Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

188 lines
3.6 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. dialogs.c
  5. Abstract:
  6. This file implements the common dialog proc and other
  7. common code used by other dialog procs. All global
  8. data used by the dialog procs lives here too.
  9. Environment:
  10. WIN32 User Mode
  11. Author:
  12. Wesley Witt (wesw) 17-Feb-1996
  13. --*/
  14. #include "wizard.h"
  15. #pragma hdrstop
  16. LRESULT
  17. CommonDlgProc(
  18. HWND hwnd,
  19. UINT msg,
  20. WPARAM wParam,
  21. LPARAM lParam
  22. )
  23. {
  24. PWIZPAGE WizPage;
  25. WizPage = (PWIZPAGE) GetWindowLong( hwnd, DWL_USER );
  26. switch( msg ) {
  27. case WM_INITDIALOG:
  28. SetWindowLong( hwnd, DWL_USER, (LONG) ((LPPROPSHEETPAGE) lParam)->lParam );
  29. WizPage = (PWIZPAGE) ((LPPROPSHEETPAGE) lParam)->lParam;
  30. SetWizPageTitle( hwnd );
  31. break;
  32. case WM_NOTIFY:
  33. switch( ((LPNMHDR)lParam)->code ) {
  34. case PSN_SETACTIVE:
  35. PropSheet_SetWizButtons(
  36. GetParent(hwnd),
  37. WizPage->ButtonState
  38. );
  39. SetWindowLong( hwnd, DWL_MSGRESULT, 0 );
  40. break;
  41. case PSN_QUERYCANCEL:
  42. {
  43. if (!OkToCancel) {
  44. DWORD Answer;
  45. MessageBeep(0);
  46. Answer = PopUpMsg( hwnd, IDS_QUERY_CANCEL, FALSE, MB_YESNO );
  47. if (Answer == IDNO) {
  48. SetWindowLong( hwnd, DWL_MSGRESULT, 1 );
  49. return TRUE;
  50. } else {
  51. InstallThreadError = ERROR_CANCELLED;
  52. }
  53. }
  54. }
  55. break;
  56. }
  57. break;
  58. }
  59. if (WizPage && WizPage->DlgProc) {
  60. return WizPage->DlgProc( hwnd, msg, wParam, lParam );
  61. }
  62. return FALSE;
  63. }
  64. INT
  65. BrowseCallbackProc(
  66. HWND hwnd,
  67. UINT uMsg,
  68. LPARAM lParam,
  69. LPARAM lpData
  70. )
  71. /*++
  72. Routine Description:
  73. Callback function for SHBrowseForFolder
  74. Arguments:
  75. hwnd - Handle to the browse dialog box
  76. uMsg - Identifying the reason for the callback
  77. lParam - Message parameter
  78. lpData - Application-defined value given in BROWSEINFO.lParam
  79. Return Value:
  80. 0
  81. --*/
  82. {
  83. if (uMsg == BFFM_INITIALIZED) {
  84. TCHAR buffer[MAX_PATH];
  85. HWND hDlg = (HWND) lpData;
  86. if (GetDlgItemText(hDlg, IDC_DEST_DIRPATH, buffer, MAX_PATH)) {
  87. SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM) buffer);
  88. }
  89. }
  90. return 0;
  91. }
  92. BOOL
  93. DoBrowseDestDir(
  94. HWND hDlg
  95. )
  96. /*++
  97. Routine Description:
  98. Present a browse dialog to let user select a directory
  99. for storing inbound fax files
  100. Arguments:
  101. hDlg - Handle to the "Receive Options" property page
  102. Return Value:
  103. TRUE if successful, FALSE if user cancelled the dialog
  104. --*/
  105. {
  106. LPITEMIDLIST pidl;
  107. TCHAR buffer[MAX_PATH];
  108. TCHAR title[MAX_TITLE_LEN];
  109. VOID SHFree(LPVOID);
  110. BOOL result = FALSE;
  111. BROWSEINFO bi = {
  112. hDlg,
  113. NULL,
  114. buffer,
  115. title,
  116. BIF_RETURNONLYFSDIRS,
  117. BrowseCallbackProc,
  118. (LPARAM) hDlg,
  119. };
  120. _tcsncpy( title, GetString( IDS_INBOUND_DIR ), MAX_TITLE_LEN );
  121. if (pidl = SHBrowseForFolder(&bi)) {
  122. if (SHGetPathFromIDList(pidl, buffer)) {
  123. SetDlgItemText(hDlg, IDC_DEST_DIRPATH, buffer);
  124. result = TRUE;
  125. }
  126. SHFree(pidl);
  127. }
  128. return result;
  129. }