BOOL CDisplayResolutionPane::OnInitDialog() { CPropertyPage::OnInitDialog(); UInt8 isSelected; CComboBox* pCB = (CComboBox*) GetDlgItem(IDC_COMBO1); VisualGraphics* theVisualGraphics; theVisualGraphics = VisualGraphics::getInstance(); theVisualGraphics->evaluateFullscreenDisplayResolution(); //theVisualGraphics->gatherAvailableDisplayResolutions(); //theVisualGraphics->resetDisplayResolutionIterIndex(); char showStr[32]; UInt16 count = 0; UInt16 selIdx = 0; while(theVisualGraphics->getNextAvailableDisplayResolution(showStr, &isSelected)) { if (isSelected == 1) { selIdx = count; } if (pCB->AddString(showStr) == CB_ERR) { AfxMessageBox("AnError occurred while adding mon res item to combo list."); } count++; } pCB->SetCurSel(selIdx); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX-Eigenschaftenseiten sollten FALSE zurückgeben }
void OptionsDialog::show() { int aLastTabIndex; OSStatus err; VisualGraphics* theVisualGraphics = VisualGraphics::getInstance(); theVisualGraphics->evaluateFullscreenDisplayResolution(); aLastTabIndex = VisualDataStore::getPreferenceValueInt(VisualConfiguration::kPreferencePane); if (aLastTabIndex == 0) { aLastTabIndex = 1; } if (theOptionsDialog->optionsDialogWindow == NULL) { // find the bundle to load the nib inside of it IBNibRef nibRef; CFStringRef pluginName; pluginName = CFStringCreateWithCString(kCFAllocatorDefault, VisualConfiguration::kVisualPluginDomainIdentifier, kCFStringEncodingWindowsLatin1); CFBundleRef thePlugin = CFBundleGetBundleWithIdentifier(pluginName); err = CreateNibReferenceWithCFBundle(thePlugin, CFSTR("VisualOptions"), &nibRef); if (err != noErr) { writeLog("CreateNibReferenceWithCFBundle failed in OptionsDialog->show"); return; } CreateWindowFromNib(nibRef, CFSTR("OptionsDialog"), &(theOptionsDialog->optionsDialogWindow)); if (err != noErr) { writeLog("CreateWindowFromNib failed in OptionsDialog->show"); return; } DisposeNibReference(nibRef); CFRelease(pluginName); // tab control GetControlByID(theOptionsDialog->optionsDialogWindow, &theOptionsDialog->tabControlID, &theOptionsDialog->tabControl); // display resolution menu pop up control err = GetControlByID(theOptionsDialog->optionsDialogWindow, &theOptionsDialog->displayResolutionMenuControlID, &(theOptionsDialog->displayResolutionPopUpControl)); if (err != noErr) { writeLog("GetControlByID failed in OptionsDialog->show"); return; } UInt32 count; MenuAttributes displayResolutionMenuAttributes = (MenuAttributes)NULL; err = CreateNewMenu(131, displayResolutionMenuAttributes, &(theOptionsDialog->displayResolutionMenu)); if (err != noErr) { writeLog("CreateNewMenu failed in OptionsDialog->show"); return; } CFStringRef displayResolutionShowStr; count = 0; char str[32]; UInt8 isSelected = 0; while(theVisualGraphics->getNextAvailableDisplayResolution(str, &isSelected)) { displayResolutionShowStr = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%s"), str); err = AppendMenuItemTextWithCFString(theOptionsDialog->displayResolutionMenu, displayResolutionShowStr, 0, 0, NULL); if (err != noErr) { writeLog("Error while appending menu item"); } count++; if (isSelected == 1) { theOptionsDialog->displayResolutionMenuSelectedIdx = count; } CFRelease(displayResolutionShowStr); } SetControlPopupMenuHandle(theOptionsDialog->displayResolutionPopUpControl, theOptionsDialog->displayResolutionMenu); SetControl32BitMaximum(theOptionsDialog->displayResolutionPopUpControl, count); InstallWindowEventHandler(theOptionsDialog->optionsDialogWindow, NewEventHandlerUPP(optionsDialogWindowHandler), 1, &windowCloseEvent, NULL, NULL); InstallWindowEventHandler(theOptionsDialog->optionsDialogWindow, NewEventHandlerUPP(optionsDialogControlHandler), 1, &controlHitEvent, NULL, NULL); } if (theOptionsDialog->displayResolutionMenuSelectedIdx == -1) { theOptionsDialog->displayResolutionMenuSelectedIdx = 1; // first menuItem is default } SetControl32BitValue(theOptionsDialog->displayResolutionPopUpControl, theOptionsDialog->displayResolutionMenuSelectedIdx); SetControl32BitValue(theOptionsDialog->tabControl, aLastTabIndex); theOptionsDialog->showSelectedPaneOfTabControl(); ShowWindow(theOptionsDialog->optionsDialogWindow); SelectWindow(theOptionsDialog->optionsDialogWindow); }