Small fix.
[wine/multimedia.git] / windows / winhelp.c
blob3a8ea2e24815d9056a6b53487c1fd1befde236ed
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)
56 if(wCommand == HELP_QUIT)
57 return TRUE;
58 else
59 return FALSE;
60 switch(wCommand)
62 case HELP_CONTEXT:
63 case HELP_SETCONTENTS:
64 case HELP_CONTENTS:
65 case HELP_CONTEXTPOPUP:
66 case HELP_FORCEFILE:
67 case HELP_HELPONHELP:
68 case HELP_FINDER:
69 case HELP_QUIT:
70 dsize=0;
71 break;
72 case HELP_KEY:
73 case HELP_PARTIALKEY:
74 case HELP_COMMAND:
75 dsize = strlen( (LPSTR)dwData )+1;
76 break;
77 case HELP_MULTIKEY:
78 dsize = ((LPMULTIKEYHELP)dwData)->mkSize;
79 break;
80 case HELP_SETWINPOS:
81 dsize = ((LPHELPWININFO)dwData)->wStructSize;
82 break;
83 default:
84 WARN( win,"Unknown help command %d\n",wCommand);
85 return FALSE;
87 if(lpHelpFile)
88 nlen = strlen(lpHelpFile)+1;
89 else
90 nlen = 0;
91 size = sizeof(WINHELP) + nlen + dsize;
92 hwh = GlobalAlloc16(0,size);
93 lpwh = GlobalLock16(hwh);
94 lpwh->size = size;
95 lpwh->command = wCommand;
96 lpwh->data = dwData;
97 if(nlen) {
98 strcpy(((char*)lpwh) + sizeof(WINHELP),lpHelpFile);
99 lpwh->ofsFilename = sizeof(WINHELP);
100 } else
101 lpwh->ofsFilename = 0;
102 if(dsize) {
103 memcpy(((char*)lpwh)+sizeof(WINHELP)+nlen,(LPSTR)dwData,dsize);
104 lpwh->ofsData = sizeof(WINHELP)+nlen;
105 } else
106 lpwh->ofsData = 0;
107 GlobalUnlock16(hwh);
108 return SendMessage16(hDest,WM_WINHELP,hWnd,hwh);
112 /**********************************************************************
113 * WinHelp32W (USER32.580)
115 BOOL32 WINAPI WinHelp32W( HWND32 hWnd, LPCWSTR helpFile, UINT32 command,
116 DWORD dwData )
118 LPSTR file = HEAP_strdupWtoA( GetProcessHeap(), 0, helpFile );
119 BOOL32 ret = WinHelp32A( hWnd, file, command, dwData );
120 HeapFree( GetProcessHeap(), 0, file );
121 return ret;