bool ChkdStringInputDialog::InternalGetChkdString(ChkdString &str, const ChkdString &initialString, HWND hParent) { gotChkdString = false; this->initialString = initialString; newString = ""; CreateDialogBox(MAKEINTRESOURCE(IDD_INPUTCHKDSTR), hParent); if ( gotChkdString ) str = newString; return gotChkdString; }
/* Show "associate this application with PDF files" dialog. Returns IDYES if "Yes" button was pressed or IDNO if "No" button was pressed. Returns the state of "don't ask me again" checkbox" in <dontAskAgain> */ INT_PTR Dialog_PdfAssociate(HWND hwnd, bool *dontAskAgainOut) { assert(dontAskAgainOut); Dialog_PdfAssociate_Data data; INT_PTR res = CreateDialogBox(IDD_DIALOG_PDF_ASSOCIATE, hwnd, Dialog_PdfAssociate_Proc, (LPARAM)&data); if (dontAskAgainOut) *dontAskAgainOut = data.dontAskAgain; return res; }
/* Returns NULL -1 if user choses 'cancel' */ const char *Dialog_ChangeLanguge(HWND hwnd, const char *currLangCode) { Dialog_ChangeLanguage_Data data; data.langCode = currLangCode; INT_PTR res = CreateDialogBox(IDD_DIALOG_CHANGE_LANGUAGE, hwnd, Dialog_ChangeLanguage_Proc, (LPARAM)&data); if (IDCANCEL == res) return NULL; return data.langCode; }
/* Shows a 'go to page' dialog and returns the page label entered by the user or NULL if user clicked the "cancel" button or there was an error. The caller must free() the result. */ WCHAR *Dialog_GoToPage(HWND hwnd, const WCHAR *currentPageLabel, int pageCount, bool onlyNumeric) { Dialog_GoToPage_Data data; data.currPageLabel = currentPageLabel; data.pageCount = pageCount; data.onlyNumeric = onlyNumeric; data.newPageLabel = NULL; CreateDialogBox(IDD_DIALOG_GOTO_PAGE, hwnd, Dialog_GoToPage_Proc, (LPARAM)&data); return data.newPageLabel; }
bool Dialog_CustomZoom(HWND hwnd, bool forChm, float *currZoomInOut) { Dialog_CustomZoom_Data data; data.forChm = forChm; data.zoomArg = *currZoomInOut; INT_PTR res = CreateDialogBox(IDD_DIALOG_CUSTOM_ZOOM, hwnd, Dialog_CustomZoom_Proc, (LPARAM)&data); if (res == IDCANCEL) return false; *currZoomInOut = data.zoomResult; return true; }
bool CuwpInputDialog::InternalGetCuwp(ChkCuwp &cuwp, const ChkCuwp &initialCuwp, HWND hParent) { gotCuwp = false; ClearStoredCuwps(); this->initialCuwp = initialCuwp; CreateDialogBox(MAKEINTRESOURCE(IDD_EDITCUWP), hParent); if ( gotCuwp ) cuwp = newCuwp; return gotCuwp; }
INT_PTR Dialog_NewVersionAvailable(HWND hwnd, const WCHAR *currentVersion, const WCHAR *newVersion, bool *skipThisVersion) { Dialog_NewVersion_Data data; data.currVersion = currentVersion; data.newVersion = newVersion; data.skipThisVersion = false; INT_PTR res = CreateDialogBox(IDD_DIALOG_NEW_VERSION, hwnd, Dialog_NewVersion_Proc, (LPARAM)&data); if (skipThisVersion) *skipThisVersion = data.skipThisVersion; return res; }
/* Shows a 'get password' dialog for a given file. Returns a password entered by user as a newly allocated string or NULL if user cancelled the dialog or there was an error. Caller needs to free() the result. */ WCHAR *Dialog_GetPassword(HWND hwndParent, const WCHAR *fileName, bool *rememberPassword) { Dialog_GetPassword_Data data = { 0 }; data.fileName = fileName; data.remember = rememberPassword; INT_PTR res = CreateDialogBox(IDD_DIALOG_GET_PASSWORD, hwndParent, Dialog_GetPassword_Proc, (LPARAM)&data); if (IDOK != res) { free(data.pwdOut); return NULL; } return data.pwdOut; }
/* Shows a 'Find' dialog and returns the new search term entered by the user or NULL if the search was canceled. previousSearch is the search term to be displayed as default. */ WCHAR * Dialog_Find(HWND hwnd, const WCHAR *previousSearch, bool *matchCase) { Dialog_Find_Data data; data.searchTerm = (WCHAR *)previousSearch; data.matchCase = matchCase ? *matchCase : false; INT_PTR res = CreateDialogBox(IDD_DIALOG_FIND, hwnd, Dialog_Find_Proc, (LPARAM)&data); if (res != IDOK) return NULL; if (matchCase) *matchCase = data.matchCase; return data.searchTerm; }
// pageNo is the page we're adding to favorites // returns true if the user wants to add a favorite. // favName is the name the user wants the favorite to have // (passing in a non-NULL favName will use it as default name) bool Dialog_AddFavorite(HWND hwnd, const WCHAR *pageNo, ScopedMem<WCHAR>& favName) { Dialog_AddFav_Data data; data.pageNo = pageNo; data.favName = favName; INT_PTR res = CreateDialogBox(IDD_DIALOG_FAV_ADD, hwnd, Dialog_AddFav_Proc, (LPARAM)&data); if (IDCANCEL == res) { assert(data.favName == favName); return false; } assert(data.favName != favName || !data.favName); favName.Set(data.favName); return true; }
INT_PTR Dialog_Settings(HWND hwnd, GlobalPrefs *prefs) { return CreateDialogBox(IDD_DIALOG_SETTINGS, hwnd, Dialog_Settings_Proc, (LPARAM)prefs); }
LRESULT CALLBACK WndProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam) { HDC ContextHandle; PAINTSTRUCT PaintStructure; RECT ClientRectangle; LPCWSTR MyText = L"Done with Pride and Prejudice by Danny!"; int cxClient, cyClient; switch (Msg) { //////////////////////////////////// case WM_SIZE: cxClient = LOWORD(lParam); cyClient = HIWORD(lParam); break; //////////////////////////////////// case WM_CREATE: { RegisterDialogClass(hwnd); HMENU menu = GetSystemMenu(hwnd, TRUE); LPCWSTR button01_ID = L"BUTTON"; LPCWSTR button01_text = L"FONT"; HWND button01 = CreateWindowEx(WS_EX_WINDOWEDGE, button01_ID, button01_text, BS_DEFPUSHBUTTON | WS_VISIBLE | WS_BORDER | WS_CHILD, 5, 5, 105, 25, hwnd, (HMENU)BUTTON_01, NULL, NULL); LPCWSTR button02_ID = L"BUTTON"; LPCWSTR button02_text = L"DIALOG BOX"; HWND button02 = CreateWindowEx(NULL, button02_ID, button02_text, BS_DEFPUSHBUTTON | WS_VISIBLE | WS_BORDER | WS_CHILD, 5, 35, 105, 25, hwnd, (HMENU)BUTTON_02, NULL, NULL); hWndSizeBox = CreateWindowEx(NULL, TEXT("Scrollbar"), 0, WS_CHILD | WSF_VISIBLE | WS_VISIBLE | SBS_SIZEBOXTOPLEFTALIGN, 50, 100, 0, NULL, hwnd, (HMENU)NULL, NULL, NULL); } break; ////////////////////////////////// case WM_PAINT: ContextHandle = BeginPaint(hwnd, &PaintStructure); GetClientRect(hwnd, &ClientRectangle); /*DrawText(ContextHandle, MyText, -1, &ClientRectangle, DT_SINGLELINE | DT_CENTER | DT_VCENTER);*/ EndPaint(hwnd, &PaintStructure); return 0; ////////////////////////////////// case WM_COMMAND: { switch (LOWORD(wParam)) { case BUTTON_01: { HFONT Font = CreateFont(20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TEXT("Times New Roman")); SendMessage(TextBox, WM_SETFONT, (WPARAM)Font, TRUE); break; } case BUTTON_02: { CreateDialogBox(hwnd); break; } } } break; ////////////////////////////// case WM_KEYDOWN: // keyboard input { switch (wParam) { case KEY_C: { // LeftSHIFT + E if (GetAsyncKeyState(VK_LSHIFT)) { if (MessageBox(hwnd, L"Do you want to exit?", L"Exit", MB_OKCANCEL) == IDOK) DestroyWindow(hwnd); } break; } case KEY_SPACE: if (GetAsyncKeyState(VK_LCONTROL)) { HBRUSH brush = CreateSolidBrush(RGB(100, 23, 31)); SetClassLongPtr(hwnd, GCLP_HBRBACKGROUND, (LONG)brush); RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME); MessageBox(NULL, L"Background color changed", L"ATENTION", NULL); } break; } } ///////////////////////////// case WM_SYSCOMMAND: switch (LOWORD(wParam)) { case IDM_SYS_CHANGE: { HBRUSH brush1 = (HBRUSH)GetStockObject(WHITE_BRUSH); SetClassLongPtr(hwnd, GCLP_HBRBACKGROUND, (LONG)brush1); RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME); break; } case IDM_SYS_ABOUT: { MessageBox(NULL, L"Done by FaF sTudent!", L"ATENTION", NULL); } return 0; case IDM_SYS_HELP: { TextBox = CreateWindowEx((DWORD)NULL, TEXT("EDIT"), TEXT("DEFAULT FONT"), WS_VISIBLE | WS_CHILD | WS_BORDER | ES_AUTOHSCROLL | DT_VCENTER, 5, 65, 200, 25, hwnd, (HMENU)NULL, NULL, NULL); RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME); break; } } break; ///////////////////////////// case WM_CLOSE: { if (MessageBox(hwnd, L"Do you want to exit?", L"Exit", MB_OKCANCEL) == IDOK) DestroyWindow(hwnd); } break; ///////////////////////////// case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, Msg, wParam, lParam); }