SetScrollInfo : don't show/hide scrollbar if no parameter (minval,
[wine.git] / windows / winhelp.c
blob9e3ca16c78f6adef16fceb73fd532bf95307c5c6
1 /*
2 * Windows Help
3 */
5 #include <stdlib.h>
6 #include <stdio.h>
7 #include <string.h>
8 #include <unistd.h>
9 #include "debugtools.h"
10 #include "windef.h"
11 #include "wingdi.h"
12 #include "wine/winuser16.h"
13 #include "wine/winbase16.h"
14 #include "heap.h"
15 #include "ldt.h"
16 #include "syslevel.h"
18 DEFAULT_DEBUG_CHANNEL(win);
21 /**********************************************************************
22 * WinHelp16 (USER.171)
24 BOOL16 WINAPI WinHelp16( HWND16 hWnd, LPCSTR lpHelpFile, UINT16 wCommand,
25 DWORD dwData )
27 BOOL ret;
28 /* We might call WinExec() */
29 SYSLEVEL_ReleaseWin16Lock();
31 if (!(ret = WinHelpA( hWnd, lpHelpFile, wCommand, (DWORD)PTR_SEG_TO_LIN(dwData) )))
33 /* try to start the 16-bit winhelp */
34 if (WinExec( "winhelp.exe -x", SW_SHOWNORMAL ) >= 32)
36 Yield16();
37 ret = WinHelpA( hWnd, lpHelpFile, wCommand, (DWORD)PTR_SEG_TO_LIN(dwData) );
41 SYSLEVEL_RestoreWin16Lock();
42 return ret;
46 /**********************************************************************
47 * WinHelpA (USER32.579)
49 BOOL WINAPI WinHelpA( HWND hWnd, LPCSTR lpHelpFile, UINT wCommand,
50 DWORD dwData )
52 static WORD WM_WINHELP = 0;
53 HWND hDest;
54 LPWINHELP lpwh;
55 HGLOBAL16 hwh;
56 int size,dsize,nlen;
59 if(!WM_WINHELP)
61 WM_WINHELP=RegisterWindowMessageA("WM_WINHELP");
62 if(!WM_WINHELP)
63 return FALSE;
66 hDest = FindWindowA( "MS_WINHELP", NULL );
67 if(!hDest) {
68 if(wCommand == HELP_QUIT) return TRUE;
69 if (WinExec ( "winhlp32.exe -x", SW_SHOWNORMAL ) < 32) return FALSE;
70 if ( ! ( hDest = FindWindowA ( "MS_WINHELP", NULL ) )) return FALSE;
74 switch(wCommand)
76 case HELP_CONTEXT:
77 case HELP_SETCONTENTS:
78 case HELP_CONTENTS:
79 case HELP_CONTEXTPOPUP:
80 case HELP_FORCEFILE:
81 case HELP_HELPONHELP:
82 case HELP_FINDER:
83 case HELP_QUIT:
84 dsize=0;
85 break;
86 case HELP_KEY:
87 case HELP_PARTIALKEY:
88 case HELP_COMMAND:
89 dsize = dwData ? strlen( (LPSTR)dwData )+1: 0;
90 break;
91 case HELP_MULTIKEY:
92 dsize = ((LPMULTIKEYHELP)dwData)->mkSize;
93 break;
94 case HELP_SETWINPOS:
95 dsize = ((LPHELPWININFO)dwData)->wStructSize;
96 break;
97 default:
98 WARN("Unknown help command %d\n",wCommand);
99 return FALSE;
101 if(lpHelpFile)
102 nlen = strlen(lpHelpFile)+1;
103 else
104 nlen = 0;
105 size = sizeof(WINHELP) + nlen + dsize;
106 hwh = GlobalAlloc16(0,size);
107 lpwh = GlobalLock16(hwh);
108 lpwh->size = size;
109 lpwh->command = wCommand;
110 lpwh->data = dwData;
111 if(nlen) {
112 strcpy(((char*)lpwh) + sizeof(WINHELP),lpHelpFile);
113 lpwh->ofsFilename = sizeof(WINHELP);
114 } else
115 lpwh->ofsFilename = 0;
116 if(dsize) {
117 memcpy(((char*)lpwh)+sizeof(WINHELP)+nlen,(LPSTR)dwData,dsize);
118 lpwh->ofsData = sizeof(WINHELP)+nlen;
119 } else
120 lpwh->ofsData = 0;
121 GlobalUnlock16(hwh);
122 return SendMessage16(hDest,WM_WINHELP,hWnd,hwh);
126 /**********************************************************************
127 * WinHelpW (USER32.580)
129 BOOL WINAPI WinHelpW( HWND hWnd, LPCWSTR helpFile, UINT command,
130 DWORD dwData )
132 LPSTR file = HEAP_strdupWtoA( GetProcessHeap(), 0, helpFile );
133 BOOL ret = WinHelpA( hWnd, file, command, dwData );
134 HeapFree( GetProcessHeap(), 0, file );
135 return ret;