/* * TEMPLATE.C * * Copyright (c)1992 Microsoft Corporation, All Right Reserved * * * CUSTOMIZATION INSTRUCTIONS: * * 1. Replace with the uppercased filename for this file. * Lowercase the .h entry * * 2. Replace with the mixed case dialog name in one word, * such as InsertObject * * 3. Replace with the mixed case dialog name in multiple * words, such as Insert Object * * 4. Replace with the suffix for pointer variables, such * as the IO in InsertObject's pIO or the CI in ChangeIcon's pCI. * Check the alignment of the first variable declaration in the * Dialog Proc after this. I will probably be misaligned with the * rest of the variables. * * 5. Replace with the uppercase structure name for this * dialog sans OLEUI, such as INSERTOBJECT. Changes OLEUI * in most cases, but we also use this for IDD_ as the * standard template resource ID. * * 6. Find fields and fill them out with whatever is appropriate. * * 7. Delete this header up to the start of the next comment. */ /* * .C * * Implements the OleUI function which invokes the complete * dialog. * * Copyright (c)1992 Microsoft Corporation, All Right Reserved */ #define STRICT 1 #include "ole2ui.h" #include "common.h" #ifndef WIN32 #include ".h" #else #include "template.h" #endif /* * OleUI * * Purpose: * Invokes the standard OLE dialog box allowing the user * to * * Parameters: * lp LPOLEUI pointing to the in-out structure * for this dialog. * * Return Value: * UINT One of the following codes, indicating success or error: * OLEUI_SUCCESS Success * OLEUI_ERR_STRUCTSIZE The dwStructSize value is wrong */ STDAPI_(UINT) OleUI(LPOLEUI lp) { UINT uRet; HGLOBAL hMemDlg=NULL; uRet=UStandardValidation((LPOLEUISTANDARD)lp, sizeof(OLEUI) , &hMemDlg); if (OLEUI_SUCCESS!=uRet) return uRet; /* * PERFORM ANY STRUCTURE-SPECIFIC VALIDATION HERE! * ON FAILURE: * { * if (NULL!=hMemDlg) * FreeResource(hMemDlg) * * return OLEUI_ERR_ * } */ //Now that we've validated everything, we can invoke the dialog. uRet=UStandardInvocation(DialogProc, (LPOLEUISTANDARD)lp , hMemDlg, MAKEINTRESOURCE(IDD_)); /* * IF YOU ARE CREATING ANYTHING BASED ON THE RESULTS, DO IT HERE. */ return uRet; } /* * DialogProc * * Purpose: * Implements the OLE dialog as invoked through the * OleUI function. * * Parameters: * Standard * * Return Value: * Standard */ BOOL CALLBACK EXPORT DialogProc(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam) { P p; BOOL fHook=FALSE; //Declare Win16/Win32 compatible WM_COMMAND parameters. COMMANDPARAMS(wID, wCode, hWndMsg); //This will fail under WM_INITDIALOG, where we allocate it. p=()PvStandardEntry(hDlg, iMsg, wParam, lParam, &uHook); //If the hook processed the message, we're done. if (0!=uHook) return (BOOL)uHook; //Process the temination message if (iMsg==uMsgEndDialog) { //Free any specific allocations before calling StandardCleanup StandardCleanup((PVOID)p, hDlg); EndDialog(hDlg, wParam); return TRUE; } switch (iMsg) { case WM_INITDIALOG: FInit(hDlg, wParam, lParam); return TRUE; case WM_COMMAND: switch (wID) { case IDOK: /* * PERFORM WHATEVER FUNCTIONS ARE DEFAULT HERE. */ SendMessage(hDlg, uMsgEndDialog, OLEUI_OK, 0L); break; case IDCANCEL: /* * PERFORM ANY UNDOs HERE, BUT NOT CLEANUP THAT WILL * ALWAYS HAPPEN WHICH SHOULD BE IN uMsgEndDialog. */ SendMessage(hDlg, uMsgEndDialog, OLEUI_CANCEL, 0L); break; case ID_OLEUIHELP: PostMessage(p->lpO->hWndOwner, uMsgHelp , (WPARAM)hDlg, MAKELPARAM(IDD_, 0)); break; } break; } return FALSE; } /* * FInit * * Purpose: * WM_INITIDIALOG handler for the dialog box. * * Parameters: * hDlg HWND of the dialog * wParam WPARAM of the message * lParam LPARAM of the message * * Return Value: * BOOL Value to return for WM_INITDIALOG. */ BOOL FInit(HWND hDlg, WPARAM wParam, LPARAM lParam) { P p; LPOLEUI lpO; HFONT hFont; //1. Copy the structure at lParam into our instance memory. p=(PSTRUCT)PvStandardInit(hDlg, sizeof(), TRUE, &hFont); //PvStandardInit send a termination to us already. if (NULL==p) return FALSE; lpO=(LPOLEUI)lParam); p->lpO=lpO; //Copy other information from lpO that we might modify. //2. If we got a font, send it to the necessary controls. if (NULL!=hFont) { //Do this for as many controls as you need it for. SendDlgItemMessage(hDlg, ID_, WM_SETFONT, (WPARAM)hFont, 0L); } //3. Show or hide the help button if (!(p->lpO->dwFlags & F_SHOWHELP)) StandardShowDlgItem(hDlg, ID_OLEUIHELP, SW_HIDE); /* * PERFORM OTHER INITIALIZATION HERE. ON ANY LoadString * FAILURE POST OLEUI_MSG_ENDDIALOG WITH OLEUI_ERR_LOADSTRING. */ //n. Call the hook with lCustData in lParam UStandardHook((PVOID)p, hDlg, WM_INITDIALOG, wParam, lpO->lCustData); return TRUE; }