Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

help.c File Reference

#include "precomp.h"

Go to the source code of this file.

Defines

#define MAX_ATTEMPTS   5
#define HLP_POPUP   'p'
#define HLP_TRAININGCARD   'c'
#define HLP_APPLICATION   'x'

Functions

LRESULT SendWinHelpMessage (HWND hwnd, WPARAM wParam, LPARAM lParam)
LPHLP HFill (LPCSTR lpszHelp, DWORD ulCommand, ULONG_PTR ulData)
BOOL LaunchHelper (LPWSTR lpfile, DWORD dwType)
BOOL LaunchHelp (DWORD dwType)
PWND GetNextDlgHelpItem (PWND pwndDlg, PWND pwnd)
UINT HelpMenu (HWND hwnd, PPOINT ppt)
HWND FindWinHelpWindow (LPCWSTR lpwstrHelpWindowClass, DWORD dwType, BOOL bLaunchIt)
BOOL CALLBACK EnumHwndDlgChildProc (HWND hwnd, LPARAM lParam)
BOOL WinHelpA (HWND hwnd, LPCSTR lpszHelp, UINT uCommand, ULONG_PTR dwData)
BOOL WinHelpW (HWND hwndMain, LPCWSTR lpwszHelp, UINT uCommand, ULONG_PTR dwData)

Variables

char szDefaultHelpFileA [] = "windows.hlp"
PWCHAR szEXECHELP = TEXT("\\winhlp32 - ")
PWCHAR szMS_WINHELP = L"MS_WINHELP"
PWCHAR szMS_POPUPHELP = L"MS_POPUPHELP"
PWCHAR szMS_TCARDHELP = L"MS_TCARDHELP"


Define Documentation

#define HLP_APPLICATION   'x'
 

Definition at line 26 of file client/help.c.

Referenced by LaunchHelper().

#define HLP_POPUP   'p'
 

Definition at line 24 of file client/help.c.

Referenced by LaunchHelper().

#define HLP_TRAININGCARD   'c'
 

Definition at line 25 of file client/help.c.

Referenced by LaunchHelper().

#define MAX_ATTEMPTS   5
 

Definition at line 15 of file client/help.c.


Function Documentation

BOOL CALLBACK EnumHwndDlgChildProc HWND  hwnd,
LPARAM  lParam
 

Definition at line 419 of file client/help.c.

References BOOL, EnumPwndDlgChildProc(), TRUE, and ValidateHwnd.

Referenced by WinHelpA().

00420 { 00421 PWND pwnd; 00422 BOOL bResult; 00423 00424 if (pwnd = ValidateHwnd(hwnd)) 00425 bResult = EnumPwndDlgChildProc( pwnd, lParam ); 00426 else 00427 bResult = TRUE; 00428 00429 return bResult; 00430 }

HWND FindWinHelpWindow LPCWSTR  lpwstrHelpWindowClass,
DWORD  dwType,
BOOL  bLaunchIt
 

Definition at line 375 of file client/help.c.

References FALSE, FindWindowEx(), FW_32BIT, InternalFindWindowExW(), LaunchHelp(), and NULL.

Referenced by WinHelpA().

00380 { 00381 HWND hwndHelp; 00382 00383 /* 00384 * Find the current help window. If not found, try and launch 00385 * the WinHlp32 application. We are interested only in 32 bit help. 00386 * Note that 16 bit apps don't walk this path, ntvdm taking care of 00387 * starting the 16 bit help for them. 00388 */ 00389 hwndHelp = InternalFindWindowExW(NULL, NULL, lpwstrHelpWindowClass, NULL, FW_32BIT); 00390 00391 if (hwndHelp == NULL) { 00392 if (bLaunchIt) { 00393 /* 00394 * Can't find it --> see if we want to launch it 00395 */ 00396 if ((LaunchHelp(dwType) == FALSE) || 00397 (hwndHelp = FindWindowEx(NULL, NULL, (LPWSTR)lpwstrHelpWindowClass, NULL)) == NULL) 00398 { 00399 00400 /* 00401 * Can't find help, or not enough memory to load help. 00402 * pwndHelp will be NULL at this point. 00403 */ 00404 #if DBG 00405 RIPMSG0( RIP_WARNING, "xxxWinHelpA: xxxLaunchHelp and xxxFindWinow failed." ); 00406 #endif 00407 } 00408 } 00409 } 00410 00411 return hwndHelp; 00412 }

PWND GetNextDlgHelpItem PWND  pwndDlg,
PWND  pwnd
 

Definition at line 290 of file client/help.c.

References _GetChildControl(), _IsDescendant(), _NextControl(), and NULL.

Referenced by WinHelpA().

00291 { 00292 PWND pwndSave; 00293 00294 if (pwnd == pwndDlg) 00295 pwnd = NULL; 00296 else 00297 { 00298 pwnd = _GetChildControl(pwndDlg, pwnd); 00299 if (pwnd) 00300 { 00301 if (!_IsDescendant(pwndDlg, pwnd)) 00302 return(NULL); 00303 } 00304 } 00305 00306 /* 00307 * BACKWARD COMPATIBILITY 00308 * 00309 * Note that the result when there are no tabstops of 00310 * IGetNextDlgTabItem(hwndDlg, NULL, FALSE) was the last item, now 00311 * will be the first item. We could put a check for fRecurse here 00312 * and do the old thing if not set. 00313 */ 00314 00315 /* 00316 * We are going to bug out if we hit the first child a second time. 00317 */ 00318 pwndSave = pwnd; 00319 pwnd = _NextControl(pwndDlg, pwnd, CWP_SKIPINVISIBLE); 00320 00321 while ((pwnd != pwndSave) && (pwnd != pwndDlg)) 00322 { 00323 UserAssert(pwnd); 00324 00325 if (!pwndSave) 00326 pwndSave = pwnd; 00327 00328 if ((pwnd->style & (WS_TABSTOP | WS_VISIBLE)) == (WS_TABSTOP | WS_VISIBLE)) 00329 /* 00330 * Found it. 00331 */ 00332 break; 00333 00334 pwnd = _NextControl(pwndDlg, pwnd, CWP_SKIPINVISIBLE); 00335 } 00336 00337 return(pwnd); 00338 }

UINT HelpMenu HWND  hwnd,
PPOINT  ppt
 

Definition at line 348 of file client/help.c.

References GetSubMenu(), hmodUser, ID_HELPMENU, INT, NtUserDestroyMenu(), NULL, TrackPopupMenu(), and UINT.

Referenced by WinHelpA().

00351 { 00352 INT cmd; 00353 HMENU hmenu = LoadMenu( hmodUser, MAKEINTRESOURCE(ID_HELPMENU)); 00354 00355 if (hmenu != NULL) { 00356 cmd = TrackPopupMenu( GetSubMenu(hmenu, 0), 00357 TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RETURNCMD | TPM_RIGHTBUTTON, 00358 ppt->x, ppt->y, 0, hwnd, NULL); 00359 NtUserDestroyMenu(hmenu); 00360 return cmd; 00361 } 00362 00363 return (UINT)-1; 00364 }

LPHLP HFill LPCSTR  lpszHelp,
DWORD  ulCommand,
ULONG_PTR  ulData
 

Definition at line 60 of file client/help.c.

References BYTE, DWORD, HIBYTE, NULL, and strlen().

Referenced by WinHelpA().

00064 { 00065 DWORD cb; // Size of the data block 00066 DWORD cbStr; // Length of the help file name 00067 DWORD cbData; // Size of the dwData parameter in bytes (0 if not used) 00068 LPHLP phlp; // Pointer to data block 00069 BYTE bType; // dwData parameter type 00070 00071 /* 00072 * Get the length of the help file name 00073 */ 00074 cbStr = (lpszHelp) ? strlen(lpszHelp) + 1 : 0; 00075 00076 /* 00077 * Get the length of any dwData parameters 00078 */ 00079 bType = HIBYTE(LOWORD(ulCommand)); 00080 if (ulData) { 00081 switch (bType) { 00082 case HIBYTE(HELP_HB_STRING): 00083 /* 00084 * ulData is an ANSI string, so compute its length 00085 */ 00086 cbData = strlen((LPSTR)ulData) + 1; 00087 break; 00088 00089 case HIBYTE(HELP_HB_STRUCT): 00090 /* 00091 * ulData points to a structure who's first member is 00092 * an int that contains the size of the structure in bytes. 00093 */ 00094 cbData = *((int *)ulData); 00095 break; 00096 00097 default: 00098 /* 00099 * dwData has no parameter 00100 */ 00101 cbData = 0; 00102 } 00103 } else { 00104 /* 00105 * No parameter is present 00106 */ 00107 cbData = 0; 00108 } 00109 00110 /* 00111 * Calculate size (NOTE: HLP is called WINHLP in Win95) 00112 */ 00113 cb = sizeof(HLP) + cbStr + cbData; 00114 00115 /* 00116 * Get data block 00117 */ 00118 if ((phlp = (LPHLP)LocalAlloc(LPTR, cb)) == NULL) 00119 return NULL; 00120 00121 /* 00122 * Fill in info 00123 */ 00124 phlp->cbData = (WORD)cb; 00125 phlp->usCommand = (WORD)ulCommand; 00126 phlp->ulReserved = 0; 00127 // phlp->ulTopic = 0; 00128 00129 /* 00130 * Fill in file name 00131 */ 00132 if (lpszHelp) { 00133 phlp->offszHelpFile = sizeof(HLP); // NOTE: HLP is called WINHLP in Win95 00134 strcpy((LPSTR)(phlp + 1), lpszHelp); 00135 } else { 00136 phlp->offszHelpFile = 0; 00137 } 00138 00139 /* 00140 * Fill in data 00141 */ 00142 switch (bType) { 00143 case HIBYTE(HELP_HB_STRING): 00144 if (cbData) { 00145 phlp->offabData = (WORD)(sizeof(HLP) + cbStr); // NOTE: HLP is called WINHLP in Win95 00146 strcpy((LPSTR)phlp + phlp->offabData, (LPSTR)ulData); 00147 } else { 00148 phlp->offabData = 0; 00149 } 00150 break; 00151 00152 case HIBYTE(HELP_HB_STRUCT): 00153 if (cbData) { 00154 phlp->offabData = (WORD)(sizeof(HLP) + cbStr); // NOTE: HLP is called WINHLP in Win95 00155 RtlCopyMemory((LPBYTE)phlp + phlp->offabData, (PVOID)ulData, 00156 *((int far *)ulData)); 00157 } else { 00158 phlp->offabData = 0; 00159 } 00160 break; 00161 00162 default: 00163 phlp->offabData = 0; 00164 // BradG - This item is named differently in the Win95 WINHLP structure 00165 // phlp->ctx = ulData; 00166 phlp->ulTopic = ulData; 00167 break; 00168 } 00169 00170 return(phlp); 00171 }

BOOL LaunchHelp DWORD  dwType  ) 
 

Definition at line 256 of file client/help.c.

References BOOL, L, LaunchHelper(), MAX_PATH, and TRUE.

Referenced by FindWinHelpWindow().

00257 { 00258 WCHAR wszPath[MAX_PATH]; 00259 00260 GetSystemWindowsDirectoryW(wszPath, MAX_PATH); 00261 00262 if (LaunchHelper(wszPath, dwType)) 00263 return TRUE; 00264 00265 /* 00266 * Search the system directory (Not in Win95) 00267 */ 00268 GetSystemDirectoryW(wszPath, MAX_PATH); 00269 if (LaunchHelper(wszPath, dwType)) 00270 return TRUE; 00271 00272 /* 00273 * Try the search path 00274 */ 00275 wszPath[0] = L'\0'; 00276 return LaunchHelper(wszPath, dwType); 00277 00278 }

BOOL LaunchHelper LPWSTR  lpfile,
DWORD  dwType
 

Definition at line 183 of file client/help.c.

References BOOL, DWORD, FALSE, HLP_APPLICATION, HLP_POPUP, HLP_TRAININGCARD, NtClose(), NULL, szEXECHELP, TRUE, TYPE_POPUP, TYPE_TCARD, and WaitForInputIdle().

Referenced by LaunchHelp().

00184 { 00185 int cchLen; 00186 int cchShift; 00187 DWORD idProcess; 00188 STARTUPINFO StartupInfo; 00189 PROCESS_INFORMATION ProcessInformation; 00190 PWCHAR pwcExecHelp; 00191 00192 pwcExecHelp = szEXECHELP; 00193 00194 /* 00195 * Are we at the root?? If so, skip over leading backslash in text string 00196 */ 00197 if (*lpfile) { 00198 cchLen = wcslen(lpfile); 00199 cchShift = (lpfile[cchLen - 1] == TEXT('\\')) ? 1 : 0; 00200 wcscat(lpfile, pwcExecHelp + cchShift); 00201 } else { 00202 wcscat(lpfile, pwcExecHelp + 1); 00203 } 00204 00205 00206 /* 00207 * Defaultly send "winhlp32 -x" or adjust the last flag character 00208 */ 00209 switch (dwType) { 00210 case TYPE_POPUP: 00211 lpfile[wcslen(lpfile)-1] = TEXT(HLP_POPUP); 00212 break; 00213 00214 case TYPE_TCARD: 00215 lpfile[wcslen(lpfile)-1] = TEXT(HLP_TRAININGCARD); 00216 break; 00217 00218 default: 00219 lpfile[wcslen(lpfile)-1] = TEXT(HLP_APPLICATION); 00220 break; 00221 } 00222 00223 /* 00224 * Launch winhelp 00225 */ 00226 memset(&StartupInfo,0,sizeof(StartupInfo)); 00227 StartupInfo.cb = sizeof(StartupInfo); 00228 StartupInfo.wShowWindow = SW_SHOW; 00229 StartupInfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_FORCEONFEEDBACK; 00230 00231 idProcess = (DWORD)CreateProcessW(NULL, lpfile, 00232 NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &StartupInfo, 00233 &ProcessInformation); 00234 00235 if (idProcess) { 00236 WaitForInputIdle(ProcessInformation.hProcess, 10000); 00237 NtClose(ProcessInformation.hProcess); 00238 NtClose(ProcessInformation.hThread); 00239 return TRUE; 00240 } 00241 00242 return FALSE; 00243 }

LRESULT SendWinHelpMessage HWND  hwnd,
WPARAM  wParam,
LPARAM  lParam
 

Definition at line 39 of file client/help.c.

References AllowSetForegroundWindow(), DWORD, GetWindowThreadProcessId(), and SendMessage().

Referenced by WinHelpA().

00040 { 00041 DWORD dwProcessId = 0; 00042 GetWindowThreadProcessId(hwnd, &dwProcessId); 00043 AllowSetForegroundWindow(dwProcessId); 00044 return SendMessage(hwnd, WM_WINHELP, wParam, lParam); 00045 }

BOOL WinHelpA HWND  hwnd,
LPCSTR  lpszHelp,
UINT  uCommand,
ULONG_PTR  dwData
 

Definition at line 447 of file client/help.c.

References BFTYPEMASK, BOOL, DefWindowProc(), DLGENUMDATA, DWORD, EnumChildWindows(), EnumHwndDlgChildProc(), FALSE, FindNCHit(), FindWinHelpWindow(), FIsParentDude(), FNID_BUTTON, GetCursorPos(), GETFNID, GetFocus(), GetNextDlgHelpItem(), GetTopLevelWindow(), GetWindowRect(), gpsi, HelpMenu(), HFill(), HW, MAX_ATTEMPTS, NULL, tagDLGENUMDATA::ptCurHelp, PTR_TO_ID, tagDLGENUMDATA::pwndControl, tagDLGENUMDATA::pwndDialog, tagWND::rcWindow, REBASEPWND, SendWinHelpMessage(), SHORT, tagWND::spmenu, szDefaultHelpFileA, szMS_POPUPHELP, szMS_TCARDHELP, szMS_WINHELP, TestWF, TRUE, TYPE_NORMAL, TYPE_POPUP, TYPE_TCARD, and ValidateHwnd.

Referenced by WinHelpW().

00452 { 00453 LPWSTR lpwstrHelpWindowClass; 00454 LPHLP lpHlp = NULL; 00455 DWORD dwType; 00456 PWND pwnd; 00457 HWND hwndHelp = NULL; /* Handle of help's main window */ 00458 PWND pwndTop = NULL; /* Top level window that WinHelp uses. */ 00459 PWND pwndMain; /* pointer to main help control */ 00460 LRESULT lResult; 00461 POINT ptCur; 00462 BOOL bResult = TRUE; 00463 00464 pwnd = ValidateHwnd(hwnd); 00465 00466 if (uCommand & HELP_TCARD) { 00467 /* 00468 * For Training Cards, the HELP_TCARD bit is set. We need to 00469 * set our help window class to szMS_TCARDHELP and then remove 00470 * the HELP_TCARD bit. 00471 */ 00472 lpwstrHelpWindowClass = szMS_TCARDHELP; 00473 uCommand &= ~HELP_TCARD; // mask out the tcard flag 00474 dwType = TYPE_TCARD; 00475 } else { 00476 if( (uCommand == HELP_CONTEXTMENU) || (uCommand == HELP_CONTEXTPOPUP) || 00477 (uCommand == HELP_SETPOPUP_POS) || (uCommand == HELP_WM_HELP)) { 00478 /* 00479 * Popups should be connected to a valid window. pwndMain has already 00480 * been validated as a real window handle or NULL, so we just need to 00481 * check the NULL case here. 00482 */ 00483 if (pwnd == NULL) { 00484 RIPERR1(ERROR_INVALID_PARAMETER, 00485 RIP_WARNING, 00486 "WinHelpA: NULL hWnd invalid for this type of help command (0x%X)", 00487 uCommand); 00488 00489 bResult = FALSE; 00490 goto Exit_WinHelp; 00491 } 00492 dwType = TYPE_POPUP; 00493 lpwstrHelpWindowClass = szMS_POPUPHELP; 00494 } else { 00495 dwType = TYPE_NORMAL; 00496 lpwstrHelpWindowClass = szMS_WINHELP; 00497 } 00498 } 00499 00500 /* 00501 * Get the cursor's current location This is where we assume the user 00502 * clicked. We will use this position to search for a child window and 00503 * to set the context sensitive help popup window's location. 00504 * 00505 * If the last input was a keyboard one, use the point in the center 00506 * of the focus window rectangle. MCostea #249270 00507 */ 00508 if (gpsi->bLastRITWasKeyboard) { 00509 HWND hWndFocus = GetFocus(); 00510 RECT rcWindow; 00511 00512 if (GetWindowRect(hWndFocus, &rcWindow)) { 00513 ptCur.x = (rcWindow.left + rcWindow.right)/2; 00514 ptCur.y = (rcWindow.top + rcWindow.bottom)/2; 00515 } else { 00516 goto getCursorPos; 00517 } 00518 } else { 00519 getCursorPos: 00520 GetCursorPos(&ptCur); 00521 } 00522 00523 /* 00524 * If we are handling the HELP_CONTEXTMENU command, see if we 00525 * can determine the correct child window. 00526 */ 00527 if (uCommand == HELP_CONTEXTMENU && FIsParentDude(pwnd)) { 00528 LONG lPt; 00529 int nHit; 00530 DLGENUMDATA DlgEnumData; 00531 00532 /* 00533 * If the user really clicked on the caption or the system menu, 00534 * then we want the context menu for the window, not help for a 00535 * control. This makes it consistent across all 3.x and 4.0 00536 * windows. 00537 */ 00538 lPt = MAKELONG(ptCur.x,ptCur.y); 00539 nHit = FindNCHit(pwnd, lPt); 00540 if ((nHit == HTCAPTION) || (nHit == HTSYSMENU)) 00541 DefWindowProc(hwnd, WM_CONTEXTMENU, (WPARAM)hwnd, lPt); 00542 00543 /* 00544 * If this is a dialog class, then one of three things has 00545 * happened: 00546 * 00547 * o This is a disabled control 00548 * o This is a static text control 00549 * o This is the background of the dialog box. 00550 * 00551 * What we do is enumerate the child windows and see if 00552 * any of them contain the current cursor point. If they do, 00553 * change our window handle and continue on. Otherwise, 00554 * return doing nothing -- we don't want context-sensitive 00555 * help for a dialog background. 00556 * 00557 * If this is a group box, then we might have clicked on a 00558 * disabled control, so we enumerate child windows to see 00559 * if we get another control. 00560 */ 00561 DlgEnumData.pwndDialog = pwnd; 00562 DlgEnumData.pwndControl = NULL; 00563 DlgEnumData.ptCurHelp = ptCur; 00564 EnumChildWindows(hwnd, (WNDENUMPROC)EnumHwndDlgChildProc, (LPARAM)&DlgEnumData); 00565 if (DlgEnumData.pwndControl == NULL) { 00566 /* 00567 * Can't find a control, so nothing to do. 00568 */ 00569 goto Exit_WinHelp; 00570 } else { 00571 /* 00572 * Remember this control because it will be used as the 00573 * control for context sensitive help. 00574 */ 00575 pwndMain = DlgEnumData.pwndControl; 00576 } 00577 } else { 00578 /* 00579 * We will use pwnd as our main control. No need to lock it 00580 * because it is already locked. 00581 */ 00582 pwndMain = pwnd; 00583 } 00584 00585 /* 00586 * For HELP_CONTEXTPOPUP and HELP_WM_HELP, see if we can derive the 00587 * context id by looking at the array of double word ID pairs that 00588 * have been passed in in dwData. 00589 */ 00590 if (uCommand == HELP_CONTEXTMENU || uCommand == HELP_WM_HELP) { 00591 int id; 00592 int i; 00593 LPDWORD pid; 00594 00595 // MapIdToHelp: 00596 /* 00597 * Be careful about the cast below. We need the ID, which is stored 00598 * in the LOWORD of spmenu to be sign extended to an int. 00599 * Don't sign extend so IDs like 8008 work 00600 */ 00601 id = (DWORD)(PTR_TO_ID(pwndMain->spmenu)); // get control id 00602 pid = (LPDWORD) dwData; 00603 00604 /* 00605 * Is the control's ID -1? 00606 */ 00607 if ((SHORT)id == -1) 00608 { 00609 /* 00610 * This is a static (i.e., ID'less) control 00611 */ 00612 PWND pwndCtrl; 00613 int cAttempts = 0; 00614 00615 /* 00616 * If the control is a group box, with an ID of -1, bail out 00617 * as the UI specs decided to have no context help 00618 * for these cases. MCostea 00619 */ 00620 if ((TestWF(pwndMain, BFTYPEMASK) == BS_GROUPBOX) && 00621 (GETFNID(pwndMain) == FNID_BUTTON)) { 00622 goto Exit_WinHelp; 00623 } 00624 00625 /* 00626 * For non-id controls (typically static controls), step 00627 * through to the next tab item. Keep finding the next tab 00628 * item until we find a valid id, or we have tried 00629 * MAX_ATTEMPTS times. 00630 */ 00631 do { 00632 pwndCtrl = GetNextDlgHelpItem( REBASEPWND(pwndMain,spwndParent), pwndMain ); 00633 00634 /* 00635 * pwndCtrl will be NULL if hwndMain doesn't have a parent, 00636 * or if there are no tab stops. 00637 */ 00638 if (!pwndCtrl) { 00639 /* 00640 * Remember to unlock the control 00641 */ 00642 bResult = FALSE; 00643 goto Exit_WinHelp; 00644 } 00645 00646 /* 00647 * Be careful about the cast below. We need the ID, which is stored 00648 * in the LOWORD of spmenu to be sign extended to an int. 00649 * Don't sign extend so IDs like 8008 work 00650 */ 00651 id = (DWORD)(PTR_TO_ID(pwndCtrl->spmenu)); 00652 00653 } while (((SHORT)id == -1) && (++cAttempts < MAX_ATTEMPTS)); 00654 } 00655 00656 if ((SHORT)id == -1) { 00657 id = -1; 00658 } 00659 00660 /* 00661 * Find the id value in array of id/help context values 00662 */ 00663 for (i = 0; pid[i]; i += 2) { 00664 if ((int) pid[i] == id) 00665 break; 00666 } 00667 00668 /* 00669 * Since no help was specified for the found control, see if 00670 * the control is one of the known ID (i.e., OK, Cancel...) 00671 */ 00672 if (!pid[i]) { 00673 /* 00674 * Help for the standard controls is in the default 00675 * help file windows.hlp. Switch to this file. 00676 */ 00677 lpszHelp = szDefaultHelpFileA; 00678 00679 switch (id) { 00680 case IDOK: 00681 dwData = IDH_OK; 00682 break; 00683 00684 case IDCANCEL: 00685 dwData = IDH_CANCEL; 00686 break; 00687 00688 case IDHELP: 00689 dwData = IDH_HELP; 00690 break; 00691 00692 default: 00693 /* 00694 * Unknown control, give a generic missing context info 00695 * popup message in windows.hlp. 00696 */ 00697 dwData = IDH_MISSING_CONTEXT; 00698 } 00699 } else { 00700 dwData = pid[i + 1]; 00701 if (dwData == (DWORD)-1) { 00702 /* 00703 * Remember, to unlock the control 00704 */ 00705 goto Exit_WinHelp; // caller doesn't want help after all 00706 } 00707 } 00708 00709 /* 00710 * Now that we know the caller wants help for this control, display the 00711 * help menu. 00712 */ 00713 if (uCommand == HELP_CONTEXTMENU) 00714 { 00715 int cmd; 00716 00717 /* 00718 * Must lock pwndMain because it may have been reassigned above. 00719 */ 00720 cmd = HelpMenu(HW(pwndMain), &ptCur); 00721 if (cmd <= 0) // probably means user cancelled the menu 00722 goto Exit_WinHelp; 00723 } 00724 00725 /* 00726 * Create WM_WINHELP's HLP data structure for HELP_SETPOPUP_POS 00727 */ 00728 if (!(lpHlp = HFill(lpszHelp, HELP_SETPOPUP_POS, 00729 MAKELONG(pwndMain->rcWindow.left, pwndMain->rcWindow.top)))) { 00730 /* 00731 * Remember to unlock pwndMain if needed 00732 */ 00733 bResult = FALSE; 00734 goto Exit_WinHelp; 00735 } 00736 00737 /* 00738 * Tell WinHelp where to put the popup. This is different than Win95 00739 * because we try and avoid a recursive call here. So, we find the 00740 * WinHlp32 window and send the HELP_SETPOPUP_POS. No recursion. 00741 */ 00742 hwndHelp = FindWinHelpWindow( lpwstrHelpWindowClass, dwType, TRUE); 00743 if (hwndHelp == NULL ) { 00744 /* 00745 * Uable to communicate with WinHlp32.exe. 00746 * Remember to unlock the control 00747 */ 00748 bResult = FALSE; 00749 goto Exit_WinHelp; 00750 } 00751 00752 /* 00753 * Send the WM_WINHELP message to WinHlp32's window. 00754 */ 00755 lResult = SendWinHelpMessage(hwndHelp, (WPARAM)HW(pwndMain), (LPARAM)lpHlp); 00756 LocalFree(lpHlp); 00757 lpHlp = NULL; 00758 00759 /* BradG - revalidate pwndMain? */ 00760 00761 if (!lResult) 00762 { 00763 /* 00764 * WinHlp32 couldn't process the command. Bail out! 00765 */ 00766 bResult = FALSE; 00767 goto Exit_WinHelp; 00768 } 00769 00770 /* 00771 * Make HELP_WM_HELP and HELP_CONTEXTMENU act like HELP_CONTEXTPOPUP 00772 */ 00773 uCommand = HELP_CONTEXTPOPUP; 00774 } 00775 00776 00777 if (uCommand == HELP_CONTEXTPOPUP ) { 00778 // MapNullHlpToWindowsHlp: 00779 /* 00780 * If no help file was specified, use windows.hlp 00781 */ 00782 if (lpszHelp == NULL || *lpszHelp == '\0') 00783 lpszHelp = szDefaultHelpFileA; // default: use windows.hlp 00784 00785 /* 00786 * WINHELP.EXE will call SetForegroundWindow on the hwnd that we pass 00787 * to it below. We really want to pass the parent dialog hwnd of the 00788 * control so that focus will properly be restored to the dialog and 00789 * not the control that wants help. 00790 */ 00791 pwndTop = GetTopLevelWindow(pwndMain); 00792 } else { 00793 pwndTop = pwndMain; 00794 } 00795 00796 00797 /* 00798 * Move Help file name to a handle 00799 */ 00800 if (!(lpHlp = HFill(lpszHelp, uCommand, dwData))) { 00801 /* 00802 * Can't allocate memory 00803 */ 00804 bResult = FALSE; 00805 goto Exit_WinHelp; 00806 } 00807 00808 /* 00809 * Get a pointer to the help window. 00810 */ 00811 hwndHelp = FindWinHelpWindow( lpwstrHelpWindowClass, dwType, (uCommand != HELP_QUIT)); 00812 if (hwndHelp == NULL) { 00813 if (uCommand != HELP_QUIT) 00814 /* 00815 * Can't find Winhlp 00816 */ 00817 bResult = FALSE; 00818 goto Exit_WinHelp; 00819 } 00820 00821 /* 00822 * Send the WM_WINHELP message to WinHlp32's window 00823 * Must ThreadLock pwndHelp AND pwndMain (because pwndMain may have been 00824 * reassigned above). 00825 */ 00826 SendWinHelpMessage(hwndHelp, (WPARAM)HW(pwndTop), (LPARAM)lpHlp); 00827 00828 /* 00829 * Free the help info data structure (if not already free). 00830 */ 00831 Exit_WinHelp: 00832 if (lpHlp != NULL) { 00833 LocalFree(lpHlp); 00834 } 00835 00836 return bResult; 00837 }

BOOL WinHelpW HWND  hwndMain,
LPCWSTR  lpwszHelp,
UINT  uCommand,
ULONG_PTR  dwData
 

Definition at line 1116 of file client/help.c.

References BOOL, CHAR, FALSE, NT_SUCCESS, NTSTATUS(), NULL, RtlUnicodeToMultiByteN(), Status, strlen(), TRUE, and WinHelpA().

Referenced by ImeRunHelp().

01121 { 01122 BOOL fSuccess = FALSE; 01123 LPSTR lpAnsiHelp = NULL; 01124 LPSTR lpAnsiKey = NULL; 01125 PMULTIKEYHELPA pmkh = NULL; 01126 PHELPWININFOA phwi = NULL; 01127 NTSTATUS Status; 01128 01129 01130 /* 01131 * First convert the string. 01132 */ 01133 if (lpwszHelp != NULL && 01134 !WCSToMB(lpwszHelp, -1, &lpAnsiHelp, -1, TRUE)) { 01135 return FALSE; 01136 } 01137 01138 /* 01139 * Then convert dwData if needed 01140 */ 01141 switch (uCommand) { 01142 case HELP_MULTIKEY: 01143 if (!WCSToMB(((PMULTIKEYHELPW)dwData)->szKeyphrase, -1, &lpAnsiKey, 01144 -1, TRUE)) { 01145 goto FreeAnsiHelp; 01146 } 01147 01148 pmkh = (PMULTIKEYHELPA)LocalAlloc(LPTR, 01149 sizeof(MULTIKEYHELPA) + strlen(lpAnsiKey)); 01150 if (pmkh == NULL) { 01151 goto FreeAnsiKeyAndHelp; 01152 } 01153 01154 pmkh->mkSize = sizeof(MULTIKEYHELPA) + strlen(lpAnsiKey); 01155 Status = RtlUnicodeToMultiByteN((LPSTR)&pmkh->mkKeylist, sizeof(CHAR), 01156 NULL, (LPWSTR)&((PMULTIKEYHELPW)dwData)->mkKeylist, 01157 sizeof(WCHAR)); 01158 strcpy(pmkh->szKeyphrase, lpAnsiKey); 01159 if (!NT_SUCCESS(Status)) { 01160 goto FreeAnsiKeyAndHelp; 01161 } 01162 01163 dwData = (ULONG_PTR)pmkh; 01164 break; 01165 01166 case HELP_SETWINPOS: 01167 if (!WCSToMB(((PHELPWININFOW)dwData)->rgchMember, -1, &lpAnsiKey, 01168 -1, TRUE)) { 01169 goto FreeAnsiKeyAndHelp; 01170 } 01171 01172 phwi = (PHELPWININFOA)LocalAlloc(LPTR, ((PHELPWININFOW)dwData)->wStructSize); 01173 if (phwi == NULL) { 01174 goto FreeAnsiKeyAndHelp; 01175 } 01176 01177 *phwi = *((PHELPWININFOA)dwData); // copies identical parts 01178 strcpy(phwi->rgchMember, lpAnsiKey); 01179 dwData = (ULONG_PTR)phwi; 01180 break; 01181 01182 case HELP_KEY: 01183 case HELP_PARTIALKEY: 01184 case HELP_COMMAND: 01185 if (!WCSToMB((LPCTSTR)dwData, -1, &lpAnsiKey, -1, TRUE)) { 01186 goto FreeAnsiKeyAndHelp; 01187 } 01188 01189 dwData = (ULONG_PTR)lpAnsiKey; 01190 break; 01191 } 01192 01193 /* 01194 * Call the Ansi version 01195 */ 01196 fSuccess = WinHelpA(hwndMain, lpAnsiHelp, uCommand, dwData); 01197 01198 if (pmkh) { 01199 LocalFree(pmkh); 01200 } 01201 01202 if (phwi) { 01203 LocalFree(phwi); 01204 } 01205 01206 FreeAnsiKeyAndHelp: 01207 if (lpAnsiKey) { 01208 LocalFree(lpAnsiKey); 01209 } 01210 01211 01212 FreeAnsiHelp: 01213 if (lpAnsiHelp) 01214 LocalFree(lpAnsiHelp); 01215 01216 return fSuccess; 01217 }


Variable Documentation

char szDefaultHelpFileA[] = "windows.hlp"
 

Definition at line 16 of file client/help.c.

Referenced by WinHelpA().

PWCHAR szEXECHELP = TEXT("\\winhlp32 - ")
 

Definition at line 18 of file client/help.c.

Referenced by LaunchHelper().

PWCHAR szMS_POPUPHELP = L"MS_POPUPHELP"
 

Definition at line 20 of file client/help.c.

Referenced by WinHelpA().

PWCHAR szMS_TCARDHELP = L"MS_TCARDHELP"
 

Definition at line 21 of file client/help.c.

Referenced by WinHelpA().

PWCHAR szMS_WINHELP = L"MS_WINHELP"
 

Definition at line 19 of file client/help.c.

Referenced by WinHelpA().


Generated on Sat May 15 19:44:04 2004 for test by doxygen 1.3.7