void ShowOptions(HWND hwndParent) { PROPSHEETHEADER psh = { sizeof(psh) }; PROPSHEETPAGE psp[3] = { { sizeof(psp[0]) }, { sizeof(psp[1]) }, { sizeof(psp[2]) }, }; CoInitialize(0); // configure property sheet psh.dwFlags = PSH_PROPSHEETPAGE; psh.hwndParent = hwndParent; psh.nPages = sizeof(psp) / sizeof(psp[0]); psh.ppsp = psp; psh.pszCaption = _T("Options"); // configure property sheet page(1) psp[0].dwFlags = PSP_USETITLE; psp[0].hInstance = g_hResourceModule;//GetModuleHandle(0); psp[0].pfnDlgProc = FontOptionsDlgProc; psp[0].pszTemplate = MAKEINTRESOURCE(IDD_FONT); psp[0].pszTitle = _T("Font"); // configure property sheet page(2) psp[1].dwFlags = PSP_USETITLE; psp[1].hInstance = g_hResourceModule;//GetModuleHandle(0); psp[1].pfnDlgProc = DisplayOptionsDlgProc; psp[1].pszTemplate = MAKEINTRESOURCE(IDD_DISPLAY); psp[1].pszTitle = _T("Display"); // configure property sheet page(3) psp[2].dwFlags = PSP_USETITLE; psp[2].hInstance = g_hResourceModule;//GetModuleHandle(0); psp[2].pfnDlgProc = MiscOptionsDlgProc; psp[2].pszTemplate = MAKEINTRESOURCE(IDD_OPTIONS); psp[2].pszTitle = _T("Settings"); if(PropertySheet(&psh)) { ApplyRegSettings(); } CoUninitialize(); }
// // Entry-point for text-editor application // int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int iShowCmd) { MSG msg; HACCEL hAccel; TCHAR **argv; int argc; //TCHAR *pszCmdlineFile = 0; TCHAR arg[MAX_PATH]; // // get the first commandline argument // TCHAR *pszCmdline = GetArg(GetCommandLineW(), arg, MAX_PATH); argv = GetArgvCommandLine(&argc); // check if we have any options if(pszCmdline && *pszCmdline == '-') { pszCmdline = GetArg(pszCmdline, arg, MAX_PATH); // do the user-account-control thing if(lstrcmpi(arg, _T("-uac")) == 0) { //return 0; } // image-file-execute-options else if(lstrcmpi(arg, _T("-ifeo")) == 0) { // skip notepad.exe pszCmdline = GetArg(pszCmdline, arg, MAX_PATH); } // unrecognised option else { } } // has a prior instance elevated us to admin in order to // modify some system-wide settings in the registry? if(argv && argc == 4 && lstrcmpi(argv[1], _T("-uac")) == 0) { g_fAddToExplorer = _ttoi(argv[2]); g_fReplaceNotepad = _ttoi(argv[3]); if(SetExplorerContextMenu(g_fAddToExplorer) && SetImageFileExecutionOptions(g_fReplaceNotepad)) { SaveRegSysSettings(); return 0; } else { return ERROR_ACCESS_DENIED; } } // default to the built-in resources g_hResourceModule = hInst; OleInitialize(0); // initialize window classes InitMainWnd(); InitTextView(); LoadRegSettings(); // create the main window! g_hwndMain = CreateMainWnd(); // open file specified on commmand line if(pszCmdline && *pszCmdline) { // check to see if it's a quoted filename if(*pszCmdline == '\"') { GetArg(pszCmdline, arg, MAX_PATH); pszCmdline = arg; } NeatpadOpenFile(g_hwndMain, pszCmdline); LoadFileData(pszCmdline, g_hwndMain); } // automatically create new document if none specified else { PostMessage(g_hwndMain, WM_COMMAND, IDM_FILE_NEW, 0); } ApplyRegSettings(); ShowWindow(g_hwndMain, iShowCmd); // // load keyboard accelerator table // hAccel = LoadAccelerators(g_hResourceModule, MAKEINTRESOURCE(IDR_ACCELERATOR1)); // // message-loop // while(GetMessage(&msg, NULL, 0, 0) > 0) { if(!TranslateAccelerator(g_hwndMain, hAccel, &msg)) { if((!IsWindow(g_hwndSearchDlg) || !IsDialogMessage(g_hwndSearchDlg, &msg))) { TranslateMessage(&msg); DispatchMessage(&msg); } } } if(g_fSaveOnExit) SaveRegSettings(); OleUninitialize(); ExitProcess(0); return 0; }