Added proc to start debugging process from its command line (by launching it).
[wine.git] / windows / winhelp.c
blob8f897cb6cf4f1108559faaf3fb1929e7692a6a4e
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 "winversion.h"
15 #include "heap.h"
16 #include "ldt.h"
17 #include "syslevel.h"
19 DEFAULT_DEBUG_CHANNEL(win)
22 /**********************************************************************
23 * WinHelp16 (USER.171)
25 BOOL16 WINAPI WinHelp16( HWND16 hWnd, LPCSTR lpHelpFile, UINT16 wCommand,
26 DWORD dwData )
28 BOOL ret;
29 /* We might call WinExec() */
30 SYSLEVEL_ReleaseWin16Lock();
31 ret = WinHelpA( hWnd, lpHelpFile, wCommand, (DWORD)PTR_SEG_TO_LIN(dwData) );
32 SYSLEVEL_RestoreWin16Lock();
33 return ret;
37 /**********************************************************************
38 * WinHelp32A (USER32.579)
40 BOOL WINAPI WinHelpA( HWND hWnd, LPCSTR lpHelpFile, UINT wCommand,
41 DWORD dwData )
43 static WORD WM_WINHELP = 0;
44 HWND hDest;
45 LPWINHELP lpwh;
46 HGLOBAL16 hwh;
47 HINSTANCE winhelp;
48 int size,dsize,nlen;
51 if(!WM_WINHELP)
53 WM_WINHELP=RegisterWindowMessageA("WM_WINHELP");
54 if(!WM_WINHELP)
55 return FALSE;
58 hDest = FindWindowA( "MS_WINHELP", NULL );
59 if(!hDest) {
60 if(wCommand == HELP_QUIT)
61 return TRUE;
62 else
63 if ( VERSION_GetVersion() == WIN31 ) {
64 winhelp = WinExec ( "winhelp.exe -x", SW_SHOWNORMAL );
65 Yield16();
67 else {
68 winhelp = WinExec ( "winhlp32.exe -x", SW_SHOWNORMAL );
70 if ( winhelp <= 32 ) return FALSE;
71 if ( ! ( hDest = FindWindowA ( "MS_WINHELP", NULL ) )) return FALSE;
75 switch(wCommand)
77 case HELP_CONTEXT:
78 case HELP_SETCONTENTS:
79 case HELP_CONTENTS:
80 case HELP_CONTEXTPOPUP:
81 case HELP_FORCEFILE:
82 case HELP_HELPONHELP:
83 case HELP_FINDER:
84 case HELP_QUIT:
85 dsize=0;
86 break;
87 case HELP_KEY:
88 case HELP_PARTIALKEY:
89 case HELP_COMMAND:
90 dsize = strlen( (LPSTR)dwData )+1;
91 break;
92 case HELP_MULTIKEY:
93 dsize = ((LPMULTIKEYHELP)dwData)->mkSize;
94 break;
95 case HELP_SETWINPOS:
96 dsize = ((LPHELPWININFO)dwData)->wStructSize;
97 break;
98 default:
99 WARN("Unknown help command %d\n",wCommand);
100 return FALSE;
102 if(lpHelpFile)
103 nlen = strlen(lpHelpFile)+1;
104 else
105 nlen = 0;
106 size = sizeof(WINHELP) + nlen + dsize;
107 hwh = GlobalAlloc16(0,size);
108 lpwh = GlobalLock16(hwh);
109 lpwh->size = size;
110 lpwh->command = wCommand;
111 lpwh->data = dwData;
112 if(nlen) {
113 strcpy(((char*)lpwh) + sizeof(WINHELP),lpHelpFile);
114 lpwh->ofsFilename = sizeof(WINHELP);
115 } else
116 lpwh->ofsFilename = 0;
117 if(dsize) {
118 memcpy(((char*)lpwh)+sizeof(WINHELP)+nlen,(LPSTR)dwData,dsize);
119 lpwh->ofsData = sizeof(WINHELP)+nlen;
120 } else
121 lpwh->ofsData = 0;
122 GlobalUnlock16(hwh);
123 return SendMessage16(hDest,WM_WINHELP,hWnd,hwh);
127 /**********************************************************************
128 * WinHelp32W (USER32.580)
130 BOOL WINAPI WinHelpW( HWND hWnd, LPCWSTR helpFile, UINT command,
131 DWORD dwData )
133 LPSTR file = HEAP_strdupWtoA( GetProcessHeap(), 0, helpFile );
134 BOOL ret = WinHelpA( hWnd, file, command, dwData );
135 HeapFree( GetProcessHeap(), 0, file );
136 return ret;