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