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.

229 lines
6.6 KiB

  1. /*
  2. * TEMPLATE.CPP
  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>.CPP
  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. #include "precomp.h"
  42. #include "common.h"
  43. #include "template.h"
  44. /*
  45. * OleUI<NAME>
  46. *
  47. * Purpose:
  48. * Invokes the standard OLE <FULLNAME> dialog box allowing the user
  49. * to <UFILL>
  50. *
  51. * Parameters:
  52. * lp<ABBREV> LPOLEUI<NAME> pointing to the in-out structure
  53. * for this dialog.
  54. *
  55. * Return Value:
  56. * UINT One of the following codes, indicating success or error:
  57. * OLEUI_SUCCESS Success
  58. * OLEUI_ERR_STRUCTSIZE The dwStructSize value is wrong
  59. */
  60. STDAPI_(UINT) OleUI<NAME>(LPOLEUI<STRUCT> lp<ABBREV>)
  61. {
  62. UINT uRet;
  63. HGLOBAL hMemDlg=NULL;
  64. uRet = UStandardValidation((LPOLEUISTANDARD)lp<ABBREV>,
  65. sizeof(OLEUI<STRUCT>), &hMemDlg);
  66. if (OLEUI_SUCCESS!=uRet)
  67. return uRet;
  68. /*
  69. * PERFORM ANY STRUCTURE-SPECIFIC VALIDATION HERE!
  70. * ON FAILURE:
  71. * {
  72. * return OLEUI_<ABBREV>ERR_<ERROR>
  73. * }
  74. */
  75. //Now that we've validated everything, we can invoke the dialog.
  76. uRet = UStandardInvocation(<NAME>DialogProc, (LPOLEUISTANDARD)lp<ABBREV>
  77. , hMemDlg, MAKEINTRESOURCE(IDD_<STRUCT>));
  78. /*
  79. * IF YOU ARE CREATING ANYTHING BASED ON THE RESULTS, DO IT HERE.
  80. */
  81. <UFILL>
  82. return uRet;
  83. }
  84. /*
  85. * <NAME>DialogProc
  86. *
  87. * Purpose:
  88. * Implements the OLE <FULLNAME> dialog as invoked through the
  89. * OleUI<NAME> function.
  90. *
  91. * Parameters:
  92. * Standard
  93. *
  94. * Return Value:
  95. * Standard
  96. */
  97. BOOL CALLBACK <NAME>DialogProc(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam)
  98. {
  99. P<STRUCT> p<ABBREV>;
  100. BOOL fHook=FALSE;
  101. //Declare Win16/Win32 compatible WM_COMMAND parameters.
  102. COMMANDPARAMS(wID, wCode, hWndMsg);
  103. //This will fail under WM_INITDIALOG, where we allocate it.
  104. p<ABBREV>=(<STRUCT>)PvStandardEntry(hDlg, iMsg, wParam, lParam, &uHook);
  105. //If the hook processed the message, we're done.
  106. if (0!=uHook)
  107. return (BOOL)uHook;
  108. //Process the temination message
  109. if (iMsg==uMsgEndDialog)
  110. {
  111. EndDialog(hDlg, wParam);
  112. return TRUE;
  113. }
  114. switch (iMsg)
  115. {
  116. case WM_DESTROY:
  117. if (p<ABBREV>)
  118. {
  119. //Free any specific allocations before calling StandardCleanup
  120. StandardCleanup((PVOID)p<ABBREV>, hDlg);
  121. }
  122. break;
  123. case WM_INITDIALOG:
  124. F<NAME>Init(hDlg, wParam, lParam);
  125. return TRUE;
  126. case WM_COMMAND:
  127. switch (wID)
  128. {
  129. case IDOK:
  130. /*
  131. * PERFORM WHATEVER FUNCTIONS ARE DEFAULT HERE.
  132. */
  133. SendMessage(hDlg, uMsgEndDialog, OLEUI_OK, 0L);
  134. break;
  135. case IDCANCEL:
  136. /*
  137. * PERFORM ANY UNDOs HERE, BUT NOT CLEANUP THAT WILL
  138. * ALWAYS HAPPEN WHICH SHOULD BE IN uMsgEndDialog.
  139. */
  140. SendMessage(hDlg, uMsgEndDialog, OLEUI_CANCEL, 0L);
  141. break;
  142. case ID_OLEUIHELP:
  143. PostMessage(p<ABBREV>->lpO<ABBREV>->hWndOwner, uMsgHelp
  144. , (WPARAM)hDlg, MAKELPARAM(IDD_<STRUCT>, 0));
  145. break;
  146. }
  147. break;
  148. }
  149. return FALSE;
  150. }
  151. /*
  152. * F<NAME>Init
  153. *
  154. * Purpose:
  155. * WM_INITIDIALOG handler for the <FULLNAME> dialog box.
  156. *
  157. * Parameters:
  158. * hDlg HWND of the dialog
  159. * wParam WPARAM of the message
  160. * lParam LPARAM of the message
  161. *
  162. * Return Value:
  163. * BOOL Value to return for WM_INITDIALOG.
  164. */
  165. BOOL F<NAME>Init(HWND hDlg, WPARAM wParam, LPARAM lParam)
  166. {
  167. P<STRUCT> p<ABBREV>;
  168. LPOLEUI<STRUCT> lpO<ABBREV>;
  169. HFONT hFont;
  170. //1. Copy the structure at lParam into our instance memory.
  171. p<ABBREV>=(PSTRUCT)PvStandardInit(hDlg, sizeof(<STRUCT>), TRUE, &hFont);
  172. //PvStandardInit send a termination to us already.
  173. if (NULL==p<ABBREV>)
  174. return FALSE;
  175. lpO<ABBREV>=(LPOLEUI<STRUCT>)lParam);
  176. p<ABBREV>->lpO<ABBREV>=lpO<ABBREV>;
  177. //Copy other information from lpO<ABBREV> that we might modify.
  178. <UFILL>
  179. //2. If we got a font, send it to the necessary controls.
  180. if (NULL!=hFont)
  181. {
  182. //Do this for as many controls as you need it for.
  183. SendDlgItemMessage(hDlg, ID_<UFILL>, WM_SETFONT, (WPARAM)hFont, 0L);
  184. }
  185. //3. Show or hide the help button
  186. if (!(p<ABBREV>->lpO<ABBREV>->dwFlags & <ABBREV>F_SHOWHELP))
  187. StandardShowDlgItem(hDlg, ID_OLEUIHELP, SW_HIDE);
  188. /*
  189. * PERFORM OTHER INITIALIZATION HERE. ON ANY LoadString
  190. * FAILURE POST OLEUI_MSG_ENDDIALOG WITH OLEUI_ERR_LOADSTRING.
  191. */
  192. //n. Call the hook with lCustData in lParam
  193. UStandardHook((PVOID)p<ABBREV>, hDlg, WM_INITDIALOG, wParam, lpO<ABBREV>->lCustData);
  194. return TRUE;
  195. }