Hacks to support server-side console. Should be redone properly
[wine/multimedia.git] / windows / winhelp.c
blob0019d0ee82c2077b697c6d5dcf484d78a44bd434
1 /*
2 * Windows Help
3 */
5 #include <stdlib.h>
6 #include <stdio.h>
7 #include <string.h>
8 #include <unistd.h>
9 #include "debug.h"
10 #include "windows.h"
11 #include "heap.h"
12 #include "ldt.h"
15 /**********************************************************************
16 * WinHelp16 (USER.171)
18 BOOL16 WINAPI WinHelp16( HWND16 hWnd, LPCSTR lpHelpFile, UINT16 wCommand,
19 DWORD dwData )
21 return WinHelp32A( hWnd, lpHelpFile, wCommand,
22 (DWORD)PTR_SEG_TO_LIN(dwData) );
26 /**********************************************************************
27 * WinHelp32A (USER32.579)
29 BOOL32 WINAPI WinHelp32A( HWND32 hWnd, LPCSTR lpHelpFile, UINT32 wCommand,
30 DWORD dwData )
32 static WORD WM_WINHELP = 0;
33 HWND32 hDest;
34 LPWINHELP lpwh;
35 HGLOBAL16 hwh;
36 int size,dsize,nlen;
37 if (wCommand != HELP_QUIT) /* FIXME */
39 if (WinExec32("winhelp.exe -x",SW_SHOWNORMAL) <= 32)
40 return FALSE;
42 /* NOTE: Probably, this should be directed yield,
43 to let winhelp open the window in all cases. */
44 Yield16();
47 if(!WM_WINHELP)
49 WM_WINHELP=RegisterWindowMessage32A("WM_WINHELP");
50 if(!WM_WINHELP)
51 return FALSE;
54 hDest = FindWindow32A( "MS_WINHELP", NULL );
55 if(!hDest)
57 if(wCommand == HELP_QUIT)
58 return TRUE;
59 else
60 return FALSE;
62 switch(wCommand)
64 case HELP_CONTEXT:
65 case HELP_SETCONTENTS:
66 case HELP_CONTENTS:
67 case HELP_CONTEXTPOPUP:
68 case HELP_FORCEFILE:
69 case HELP_HELPONHELP:
70 case HELP_FINDER:
71 case HELP_QUIT:
72 dsize=0;
73 break;
74 case HELP_KEY:
75 case HELP_PARTIALKEY:
76 case HELP_COMMAND:
77 dsize = strlen( (LPSTR)dwData )+1;
78 break;
79 case HELP_MULTIKEY:
80 dsize = ((LPMULTIKEYHELP)dwData)->mkSize;
81 break;
82 case HELP_SETWINPOS:
83 dsize = ((LPHELPWININFO)dwData)->wStructSize;
84 break;
85 default:
86 WARN( win,"Unknown help command %d\n",wCommand);
87 return FALSE;
89 if(lpHelpFile)
90 nlen = strlen(lpHelpFile)+1;
91 else
92 nlen = 0;
93 size = sizeof(WINHELP) + nlen + dsize;
94 hwh = GlobalAlloc16(0,size);
95 lpwh = GlobalLock16(hwh);
96 lpwh->size = size;
97 lpwh->command = wCommand;
98 lpwh->data = dwData;
99 if(nlen) {
100 strcpy(((char*)lpwh) + sizeof(WINHELP),lpHelpFile);
101 lpwh->ofsFilename = sizeof(WINHELP);
102 } else
103 lpwh->ofsFilename = 0;
104 if(dsize) {
105 memcpy(((char*)lpwh)+sizeof(WINHELP)+nlen,(LPSTR)dwData,dsize);
106 lpwh->ofsData = sizeof(WINHELP)+nlen;
107 } else
108 lpwh->ofsData = 0;
109 GlobalUnlock16(hwh);
110 return SendMessage16(hDest,WM_WINHELP,hWnd,hwh);
114 /**********************************************************************
115 * WinHelp32W (USER32.580)
117 BOOL32 WINAPI WinHelp32W( HWND32 hWnd, LPCWSTR helpFile, UINT32 command,
118 DWORD dwData )
120 LPSTR file = HEAP_strdupWtoA( GetProcessHeap(), 0, helpFile );
121 BOOL32 ret = WinHelp32A( hWnd, file, command, dwData );
122 HeapFree( GetProcessHeap(), 0, file );
123 return ret;