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.

262 lines
4.9 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. util.c
  5. Abstract:
  6. utility functions
  7. Environment:
  8. Fax configuration applet
  9. Revision History:
  10. 12/3/96 -georgeje-
  11. Created it.
  12. mm/dd/yy -author-
  13. description
  14. --*/
  15. #include <windows.h>
  16. #include <windowsx.h>
  17. #include <winfax.h>
  18. #include "faxcfg.h"
  19. #include "faxutil.h"
  20. #include "faxreg.h"
  21. #include "faxcfgrs.h"
  22. #include "faxhelp.h"
  23. extern PFAXCONNECTFAXSERVER pFaxConnectFaxServer;
  24. extern PFAXCLOSE pFaxClose;
  25. extern PFAXACCESSCHECK pFaxAccessCheck;
  26. extern HMODULE hModWinfax;
  27. extern DWORD changeFlag;
  28. VOID
  29. SetChangedFlag(
  30. HWND hDlg,
  31. BOOL changed
  32. )
  33. /*++
  34. Routine Description:
  35. Enable or disable the Apply button in the property sheet
  36. depending on if any of the dialog contents was changed
  37. Arguments:
  38. hDlg - Handle to the property page window
  39. pageIndex - Specifies the index of current property page
  40. changed - Specifies whether the Apply button should be enabled
  41. Return Value:
  42. NONE
  43. --*/
  44. {
  45. HWND hwndPropSheet;
  46. //
  47. // Enable or disable the Apply button as appropriate
  48. //
  49. hwndPropSheet = GetParent(hDlg);
  50. if (changed) {
  51. PropSheet_Changed(hwndPropSheet, hDlg);
  52. changeFlag = TRUE;
  53. } else {
  54. changeFlag = FALSE;
  55. PropSheet_UnChanged(hwndPropSheet, hDlg);
  56. }
  57. }
  58. BOOL
  59. HandleHelpPopup(
  60. HWND hDlg,
  61. UINT message,
  62. WPARAM wParam,
  63. LPARAM lParam,
  64. int index
  65. )
  66. /*++
  67. Routine Description:
  68. Handle context-sensitive help in property sheet pages
  69. Arguments:
  70. hDlg, message, wParam, lParam - Parameters passed to the dialog procedure
  71. pageIndex - Specifies the index of the current property sheet page
  72. Return Value:
  73. TRUE if the message is handle, FALSE otherwise
  74. --*/
  75. {
  76. if (message == WM_HELP) {
  77. WinHelp(((LPHELPINFO) lParam)->hItemHandle,
  78. FAXCFG_HELP_FILENAME,
  79. HELP_WM_HELP,
  80. (ULONG_PTR) arrayHelpIDs[index] );
  81. } else {
  82. WinHelp((HWND) wParam,
  83. FAXCFG_HELP_FILENAME,
  84. HELP_CONTEXTMENU,
  85. (ULONG_PTR) arrayHelpIDs[index] );
  86. }
  87. return TRUE;
  88. }
  89. VOID
  90. UnloadWinfax(
  91. )
  92. {
  93. if (hModWinfax) {
  94. FreeLibrary(hModWinfax);
  95. }
  96. hModWinfax = NULL;
  97. pFaxConnectFaxServer = NULL;
  98. pFaxClose = NULL;
  99. pFaxAccessCheck = NULL;
  100. }
  101. BOOL
  102. LoadWinfax(
  103. )
  104. {
  105. //
  106. // try to load the winfax dll
  107. //
  108. hModWinfax = LoadLibrary(L"winfax.dll");
  109. if (hModWinfax == NULL) {
  110. return FALSE;
  111. }
  112. //
  113. // get the addresses of the functions that we need
  114. //
  115. pFaxConnectFaxServer = (PFAXCONNECTFAXSERVER) GetProcAddress(hModWinfax, "FaxConnectFaxServerW");
  116. pFaxClose = (PFAXCLOSE) GetProcAddress(hModWinfax, "FaxClose");
  117. pFaxAccessCheck = (PFAXACCESSCHECK) GetProcAddress(hModWinfax, "FaxAccessCheck");
  118. if ((pFaxConnectFaxServer == NULL) || (pFaxClose == NULL) || (pFaxAccessCheck == NULL)) {
  119. UnloadWinfax();
  120. return FALSE;
  121. }
  122. return TRUE;
  123. }
  124. #if 0
  125. INT
  126. DisplayMessageDialog(
  127. HWND hwndParent,
  128. UINT type,
  129. INT titleStrId,
  130. INT formatStrId,
  131. ...
  132. )
  133. /*++
  134. Routine Description:
  135. Display a message dialog box
  136. Arguments:
  137. hwndParent - Specifies a parent window for the error message dialog
  138. type - Specifies the type of message box to be displayed
  139. titleStrId - Title string (could be a string resource ID)
  140. formatStrId - Message format string (could be a string resource ID)
  141. ...
  142. Return Value:
  143. Same as the return value from MessageBox
  144. --*/
  145. {
  146. LPTSTR pTitle, pFormat, pMessage;
  147. INT result;
  148. va_list ap;
  149. pTitle = pFormat = pMessage = NULL;
  150. if ((pTitle = AllocStringZ(MAX_TITLE_LEN)) &&
  151. (pFormat = AllocStringZ(MAX_STRING_LEN)) &&
  152. (pMessage = AllocStringZ(MAX_MESSAGE_LEN)))
  153. {
  154. //
  155. // Load dialog box title string resource
  156. //
  157. if (titleStrId == 0)
  158. titleStrId = IDS_ERROR_CFGDLGTITLE;
  159. LoadString(ghInstance, titleStrId, pTitle, MAX_TITLE_LEN);
  160. //
  161. // Load message format string resource
  162. //
  163. LoadString(ghInstance, formatStrId, pFormat, MAX_STRING_LEN);
  164. //
  165. // Compose the message string
  166. //
  167. va_start(ap, formatStrId);
  168. wvsprintf(pMessage, pFormat, ap);
  169. va_end(ap);
  170. //
  171. // Display the message box
  172. //
  173. if (type == 0)
  174. type = MB_OK | MB_ICONERROR;
  175. result = MessageBox(hwndParent, pMessage, pTitle, type);
  176. } else {
  177. MessageBeep(MB_ICONHAND);
  178. result = 0;
  179. }
  180. MemFree(pTitle);
  181. MemFree(pFormat);
  182. MemFree(pMessage);
  183. return result;
  184. }
  185. #endif