Leaked source code of windows server 2003
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.

243 lines
6.5 KiB

  1. /*
  2. * TEMPLATE.C
  3. *
  4. * Copyright (c)1992 Microsoft Corporation, All Right Reserved
  5. *
  6. *
  7. * CUSTOMIZATION INSTRUCTIONS:
  8. *
  9. * 1. Replace <FILE> with the uppercased filename for this file.
  10. * Lowercase the <FILE>.h entry
  11. *
  12. * 2. Replace <NAME> with the mixed case dialog name in one word,
  13. * such as InsertObject
  14. *
  15. * 3. Replace <FULLNAME> with the mixed case dialog name in multiple
  16. * words, such as Insert Object
  17. *
  18. * 4. Replace <ABBREV> with the suffix for pointer variables, such
  19. * as the IO in InsertObject's pIO or the CI in ChangeIcon's pCI.
  20. * Check the alignment of the first variable declaration in the
  21. * Dialog Proc after this. I will probably be misaligned with the
  22. * rest of the variables.
  23. *
  24. * 5. Replace <STRUCT> with the uppercase structure name for this
  25. * dialog sans OLEUI, such as INSERTOBJECT. Changes OLEUI<STRUCT>
  26. * in most cases, but we also use this for IDD_<STRUCT> as the
  27. * standard template resource ID.
  28. *
  29. * 6. Find <UFILL> fields and fill them out with whatever is appropriate.
  30. *
  31. * 7. Delete this header up to the start of the next comment.
  32. */
  33. /*
  34. * <FILE>.C
  35. *
  36. * Implements the OleUI<NAME> function which invokes the complete
  37. * <FULLNAME> dialog.
  38. *
  39. * Copyright (c)1992 Microsoft Corporation, All Right Reserved
  40. */
  41. #define STRICT 1
  42. #include "ole2ui.h"
  43. #include "common.h"
  44. #ifndef WIN32
  45. #include "<FILE>.h"
  46. #else
  47. #include "template.h"
  48. #endif
  49. /*
  50. * OleUI<NAME>
  51. *
  52. * Purpose:
  53. * Invokes the standard OLE <FULLNAME> dialog box allowing the user
  54. * to <UFILL>
  55. *
  56. * Parameters:
  57. * lp<ABBREV> LPOLEUI<NAME> pointing to the in-out structure
  58. * for this dialog.
  59. *
  60. * Return Value:
  61. * UINT One of the following codes, indicating success or error:
  62. * OLEUI_SUCCESS Success
  63. * OLEUI_ERR_STRUCTSIZE The dwStructSize value is wrong
  64. */
  65. STDAPI_(UINT) OleUI<NAME>(LPOLEUI<STRUCT> lp<ABBREV>)
  66. {
  67. UINT uRet;
  68. HGLOBAL hMemDlg=NULL;
  69. uRet=UStandardValidation((LPOLEUISTANDARD)lp<ABBREV>, sizeof(OLEUI<STRUCT>)
  70. , &hMemDlg);
  71. if (OLEUI_SUCCESS!=uRet)
  72. return uRet;
  73. /*
  74. * PERFORM ANY STRUCTURE-SPECIFIC VALIDATION HERE!
  75. * ON FAILURE:
  76. * {
  77. * if (NULL!=hMemDlg)
  78. * FreeResource(hMemDlg)
  79. *
  80. * return OLEUI_<ABBREV>ERR_<ERROR>
  81. * }
  82. */
  83. //Now that we've validated everything, we can invoke the dialog.
  84. uRet=UStandardInvocation(<NAME>DialogProc, (LPOLEUISTANDARD)lp<ABBREV>
  85. , hMemDlg, MAKEINTRESOURCE(IDD_<STRUCT>));
  86. /*
  87. * IF YOU ARE CREATING ANYTHING BASED ON THE RESULTS, DO IT HERE.
  88. */
  89. <UFILL>
  90. return uRet;
  91. }
  92. /*
  93. * <NAME>DialogProc
  94. *
  95. * Purpose:
  96. * Implements the OLE <FULLNAME> dialog as invoked through the
  97. * OleUI<NAME> function.
  98. *
  99. * Parameters:
  100. * Standard
  101. *
  102. * Return Value:
  103. * Standard
  104. */
  105. BOOL CALLBACK EXPORT <NAME>DialogProc(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam)
  106. {
  107. P<STRUCT> p<ABBREV>;
  108. BOOL fHook=FALSE;
  109. //Declare Win16/Win32 compatible WM_COMMAND parameters.
  110. COMMANDPARAMS(wID, wCode, hWndMsg);
  111. //This will fail under WM_INITDIALOG, where we allocate it.
  112. p<ABBREV>=(<STRUCT>)PvStandardEntry(hDlg, iMsg, wParam, lParam, &uHook);
  113. //If the hook processed the message, we're done.
  114. if (0!=uHook)
  115. return (BOOL)uHook;
  116. //Process the temination message
  117. if (iMsg==uMsgEndDialog)
  118. {
  119. //Free any specific allocations before calling StandardCleanup
  120. StandardCleanup((PVOID)p<ABBREV>, hDlg);
  121. EndDialog(hDlg, wParam);
  122. return TRUE;
  123. }
  124. switch (iMsg)
  125. {
  126. case WM_INITDIALOG:
  127. F<NAME>Init(hDlg, wParam, lParam);
  128. return TRUE;
  129. case WM_COMMAND:
  130. switch (wID)
  131. {
  132. case IDOK:
  133. /*
  134. * PERFORM WHATEVER FUNCTIONS ARE DEFAULT HERE.
  135. */
  136. SendMessage(hDlg, uMsgEndDialog, OLEUI_OK, 0L);
  137. break;
  138. case IDCANCEL:
  139. /*
  140. * PERFORM ANY UNDOs HERE, BUT NOT CLEANUP THAT WILL
  141. * ALWAYS HAPPEN WHICH SHOULD BE IN uMsgEndDialog.
  142. */
  143. SendMessage(hDlg, uMsgEndDialog, OLEUI_CANCEL, 0L);
  144. break;
  145. case ID_OLEUIHELP:
  146. PostMessage(p<ABBREV>->lpO<ABBREV>->hWndOwner, uMsgHelp
  147. , (WPARAM)hDlg, MAKELPARAM(IDD_<STRUCT>, 0));
  148. break;
  149. }
  150. break;
  151. }
  152. return FALSE;
  153. }
  154. /*
  155. * F<NAME>Init
  156. *
  157. * Purpose:
  158. * WM_INITIDIALOG handler for the <FULLNAME> dialog box.
  159. *
  160. * Parameters:
  161. * hDlg HWND of the dialog
  162. * wParam WPARAM of the message
  163. * lParam LPARAM of the message
  164. *
  165. * Return Value:
  166. * BOOL Value to return for WM_INITDIALOG.
  167. */
  168. BOOL F<NAME>Init(HWND hDlg, WPARAM wParam, LPARAM lParam)
  169. {
  170. P<STRUCT> p<ABBREV>;
  171. LPOLEUI<STRUCT> lpO<ABBREV>;
  172. HFONT hFont;
  173. //1. Copy the structure at lParam into our instance memory.
  174. p<ABBREV>=(PSTRUCT)PvStandardInit(hDlg, sizeof(<STRUCT>), TRUE, &hFont);
  175. //PvStandardInit send a termination to us already.
  176. if (NULL==p<ABBREV>)
  177. return FALSE;
  178. lpO<ABBREV>=(LPOLEUI<STRUCT>)lParam);
  179. p<ABBREV>->lpO<ABBREV>=lpO<ABBREV>;
  180. //Copy other information from lpO<ABBREV> that we might modify.
  181. <UFILL>
  182. //2. If we got a font, send it to the necessary controls.
  183. if (NULL!=hFont)
  184. {
  185. //Do this for as many controls as you need it for.
  186. SendDlgItemMessage(hDlg, ID_<UFILL>, WM_SETFONT, (WPARAM)hFont, 0L);
  187. }
  188. //3. Show or hide the help button
  189. if (!(p<ABBREV>->lpO<ABBREV>->dwFlags & <ABBREV>F_SHOWHELP))
  190. StandardShowDlgItem(hDlg, ID_OLEUIHELP, SW_HIDE);
  191. /*
  192. * PERFORM OTHER INITIALIZATION HERE. ON ANY LoadString
  193. * FAILURE POST OLEUI_MSG_ENDDIALOG WITH OLEUI_ERR_LOADSTRING.
  194. */
  195. //n. Call the hook with lCustData in lParam
  196. UStandardHook((PVOID)p<ABBREV>, hDlg, WM_INITDIALOG, wParam, lpO<ABBREV>->lCustData);
  197. return TRUE;
  198. }
  199.