Added German installation and configuration manual.
[wine] / windows / winhelp.c
1 /*
2  * Windows Help
3  */
4
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"
18
19 DEFAULT_DEBUG_CHANNEL(win)
20
21
22 /**********************************************************************
23  *             WinHelp16   (USER.171)
24  */
25 BOOL16 WINAPI WinHelp16( HWND16 hWnd, LPCSTR lpHelpFile, UINT16 wCommand,
26                          DWORD dwData )
27 {
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;
34 }
35
36
37 /**********************************************************************
38  *             WinHelpA   (USER32.579)
39  */
40 BOOL WINAPI WinHelpA( HWND hWnd, LPCSTR lpHelpFile, UINT wCommand,
41                           DWORD dwData )
42 {
43         static WORD WM_WINHELP = 0;
44         HWND hDest;
45         LPWINHELP lpwh;
46         HGLOBAL16 hwh;
47         HINSTANCE winhelp;
48         int size,dsize,nlen;
49
50
51         if(!WM_WINHELP) 
52           {
53             WM_WINHELP=RegisterWindowMessageA("WM_WINHELP");
54             if(!WM_WINHELP)
55               return FALSE;
56           }
57
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();
66             }
67             else {
68               winhelp = WinExec ( "winhlp32.exe -x", SW_SHOWNORMAL );
69             }     
70           if ( winhelp <= 32 ) return FALSE;
71           if ( ! ( hDest = FindWindowA ( "MS_WINHELP", NULL ) )) return FALSE;
72         }
73
74
75         switch(wCommand)
76         {
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 = dwData ? strlen( (LPSTR)dwData )+1: 0;
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;
101         }
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);
124 }
125
126
127 /**********************************************************************
128  *             WinHelpW   (USER32.580)
129  */
130 BOOL WINAPI WinHelpW( HWND hWnd, LPCWSTR helpFile, UINT command,
131                           DWORD dwData )
132 {
133     LPSTR file = HEAP_strdupWtoA( GetProcessHeap(), 0, helpFile );
134     BOOL ret = WinHelpA( hWnd, file, command, dwData );
135     HeapFree( GetProcessHeap(), 0, file );
136     return ret;
137 }