LRESULT COption::ExtractProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { static CFolderDialog FolderDlg; static SOption* pOption = &m_option_tmp; // Extraction Settings static constexpr std::array<LPCTSTR, 3> ExtractCheckText{{ _T("Extract each folder"), _T("Fix the CRC of OGG files upon extraction"), _T("Enable simple decoding") }}; static const std::array<BOOL*, 4> ExtractCheckFlag{{ &pOption->bCreateFolder, &pOption->bFixOgg, &pOption->bEasyDecrypt, &pOption->bRenameScriptExt }}; static std::array<CCheckBox, ExtractCheckText.size()> ExtractCheck; static CCheckBox ExtractCheckAlpha; static CLabel ExtractLabelPng, ExtractLabelAlpha, ExtractLabelBuf, ExtractLabelTmp; static CRadioBtn ExtractRadioImage, ExtractRadioSave; static CUpDown ExtractUpDownPng; static CEditBox ExtractEditPng, ExtractEditAlpha, ExtractEditSave, ExtractEditBuf, ExtractEditTmp; static CButton ExtractBtnSave, ExtractBtnTmp; static CGroupBox ExtractGroupImage, ExtractGroupSave; switch (msg) { case WM_INITDIALOG: { UINT ID = 10000; const int x = 10; const int xx = 15; int y = 0; // Extraction Settings for (size_t i = 0; i < ExtractCheckText.size(); i++) { ExtractCheck[i].Create(hWnd, ExtractCheckText[i], ID++, x, y += 20, 230, 20); ExtractCheck[i].SetCheck(*ExtractCheckFlag[i]); } // int y_image = y; ExtractGroupImage.Create(hWnd, _T("Output image format"), ID++, x, y_image += 34, 240, 110); ExtractRadioImage.Close(); ExtractRadioImage.Create(hWnd, _T("BMP"), ID++, x + xx, y_image += 18, 50, 20); ExtractRadioImage.Create(hWnd, _T("PNG"), ID++, x + xx, y_image += 20, 50, 20); ExtractRadioImage.SetCheck(0, pOption->bDstBMP); ExtractRadioImage.SetCheck(1, pOption->bDstPNG); ExtractLabelPng.Create(hWnd, _T("Compression Level"), ID++, x + xx + 50, y_image + 3, 100, 20); ExtractEditPng.Create(hWnd, _T(""), ID++, x + xx + 150, y_image, 40, 22); ExtractEditPng.SetLimit(1); ExtractUpDownPng.Create(hWnd, ExtractEditPng.GetCtrlHandle(), pOption->CmplvPng, ID++, 9, 0); // ExtractCheckAlpha.Create(hWnd, _T("Enable alpha blending"), ID++, x + xx, y_image += 22, 140, 20); ExtractCheckAlpha.SetCheck(pOption->bAlphaBlend); ExtractLabelAlpha.Create(hWnd, _T("Background color"), ID++, x + xx * 2 + 4, y_image += 24, 100, 20); ExtractEditAlpha.Create(hWnd, pOption->szBgRGB, ID++, x + xx * 2 + 100, y_image - 4, 100, 22); ExtractEditAlpha.SetLimit(6); ExtractEditAlpha.Enable(pOption->bAlphaBlend); // const int x_save = x + 200; int y_save = y; ExtractGroupSave.Create(hWnd, _T("Destination"), ID++, x_save + 50, y_save += 34, 290, 110); ExtractRadioSave.Close(); ExtractRadioSave.Create(hWnd, _T("Specify each time"), ID++, x_save + xx + 50, y_save += 18, 220, 20); ExtractRadioSave.Create(hWnd, _T("Same folder as input source"), ID++, x_save + xx + 50, y_save += 20, 200, 20); ExtractRadioSave.Create(hWnd, _T("The following folder"), ID++, x_save + xx + 50, y_save += 20, 200, 20); ExtractRadioSave.SetCheck(0, pOption->bSaveSel); ExtractRadioSave.SetCheck(1, pOption->bSaveSrc); ExtractRadioSave.SetCheck(2, pOption->bSaveDir); ExtractEditSave.Create(hWnd, pOption->SaveDir, ID++, x_save + xx * 2 + 40, y_save += 20, 200, 22); ExtractEditSave.Enable(pOption->bSaveDir); ExtractBtnSave.Create(hWnd, _T("Browse"), ID++, x_save + xx * 2 + 250, y_save + 1, 50, 20); ExtractBtnSave.Enable(pOption->bSaveDir); // y = (y_image > y_save) ? y_image : y_save; ExtractLabelBuf.Create(hWnd, _T("Buffer Size(KB)"), ID++, x, y += 44, 100, 20); ExtractEditBuf.Create(hWnd, pOption->BufSize, ID++, x + 100, y - 4, 110, 22); // ExtractLabelTmp.Create(hWnd, _T("Temporary Folder"), ID++, x, y += 24, 100, 20); ExtractEditTmp.Create(hWnd, pOption->TmpDir, ID++, x + 100, y - 4, 200, 22); ExtractBtnTmp.Create(hWnd, _T("Browse"), ID++, x + 310, y - 3, 50, 20); break; } case WM_COMMAND: // Checkbox if (LOWORD(wp) >= ExtractCheck.front().GetID() && LOWORD(wp) <= ExtractCheck.back().GetID()) { PropSheet_Changed(::GetParent(hWnd), hWnd); break; } // Alpha blend check box if (LOWORD(wp) == ExtractCheckAlpha.GetID()) { ExtractEditAlpha.Enable(ExtractCheckAlpha.GetCheck()); PropSheet_Changed(::GetParent(hWnd), hWnd); break; } //Output image format radio button if (LOWORD(wp) >= ExtractRadioImage.GetID(0) && LOWORD(wp) <= ExtractRadioImage.GetID(1)) { PropSheet_Changed(::GetParent(hWnd), hWnd); break; } // Destination radio button if (LOWORD(wp) >= ExtractRadioSave.GetID(0) && LOWORD(wp) <= ExtractRadioSave.GetID(2)) { ExtractEditSave.Enable(ExtractRadioSave.GetCheck(2)); ExtractBtnSave.Enable(ExtractRadioSave.GetCheck(2)); PropSheet_Changed(::GetParent(hWnd), hWnd); break; } // Output folder browse if (LOWORD(wp) == ExtractBtnSave.GetID()) { TCHAR szSaveDir[_MAX_DIR]; ExtractEditSave.GetText(szSaveDir, sizeof(szSaveDir)); if (FolderDlg.DoModal(hWnd, _T("Select the output folder"), szSaveDir)) ExtractEditSave.SetText(szSaveDir); break; } // Temporary folder browse if (LOWORD(wp) == ExtractBtnTmp.GetID()) { TCHAR szTmpDir[_MAX_DIR]; ExtractEditTmp.GetText(szTmpDir, sizeof(szTmpDir)); if (FolderDlg.DoModal(hWnd, _T("Select a temporary folder"), szTmpDir)) ExtractEditTmp.SetText(szTmpDir); break; } // Contents of the edit box have been changed if (HIWORD(wp) == EN_CHANGE) { PropSheet_Changed(::GetParent(hWnd), hWnd); break; } break; case WM_NOTIFY: { const auto* const hdr = reinterpret_cast<LPNMHDR>(lp); switch (hdr->code) { // OK/Apply, Tabbing case PSN_APPLY: case PSN_KILLACTIVE: // Extraction Settings for (size_t i = 0; i < ExtractCheck.size(); i++) *ExtractCheckFlag[i] = ExtractCheck[i].GetCheck(); // pOption->bDstBMP = ExtractRadioImage.GetCheck(0); pOption->bDstPNG = ExtractRadioImage.GetCheck(1); ExtractEditPng.GetText(&pOption->CmplvPng, FALSE); // pOption->bAlphaBlend = ExtractCheckAlpha.GetCheck(); ExtractEditAlpha.GetText(&pOption->BgRGB, TRUE); _stprintf(pOption->szBgRGB, _T("%06x"), pOption->BgRGB); // pOption->bSaveSel = ExtractRadioSave.GetCheck(0); pOption->bSaveSrc = ExtractRadioSave.GetCheck(1); pOption->bSaveDir = ExtractRadioSave.GetCheck(2); ExtractEditSave.GetText(pOption->SaveDir); // ExtractEditBuf.GetText(&pOption->BufSize, FALSE); // ExtractEditTmp.GetText(pOption->TmpDir); // OK/Apply if (hdr->code == PSN_APPLY) Apply(); return TRUE; } break; } } return FALSE; }
BOOL CBaseDlg::OnInitDialog() { //CDialog::OnInitDialog(); if (m_hIcon) { SetIcon(m_hIcon, TRUE); // 设置大图标 SetIcon(m_hIcon, FALSE); // 设置小图标 } m_bInit = TRUE; for (int i = 0; i < m_vecCtrl.size(); i++) { switch (m_vecCtrl[i].type) { case BASE_BUTTON: case BASE_CHECK_BUTTON: { CButton* pCtrl = (CButton*)m_vecCtrl[i].pCtrl; pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID); pCtrl->SetFont(&mFont); break; } case BASE_COMMOM_BUTTON: { CCommonButton* pCtrl = (CCommonButton*)m_vecCtrl[i].pCtrl; pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID); pCtrl->SetFont(&mFont); break; } case BASE_STATIC: { CStatic* pCtrl = (CStatic*)m_vecCtrl[i].pCtrl; pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID); pCtrl->SetFont(&mFont); break; } case BASE_MY_CHECK_BUTTON: { CMyCheckButton* pCtrl = (CMyCheckButton*)m_vecCtrl[i].pCtrl; pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID); pCtrl->SetFont(&mFont); break; } case BASE_INDICATOR: { CIndicator* pCtrl = (CIndicator*)m_vecCtrl[i].pCtrl; pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID); pCtrl->SetFont(&mFont); break; } case BASE_GROUPBOX: { CGroupBox* pCtrl = (CGroupBox*)m_vecCtrl[i].pCtrl; pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID); pCtrl->SetFont(&mFont); break; } case BASE_EDIT_CSTRING: case BASE_EDIT_DOUBLE: { CEdit* pCtrl = (CEdit*)m_vecCtrl[i].pCtrl; pCtrl->Create(m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID); pCtrl->SetFont(&mFont); break; } case BASE_COLOR_TEXT: { CColorText* pCtrl = (CColorText*)m_vecCtrl[i].pCtrl; pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID); break; } case BASE_DRAWVIEW: { CDrawView* pCtrl = (CDrawView*)m_vecCtrl[i].pCtrl; pCtrl->Create(m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID); break; } case BASE_LIST: { CListCtrl* pCtrl = (CListCtrl*)m_vecCtrl[i].pCtrl; pCtrl->Create(m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID); break; } case BASE_TABVIEW: { CTabViewCtrl* pCtrl = (CTabViewCtrl*)m_vecCtrl[i].pCtrl; pCtrl->Create(m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID); break; } case BASE_GRADIENT_BACKGROUND: { CGradientBackground* pCtrl = (CGradientBackground*)m_vecCtrl[i].pCtrl; pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID); break; } case BASE_COMBOBOX: { CComboBox* pCtrl = (CComboBox*)m_vecCtrl[i].pCtrl; pCtrl->Create(m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID); pCtrl->SetFont(&mFont); CString caption = m_vecCtrl[i].sCaption; for (int j = 0; j < m_vecCtrl[i].nDataCount; j++) { int endpos = caption.Find(L"\n"); CString item = caption.Mid(0, endpos); pCtrl->AddString(item); caption = caption.Right(caption.GetLength()-endpos-1); } pCtrl->SetCurSel(0); break; } case BASE_PROGRESS: { CProgressCtrl* pCtrl = (CProgressCtrl*)m_vecCtrl[i].pCtrl; pCtrl->Create(m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID); if (m_vecCtrl[i].pInOutData != NULL) { pCtrl->SetRange32((int)m_vecCtrl[i].dMinVal,(int)m_vecCtrl[i].dMaxVal); } break; } case BASE_SLIDER: { CSliderCtrl* pCtrl = (CSliderCtrl*)m_vecCtrl[i].pCtrl; pCtrl->Create(m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID); if (m_vecCtrl[i].pInOutData != NULL) { pCtrl->SetRangeMax((int)m_vecCtrl[i].dMaxVal); pCtrl->SetRangeMin((int)m_vecCtrl[i].dMinVal); } break; } case BASE_SLIDER_GROUP: { CSliderGroup* pCtrl = (CSliderGroup*)m_vecCtrl[i].pCtrl; pCtrl->Create(m_vecCtrl[i].sCaption, m_vecCtrl[i].dwStyle, m_vecCtrl[i].rect, m_vecCtrl[i].pParent, m_vecCtrl[i].nID); if (m_vecCtrl[i].pInOutData!=NULL) { pCtrl->GetSlider()->SetRangeMax((int)m_vecCtrl[i].dMaxVal); pCtrl->GetSlider()->SetRangeMin((int)m_vecCtrl[i].dMinVal); } break; } default: break; } } UpdateData(FALSE); return TRUE; }
LRESULT COption::StdProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { static SOption* pOption = &m_option_tmp; // Listview settings static CGroupBox ListGroup; static CLabel ListLabelBk, ListLabelText; static CEditBox ListEditBk, ListEditText; // Search settings static std::array<CCheckBox, search_files_labels.size()> SearchCheck; static const size_t SearchCheckNum = search_files_labels.size(); static std::array<CButton, 2> SearchBtn; static CGroupBox SearchGroup; // Search accuracy static CGroupBox HighSearchGroup; static CCheckBox HighSearchCheckOgg; switch (msg) { case WM_INITDIALOG: { CWindowBase::Init(::GetParent(hWnd)); UINT ID = 10000; const int x = 10; const int xx = 15; int y = 0; // Listview settings ListGroup.Create(hWnd, _T("List Settings"), ID++, x, y += 20, 510, 75); ListLabelBk.Create(hWnd, _T("Background Color"), ID++, x + xx, y += 24, 100, 20); ListEditBk.Create(hWnd, pOption->szListBkColor, ID++, x + xx + 100, y - 4, 70, 22); ListEditBk.SetLimit(6); ListLabelText.Create(hWnd, _T("Text Color"), ID++, x + xx, y += 24, 100, 20); ListEditText.Create(hWnd, pOption->szListTextColor, ID++, x + xx + 100, y - 4, 70, 22); ListEditText.SetLimit(6); // Search Settings SearchGroup.Create(hWnd, _T("Files to be searched"), ID++, x, y += 40, 510, 100); //y += 20; for (size_t i = 0, xxx = 0; i < SearchCheckNum; i++, xxx += 55) { if ((i % 8) == 0) { xxx = 0, y += 20; } SearchCheck[i].Create(hWnd, search_files_labels[i], ID++, x + xx + static_cast<int>(xxx), y, 50, 20); SearchCheck[i].SetCheck(pOption->bSearch[i]); } SearchBtn[0].Create(hWnd, _T("Select all"), ID++, 350, y += 30, 80, 20); SearchBtn[1].Create(hWnd, _T("Deselect all"), ID++, 430, y, 80, 20); // Search Accuracy Settings HighSearchGroup.Create(hWnd, _T("Search Accuracy"), ID++, x, y += 40, 510, 50); HighSearchCheckOgg.Create(hWnd, _T("Increase the accuracy of OGG searches"), ID++, x + xx, y += 20, 220, 20); HighSearchCheckOgg.SetCheck(pOption->bHighSearchOgg); break; } case WM_COMMAND: // Check the file search box if (LOWORD(wp) >= SearchCheck[0].GetID() && LOWORD(wp) <= SearchCheck[SearchCheckNum-1].GetID()) { const int number = LOWORD(wp) - SearchCheck[0].GetID(); pOption->bSearch[number] ^= 1; SearchCheck[number].SetCheck(pOption->bSearch[number]); PropSheet_Changed(::GetParent(hWnd), hWnd); break; } // Select all if (LOWORD(wp) == SearchBtn[0].GetID()) { for (size_t i = 0; i < SearchCheckNum; i++) { pOption->bSearch[i] = TRUE; SearchCheck[i].SetCheck(pOption->bSearch[i]); } PropSheet_Changed(::GetParent(hWnd), hWnd); break; } // Deselect if (LOWORD(wp) == SearchBtn[1].GetID()) { for (size_t i = 0; i < SearchCheckNum; i++) { pOption->bSearch[i] = FALSE; SearchCheck[i].SetCheck(pOption->bSearch[i]); } PropSheet_Changed(::GetParent(hWnd), hWnd); break; } if (LOWORD(wp) == HighSearchCheckOgg.GetID()) { PropSheet_Changed(::GetParent(hWnd), hWnd); break; } // The contents of the editbox have been changed if (HIWORD(wp) == EN_CHANGE) { PropSheet_Changed(::GetParent(hWnd), hWnd); break; } break; case WM_NOTIFY: { const auto* const hdr = reinterpret_cast<LPNMHDR>(lp); switch (hdr->code) { // Apply/OK, Tabbing case PSN_APPLY: case PSN_KILLACTIVE: ListEditBk.GetText(&pOption->ListBkColor, TRUE); _stprintf(pOption->szListBkColor, _T("%06x"), pOption->ListBkColor); ListEditText.GetText(&pOption->ListTextColor, TRUE); _stprintf(pOption->szListTextColor, _T("%06x"), pOption->ListTextColor); pOption->bHighSearchOgg = HighSearchCheckOgg.GetCheck(); // OK/Apply if (hdr->code == PSN_APPLY) Apply(); return TRUE; } break; } } return FALSE; }