BOOL CMatrix428Dlg::OnInitDialog() { CBCGPDialog::OnInitDialog(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here CRect dlgRect; dlgRect.left = 0; dlgRect.top= 0; dlgRect.right = 800; dlgRect.bottom = 76; CWnd::SetWindowPos(NULL,0,0,dlgRect.Width(),dlgRect.Height(), SWP_NOZORDER); // 设置控件的位置和尺寸 CWnd *pWnd; pWnd = GetDlgItem( IDC_BUTTON_MINMIZEBOX ); // 获取控件指针,IDC_BUTTON_MINMIZEBOX为控件ID号 pWnd->MoveWindow( CRect(2,2,32,32) ); // 在窗口左上角显示一个宽32、高32的按钮控件 pWnd = GetDlgItem( IDC_BUTTON_CLOSEBOX ); pWnd->MoveWindow( CRect(36,2,68,32) ); // 两个按钮之间间距为2 pWnd = GetDlgItem( IDC_STATIC_E428 ); pWnd->MoveWindow( CRect(2,36,68,68) ); // 设置静态控件位置 GetCurrentDirectory(500, CurrentPath); // 获取当前路径 LoadToolBar(); return TRUE; // return TRUE unless you set the focus to a control }
int MFCArrangerToolBar::OnCreate(LPCREATESTRUCT lpcs) { LoadToolBar(IDR_ARRANGER_TOOL); return CToolBar::OnCreate(lpcs); }
int CTitleBar::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CToolBar::OnCreate(lpCreateStruct) == -1) return -1; // Load Toolbar if (!LoadToolBar(IDR_TITLEBAR)) return -1; CClientDC dc(this); int nHeight=-((dc.GetDeviceCaps(LOGPIXELSY)*8)/72); // Create an 8 point sans serief font for the combo boxes m_font.CreateFont(nHeight,0,0,0,FW_NORMAL,0,0,0,DEFAULT_CHARSET,OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH | FF_DONTCARE, _T( "MS Sans Serif" )); CFont* pOldFont =dc.SelectObject(&m_font); TEXTMETRIC tm; dc.GetTextMetrics(&tm); int cxChar = tm.tmAveCharWidth; int cyChar = tm.tmHeight + tm.tmExternalLeading; dc.SelectObject(pOldFont); // Add "Artist" field to toolbar SetButtonInfo(0,IDC_TBARTIST,TBBS_SEPARATOR,cxChar*16); CRect rcClient; GetItemRect(0,&rcClient); rcClient.bottom=rcClient.top+ (cyChar*16); if (!m_Artist.Create( _T( "Artist" ),WS_CHILD|WS_VISIBLE,rcClient,this,IDC_TBARTIST)) return -1; // Add "Artist" field to toolbar SetButtonInfo(2,IDC_TBARTISTE,TBBS_SEPARATOR,cxChar*80); rcClient; GetItemRect(2,&rcClient); rcClient.bottom=rcClient.top+ (cyChar*16); if (!m_ArtistE.Create(WS_CHILD|WS_VISIBLE,rcClient,this,IDC_TBARTISTE)) return -1; return 0; }
int MFCQuaTransportBar::OnCreate(LPCREATESTRUCT lpcs) { TBBUTTONINFO tbinfo; tbinfo.cbSize = sizeof(TBBUTTONINFO); tbinfo.dwMask = TBIF_SIZE; LoadToolBar(IDR_QUAMFCTYPE); int gotit = CToolBar::OnCreate(lpcs); for (int index=0; index<GetCount(); index++) { int id = GetItemID(index); CRect rect; CRect tr; GetItemRect(index, &rect); COLORREF bgc = GetSysColor(COLOR_MENUBAR); if (id == ID_TRANSPORT_PLAYTIME) { SetButtonInfo(index, ID_TRANSPORT_PLAYTIME, TBBS_SEPARATOR, TIME_DISPLAY_WIDTH+20); rect.top = 1; rect.left +=5; rect.right = rect.left+TIME_DISPLAY_WIDTH; rect.bottom = 22; tr = CRect(3, 5, 3+TIME_DISPLAY_WIDTH, 5+TIME_DISPLAY_HEIGHT); pleitym.CreateTimeCtrl(rect, this, ID_TRANSPORT_PLAYTIME, &displayFont, &tr, &bgc, &rgb_black, &rgb_red); pleitym.SetVCMsgParams(QM_CTL_CHANGED, QCID_TB_TIME, (WPARAM)&pleitym); } else if (id == ID_TRANSPORT_TEMPO) { rect.top = 1; SetButtonInfo(index, ID_TRANSPORT_TEMPO, TBBS_SEPARATOR, TEMPO_DISPLAY_WIDTH+10); rect.right = rect.left+TEMPO_DISPLAY_WIDTH+2; rect.bottom = 22; tr = CRect(3+26, 5, 3+TEMPO_DISPLAY_WIDTH, 5+TEMPO_DISPLAY_HEIGHT); tempeh.CreateFloatCtrl(rect, this, ID_TRANSPORT_PLAYTIME, &displayFont, &tr, &bgc, &rgb_black, &rgb_red); tempeh.SetVCMsgParams(QM_CTL_CHANGED, QCID_TB_TEMPO, (WPARAM)&tempeh); // tempeh.SetLabel("BPM", &labelFont); tempeh.SetRange(1, 120, 2001); tempeh.SetSteps(1,0.1f,0.01f); tempeh.SetValue(1029.2345f); } } return gotit; }
BOOL CDeviceBar::Create(CWnd *pWnd) { if (!CreateEx(pWnd, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !LoadToolBar(IDR_DEVICEBAR)) { TRACE0("Failed to create toolbar\n"); return FALSE; // fail to create } CRect rect; int nIndex; nIndex = GetToolBarCtrl().CommandToIndex(ID_DEVICE_TYPE); SetButtonInfo(nIndex, ID_DEVICE_TYPE, TBBS_SEPARATOR, 205); GetToolBarCtrl().GetItemRect(nIndex, &rect); rect.top = 1; rect.bottom = rect.top + 250; if (!m_DeviceType.Create(CBS_DROPDOWNLIST | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL, rect, this, ID_DEVICE_TYPE)) { TRACE("Failed to create combo-box\n"); return FALSE; } nIndex = GetToolBarCtrl().CommandToIndex(ID_DEVICE_SUBTYPE); SetButtonInfo(nIndex, ID_DEVICE_SUBTYPE, TBBS_SEPARATOR, 205); GetToolBarCtrl().GetItemRect(nIndex,&rect); rect.top = 1; rect.bottom = rect.top + 250; if (!m_DeviceSubType.Create(CBS_DROPDOWNLIST | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL, rect, this, ID_DEVICE_SUBTYPE)) { TRACE("Failed to create combo-box\n"); return FALSE; } ResetDeviceTypes(); ResetDeviceSubTypes(); return TRUE; }
BOOL CPlayerToolBar::Create(CWnd* pParentWnd) { VERIFY(__super::CreateEx(pParentWnd, TBSTYLE_FLAT | TBSTYLE_TRANSPARENT | TBSTYLE_AUTOSIZE | TBSTYLE_CUSTOMERASE, WS_CHILD | WS_VISIBLE | CBRS_BOTTOM | CBRS_TOOLTIPS, CRect(2, 2, 0, 1))); VERIFY(LoadToolBar(IDB_PLAYERTOOLBAR)); // Should never be RTLed ModifyStyleEx(WS_EX_LAYOUTRTL, WS_EX_NOINHERITLAYOUT); CToolBarCtrl& tb = GetToolBarCtrl(); tb.DeleteButton(tb.GetButtonCount() - 1); tb.DeleteButton(tb.GetButtonCount() - 1); SetMute(AfxGetAppSettings().fMute); UINT styles[] = { TBBS_CHECKGROUP, TBBS_CHECKGROUP, TBBS_CHECKGROUP, TBBS_SEPARATOR, TBBS_BUTTON, TBBS_BUTTON, TBBS_BUTTON, TBBS_BUTTON, TBBS_SEPARATOR, TBBS_BUTTON, TBBS_SEPARATOR, TBBS_SEPARATOR, TBBS_CHECKBOX, }; for (int i = 0; i < _countof(styles); ++i) { // This fixes missing separator in Win 7 if (styles[i] & TBBS_SEPARATOR) { SetButtonInfo(i, GetItemID(i), styles[i], -1); } else { SetButtonStyle(i, styles[i] | TBBS_DISABLED); } } m_volctrl.Create(this); m_volctrl.SetRange(0, 100); m_nButtonHeight = 16; // reset m_nButtonHeight CImage image; if (LoadExternalToolBar(&image)) { CBitmap* bmp = CBitmap::FromHandle(image); int width = image.GetWidth(); int height = image.GetHeight(); int bpp = image.GetBPP(); if (width == height * 15) { // the manual specifies that sizeButton should be sizeImage inflated by (7, 6) SetSizes(CSize(height + 7, height + 6), CSize(height, height)); m_pButtonsImages = DEBUG_NEW CImageList(); if (bpp == 32) { m_pButtonsImages->Create(height, height, ILC_COLOR32 | ILC_MASK, 1, 0); m_pButtonsImages->Add(bmp, nullptr); // alpha is the mask } else { m_pButtonsImages->Create(height, height, ILC_COLOR24 | ILC_MASK, 1, 0); m_pButtonsImages->Add(bmp, RGB(255, 0, 255)); } m_nButtonHeight = height; GetToolBarCtrl().SetImageList(m_pButtonsImages); } image.Destroy(); } return TRUE; }
// The `main program' equivalent, creating the windows and returning the // main frame bool AudacityApp::OnInit() { // Unused strings that we want to be translated, even though // we're not using them yet... wxString future1 = _("Master Gain Control"); wxString future2 = _("Input Meter"); wxString future3 = _("Output Meter"); ::wxInitAllImageHandlers(); wxFileSystem::AddHandler(new wxZipFSHandler); InitPreferences(); #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) && !defined(__CYGWIN__) this->AssociateFileTypes(); #endif // // Paths: set search path and temp dir path // wxString home = wxGetHomeDir(); mAppHomeDir = home; // On Unix systems, the default temp dir is in /tmp. // Search path (in this order): // * The AUDACITY_PATH environment variable // * The current directory // * The user's .audacity-files directory in their home directory // * The "share" and "share/doc" directories in their install path #ifdef __WXGTK__ defaultTempDir.Printf(wxT("/tmp/audacity1.2-%s"), wxGetUserId().c_str()); wxString pathVar = wxGetenv(wxT("AUDACITY_PATH")); if (pathVar != wxT("")) AddMultiPathsToPathList(pathVar, audacityPathList); AddUniquePathToPathList(FROMFILENAME(::wxGetCwd()), audacityPathList); AddUniquePathToPathList(wxString::Format(wxT("%s/.audacity-files"), home.c_str()), audacityPathList); #ifdef AUDACITY_NAME AddUniquePathToPathList(wxString::Format(wxT("%s/share/%s"), wxT(INSTALL_PREFIX), wxT(AUDACITY_NAME)), audacityPathList); AddUniquePathToPathList(wxString::Format(wxT("%s/share/doc/%s"), wxT(INSTALL_PREFIX), wxT(AUDACITY_NAME)), audacityPathList); #else AddUniquePathToPathList(wxString::Format(wxT("%s/share/audacity"), wxT(INSTALL_PREFIX)), audacityPathList); AddUniquePathToPathList(wxString::Format(wxT("%s/share/doc/audacity"), wxT(INSTALL_PREFIX)), audacityPathList); #endif AddUniquePathToPathList(wxString::Format(wxT("%s/share/locale"), wxT(INSTALL_PREFIX)), audacityPathList); #endif wxFileName tmpFile; tmpFile.AssignTempFileName(wxT("nn")); wxString tmpDirLoc = tmpFile.GetPath(wxPATH_GET_VOLUME); ::wxRemoveFile(FILENAME(tmpFile.GetFullPath())); // On Mac and Windows systems, use the directory which contains Audacity. #ifdef __WXMSW__ // On Windows, the path to the Audacity program is in argv[0] wxString progPath = wxPathOnly(argv[0]); AddUniquePathToPathList(progPath, audacityPathList); AddUniquePathToPathList(progPath+wxT("\\Languages"), audacityPathList); defaultTempDir.Printf(wxT("%s\\audacity_1_2_temp"), tmpDirLoc.c_str()); #endif #ifdef __MACOSX__ // On Mac OS X, the path to the Audacity program is in argv[0] wxString progPath = wxPathOnly(argv[0]); AddUniquePathToPathList(progPath, audacityPathList); // If Audacity is a "bundle" package, then the root directory is // the great-great-grandparent of the directory containing the executable. AddUniquePathToPathList(progPath+wxT("/../../../"), audacityPathList); AddUniquePathToPathList(progPath+wxT("/Languages"), audacityPathList); AddUniquePathToPathList(progPath+wxT("/../../../Languages"), audacityPathList); defaultTempDir.Printf(wxT("%s/audacity1.2-%s"), tmpDirLoc.c_str(), wxGetUserId().c_str()); #endif #ifdef __MACOS9__ // On Mac OS 9, the initial working directory is the one that // contains the program. wxString progPath = wxGetCwd(); AddUniquePathToPathList(progPath, audacityPathList); AddUniquePathToPathList(progPath+wxT(":Languages"), audacityPathList); defaultTempDir.Printf(wxT("%s/audacity_1_2_temp"), tmpDirLoc.c_str()); #endif // BG: Create a temporary window to set as the top window wxFrame *temporarywindow = new wxFrame(NULL, -1, wxT("temporarytopwindow")); SetTopWindow(temporarywindow); // Locale // wxWindows 2.3 has a much nicer wxLocale API. We can make this code much // better once we move to wx 2.3/2.4. wxString lang = gPrefs->Read(wxT("/Locale/Language"), wxT("")); // Pop up a dialog the first time the program is run if (lang == wxT("")) lang = ChooseLanguage(NULL); #ifdef NOT_RQD //TIDY-ME: (CleanSpeech) Language prompt?? // The prompt for language only happens ONCE on a system. // I don't think we should disable it JKC wxString lang = gPrefs->Read(wxT("/Locale/Language"), "en"); //lda // Pop up a dialog the first time the program is run //lda if (lang == "") //lda lang = ChooseLanguage(NULL); #endif gPrefs->Write(wxT("/Locale/Language"), lang); if (lang != wxT("en")) { wxLogNull nolog; mLocale = new wxLocale(wxT(""), lang, wxT(""), true, true); for(unsigned int i=0; i<audacityPathList.GetCount(); i++) mLocale->AddCatalogLookupPathPrefix(audacityPathList[i]); #ifdef AUDACITY_NAME mLocale->AddCatalog(wxT(AUDACITY_NAME)); #else mLocale->AddCatalog(wxT("audacity")); #endif } else mLocale = NULL; // Initialize internationalisation (number formats etc.) // // This must go _after_ creating the wxLocale instance because // creating the wxLocale instance sets the application-wide locale. Internat::Init(); // Init DirManager, which initializes the temp directory // If this fails, we must exit the program. if (!InitTempDir()) { FinishPreferences(); return false; } // More initialization InitCleanSpeech(); InitDitherers(); InitAudioIO(); LoadEffects(); #ifdef __WXMAC__ // On the Mac, users don't expect a program to quit when you close the last window. // Create an offscreen frame with a menu bar. The frame should never // be visible, but when all other windows are closed, this menu bar should // become visible. gParentFrame = new wxFrame(NULL, -1, wxT("invisible"), wxPoint(5000, 5000), wxSize(100, 100)); wxMenu *fileMenu = new wxMenu(); fileMenu->Append(wxID_NEW, wxT("&New\tCtrl+N")); fileMenu->Append(wxID_OPEN, wxT("&Open...\tCtrl+O")); /* i18n-hint: Mac OS X shortcut should be Ctrl+, */ fileMenu->Append(wxID_PREFERENCES, _("&Preferences...\tCtrl+,")); wxMenuBar *menuBar = new wxMenuBar(); menuBar->Append(fileMenu, wxT("&File")); gParentFrame->SetMenuBar(menuBar); gParentFrame->Show(); SetTopWindow(gParentFrame); #endif SetExitOnFrameDelete(true); /////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// //Initiate pointers to toolbars here, and create //the toolbars that should be loaded at startup. gControlToolBarStub = LoadToolBar( wxT(""),true, gParentWindow,ControlToolBarID); gMixerToolBarStub = LoadToolBar( wxT("/GUI/EnableMixerToolBar"),true, gParentWindow,MixerToolBarID); gMeterToolBarStub = LoadToolBar( wxT("/GUI/EnableMeterToolBar"),true, gParentWindow,MeterToolBarID); gEditToolBarStub = LoadToolBar( wxT("/GUI/EnableEditToolBar"),true, gParentWindow,EditToolBarID); gTranscriptionToolBarStub = LoadToolBar( wxT("/GUI/EnableTranscriptionToolBar"),false, gParentWindow,TranscriptionToolBarID); /// ToolBar Initiation Complete. //////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// AudacityProject *project = CreateNewAudacityProject(gParentWindow); SetTopWindow(project); delete temporarywindow; // Can't handle command-line args on Mac OS X yet... // Cygwin command-line parser below... #if !defined(__MACOSX__) && !defined(__CYGWIN__) // Parse command-line arguments if (argc > 1) { for (int option = 1; option < argc; option++) { if (!argv[option]) continue; bool handled = false; if (!wxString(wxT("-help")).CmpNoCase(argv[option])) { wxPrintf(/* i18n-hint: '-help', '-test' and '-blocksize' need to stay in English. */ _("Command-line options supported:\n -help (this message)\n -test (run self diagnostics)\n -blocksize ### (set max disk block size in bytes)\n\nIn addition, specify the name of an audio file or Audacity project\nto open it.\n\n")); exit(0); } if (option < argc - 1 && argv[option + 1] && !wxString(wxT("-blocksize")).CmpNoCase(argv[option])) { long theBlockSize; if (wxString(argv[option + 1]).ToLong(&theBlockSize)) { if (theBlockSize >= 256 && theBlockSize < 100000000) { wxFprintf(stderr, _("Using block size of %ld\n"), theBlockSize); Sequence::SetMaxDiskBlockSize(theBlockSize); } } option++; handled = true; } if (!handled && !wxString(wxT("-test")).CmpNoCase(argv[option])) { RunBenchmark(NULL); exit(0); } if (argv[option][0] == wxT('-') && !handled) { wxPrintf(_("Unknown command line option: %s\n"), argv[option]); exit(0); } if (!handled) project->OpenFile(argv[option]); } // for option... } // if (argc>1) #endif // not Mac OS X // Cygwin command line parser (by Dave Fancella) #if defined(__CYGWIN__) if (argc > 1) { int optionstart = 1; bool startAtOffset = false; // Scan command line arguments looking for trouble for (int option = 1; option < argc; option++) { if (!argv[option]) continue; // Check to see if argv[0] is copied across other arguments. // This is the reason Cygwin gets its own command line parser. if (wxString(argv[option]).Lower().Contains(wxString(wxT("audacity.exe")))) { startAtOffset = true; optionstart = option + 1; } } for (int option = optionstart; option < argc; option++) { if (!argv[option]) continue; bool handled = false; bool openThisFile = false; wxString fileToOpen; if (!wxString(wxT("-help")).CmpNoCase(argv[option])) { wxPrintf(/* i18n-hint: '-help', '-test' and '-blocksize' need to stay in English. */ _("Command-line options supported:\n" " -help (this message)\n" " -test (run self diagnostics)\n" " -blocksize ### (set max disk block size in bytes)\n" "\n" "In addition, specify the name of an audio file or " "Audacity project\n" "to open it.\n" "\n")); exit(0); } if (option < argc - 1 && argv[option + 1] && !wxString(wxT("-blocksize")).CmpNoCase(argv[option])) { long theBlockSize; if (wxString(argv[option + 1]).ToLong(&theBlockSize)) { if (theBlockSize >= 256 && theBlockSize < 100000000) { wxFprintf(stderr, _("Using block size of %ld\n"), theBlockSize); Sequence::SetMaxDiskBlockSize(theBlockSize); } } option++; handled = true; } if (!handled && !wxString(wxT("-test")).CmpNoCase(argv[option])) { RunBenchmark(NULL); exit(0); } if (argv[option][0] == wxT('-') && !handled) { wxPrintf(_("Unknown command line option: %s\n"), argv[option]); exit(0); } if(handled) fileToOpen.Clear(); if (!handled) fileToOpen = fileToOpen + wxT(" ") + argv[option]; if(wxString(argv[option]).Lower().Contains(wxT(".aup"))) openThisFile = true; if(openThisFile) { openThisFile = false; project->OpenFile(fileToOpen); } } // for option... } // if (argc>1) #endif // Cygwin command-line parser gInited = true; return TRUE; }
BOOL CRRECToolBar::Create( CWnd* parent) { if (CreateEx(parent, TBSTYLE_FLAT | TBSTYLE_WRAPABLE, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP | CBRS_SIZE_DYNAMIC/* | WS_CLIPCHILDREN*/, CRect(0, 0, 0, 0), TOOLBAR_CONTROL) && LoadToolBar(TOOLBAR_CONTROL)) { SetImage(IDB_TOOLBAR, RGB(255, 0, 255)); // very important - turn OFF all the auto positioning and sizing // by default have no borders UINT nStyle = GetBarStyle(); // nStyle &= ~(CCS_NORESIZE | CCS_NOPARENTALIGN | CBRS_BORDER_ANY); nStyle |= (/*CBRS_SIZE_FIXED | */CBRS_TOOLTIPS | CBRS_FLYBY); SetBarStyle(nStyle); SetOwner(parent); GetToolBarCtrl().SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS); // colour drop buttons int nIndex = CommandToIndex(BUTTON_BACKCOLOR); SetButtonStyle(nIndex, GetButtonStyle(nIndex) | TBSTYLE_DROPDOWN); nIndex = CommandToIndex(BUTTON_TEXTCOLOR); SetButtonStyle(nIndex, GetButtonStyle(nIndex) | TBSTYLE_DROPDOWN); ///////////////////////////////////// // Map in combo boxes // TBBUTTON buttons[] = { { 0, FONT_NAME_ID, 0, TBSTYLE_SEP, 0, NULL }, { 0, -1, 0, TBSTYLE_SEP, 0, NULL }, { 0, FONT_SIZE_ID, 0, TBSTYLE_SEP, 0, NULL }, { 0, -1, 0, TBSTYLE_SEP, 0, NULL }, }; const int BTNCOUNT = sizeof(buttons) / sizeof(TBBUTTON); for (int nBtn = 0; nBtn < BTNCOUNT; nBtn++) GetToolBarCtrl().InsertButton(nBtn, &buttons[nBtn]); CRect rect; TBBUTTONINFO tbi; tbi.cbSize = sizeof( TBBUTTONINFO ); tbi.cx = FONT_COMBO_WIDTH; tbi.dwMask = TBIF_SIZE; // By index // The font name combo GetToolBarCtrl().SetButtonInfo( FONT_NAME_ID, &tbi ); GetItemRect( FONT_NAME_POS, &rect ); rect.left++; rect.top++; rect.bottom += COMBO_HEIGHT; if (!m_font.Create( WS_CHILD | WS_VSCROLL | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWNLIST | CBS_SORT, rect, this, DROPDOWN_FONT )) return FALSE; m_font.SetFont( CFont::FromHandle( ( HFONT ) ::GetStockObject( DEFAULT_GUI_FONT ) ) ); m_font.FillCombo(); // The font size combo tbi.cx = COMBO_WIDTH; GetToolBarCtrl().SetButtonInfo( FONT_SIZE_ID, &tbi ); GetItemRect( FONT_SIZE_POS, &rect ); rect.top++; rect.bottom += COMBO_HEIGHT; if (!m_size.Create(WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWNLIST | CBS_HASSTRINGS, rect, this, DROPDOWN_SIZE )) return FALSE; m_size.SetFont( CFont::FromHandle( ( HFONT ) ::GetStockObject( DEFAULT_GUI_FONT ) ) ); m_size.FillCombo(); return TRUE; } return FALSE; }
bool CEditToolBar::Create(CMainFrame* pParent) { ASSERT_VALID(pParent); if (!CToolBar::Create(pParent, WS_CHILD | WS_VISIBLE | /*CBRS_SIZE_DYNAMIC |*/ CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY) || !LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); ASSERT(false); return false; } //////////////////////////////////////////////////////////////////////////////// // Create an 8-point MS Sans Serif font for the combo boxes CClientDC dc(this); int FontHeight = -((dc.GetDeviceCaps (LOGPIXELSY) * 8) / 72); m_ToolBarFont.CreateFont(FontHeight, 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "MS Sans Serif"); // mearsure font to get size of average character CFont* pOldFont = dc.SelectObject(&m_ToolBarFont); TEXTMETRIC tm; dc.GetTextMetrics(&tm); int CharWidth = tm.tmAveCharWidth; int CharHeight = tm.tmHeight + tm.tmExternalLeading; dc.SelectObject(pOldFont); // create catagory list { SetButtonInfo(k_CatagoryIndex, ID_CATEGORY, TBBS_SEPARATOR, CharWidth*25); CRect rect; GetItemRect(k_CatagoryIndex, &rect); rect.bottom = rect.top + CharHeight*35; if (!m_CategoryList.Create( WS_CHILD | WS_VISIBLE | WS_VSCROLL | CBS_DROPDOWNLIST, rect, this, ID_CATEGORY)) return false; m_CategoryList.SetFont(&m_ToolBarFont); for (int i = 0; i < NUMCATEGORIES; i++) { m_CategoryList.AddString(g_CategoryNames[i]); } m_CategoryList.SetCurSel(g_Category); } // create terrain list { SetButtonInfo(k_TerrainIndex, ID_TERRAIN, TBBS_SEPARATOR, CharWidth*30); CRect rect; GetItemRect(k_TerrainIndex, &rect); rect.bottom = rect.top + CharHeight*20; if (!m_TerrainList.Create( WS_CHILD | WS_VISIBLE | WS_VSCROLL | CBS_DROPDOWNLIST, rect, this, ID_TERRAIN)) return false; m_TerrainList.SetFont(&m_ToolBarFont); for (int i = 0; i < MAXTILES; i++) g_TerrainToTile[i] = -1; int j=0; for (i = 0; i < g_App.m_Elements.GetSize(); i++) { if (g_App.m_Elements[i].TileType == g_Category) { g_TerrainToTile[j++] = i; m_TerrainList.AddString(g_App.m_Elements[i].Name); } } g_Terrain = 0; m_TerrainList.SetCurSel(g_Terrain); } // create elevation edit { SetButtonInfo(k_ElevationIndex, ID_ELEVATION, TBBS_SEPARATOR, CharWidth*5); CRect rect; GetItemRect(k_ElevationIndex, &rect); rect.bottom -= 1; rect.top += 1; if (!m_ElevationEdit.Create(ES_NUMBER | WS_BORDER | WS_CHILD | WS_VISIBLE, rect, this, ID_ELEVATION)) return false; m_ElevationEdit.SetFont(&m_ToolBarFont); g_Elevation = 20; CString str; str.Format("%d", g_Elevation); m_ElevationEdit.SetWindowText(str); SetButtonInfo(k_ElevationSpinnerIndex, ID_ELEVATION_SPINNER, TBBS_SEPARATOR, 20); GetItemRect(k_ElevationSpinnerIndex, &rect); rect.left += 3; rect.right += 3; if (!m_ElevationCtrl.Create(UDS_SETBUDDYINT|UDS_ARROWKEYS| WS_CHILD | WS_VISIBLE, rect, this, ID_ELEVATION_SPINNER)) return false; m_ElevationCtrl.SetBuddy(&m_ElevationEdit); m_ElevationCtrl.SetRange(0,100); } SetWindowText(_T("")); EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM); pParent->DockControlBar(this, AFX_IDW_DOCKBAR_TOP); return true; }
void ULTooToolBar::InitControlWithULInfo(CWnd* pParentWnd) { CFDMSApp* pApp = (CFDMSApp*)AfxGetApp(); Create(pParentWnd); LoadToolBar(IDR_TOOLBAR1); DWORD sty = GetBarStyle(); SetBarStyle(sty | CBRS_TOOLTIPS | CBRS_FLYBY); EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM); SetWindowText(_T("Integrated Tools")); CRect rect(-COMBOBOX_WIDTH, -COMBOBOX_HEIGHT, 0, 0); // The ID of the ComboBox is important for two reasons. One, so you // can receive notifications from the control. And also for ToolTips. // During HitTesting if the ToolBar sees that the mouse is one a child // control, the toolbar will lookup the controls ID and search for a // string in the string table with the same ID to use for ToolTips // and StatusBar info. if (m_ToolBox.Create(WS_CHILD | CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | CBS_HASSTRINGS, rect, this, ID_TOOLCOMBOBOXID)) { HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); if (hFont == NULL) hFont = (HFONT)GetStockObject(ANSI_VAR_FONT); m_ToolBox.SendMessage(WM_SETFONT, (WPARAM)hFont); // determine if UL is available. UINT num_tools = 0; if (pApp->m_pRT_Init != NULL) num_tools = pApp->m_pRT_Init->Get_Tools_Num(); if (num_tools > 0) { const char * tool_name; unsigned int i, j; BOOL tool_status; m_bULToolsAvailable = true; j = 0; for (i=0; i<num_tools; i++) { tool_status = pApp->m_pRT_Init->Get_Tool_Installed (i); if (tool_status == FALSE) continue; tool_status = pApp->m_pRT_Init->Get_Data_Match_Tool (i); if (tool_status == FALSE) continue; tool_name = pApp->m_pRT_Init->Get_Tool_Name (i); m_ToolBox.InsertString(j, tool_name); m_ToolBox.SetItemData(j, i); j++; } } else m_ToolBox.InsertString(0, "None Available"); if (ULSupport::ULIRSDataPath.GetLength() > 5) // need something with suffix at least { // no UL no IRS no FacMgr or whtever so don't bother to check CheckForImportFileExistence(); SetTimer(TIMER_CHECKIMP,21000,0); // check every 21 seconds } } if(!SetHorizontal()) return; }
void CPlayerToolBar::SwitchTheme() { AppSettings& s = AfxGetAppSettings(); CToolBarCtrl& tb = GetToolBarCtrl(); m_nButtonHeight = 16; if (iDisableXPToolbars != (__int64)s.fDisableXPToolbars) { VERIFY(LoadToolBar(IDB_PLAYERTOOLBAR)); ModifyStyleEx(WS_EX_LAYOUTRTL, WS_EX_NOINHERITLAYOUT); tb.SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS); tb.DeleteButton(1); tb.DeleteButton(tb.GetButtonCount()-2); SetMute(s.fMute); UINT styles[] = { TBBS_CHECKGROUP, TBBS_CHECKGROUP, TBBS_SEPARATOR, TBBS_BUTTON, TBBS_BUTTON, TBBS_BUTTON, TBBS_BUTTON, TBBS_SEPARATOR, TBBS_BUTTON, TBBS_BUTTON, TBBS_SEPARATOR, TBBS_SEPARATOR, TBBS_CHECKBOX, }; for (int i = 0; i < _countof(styles); i++) { SetButtonStyle(i, styles[i] | TBBS_DISABLED); } iDisableXPToolbars = s.fDisableXPToolbars; } if (s.fDisableXPToolbars) { if (HMODULE h = LoadLibrary(_T("uxtheme.dll"))) { SetWindowThemeFunct f = (SetWindowThemeFunct)GetProcAddress(h, "SetWindowTheme"); if (f) { f(m_hWnd, L" ", L" "); } FreeLibrary(h); } SwitchRemmapedImgList(IDB_PLAYERTOOLBAR, 0);// 0 Remap Active COLORSCHEME cs; cs.dwSize = sizeof(COLORSCHEME); cs.clrBtnHighlight = 0x0046413c; cs.clrBtnShadow = 0x0037322d; tb.SetColorScheme(&cs); tb.SetIndent(5); } else { if (HMODULE h = LoadLibrary(_T("uxtheme.dll"))) { SetWindowThemeFunct f = (SetWindowThemeFunct)GetProcAddress(h, "SetWindowTheme"); if (f) { f(m_hWnd, L"Explorer", NULL); } FreeLibrary(h); } SwitchRemmapedImgList(IDB_PLAYERTOOLBAR, 2);// 2 Undo Active COLORSCHEME cs; cs.dwSize = sizeof(COLORSCHEME); cs.clrBtnHighlight = GetSysColor(COLOR_BTNFACE); cs.clrBtnShadow = GetSysColor(COLOR_BTNSHADOW); tb.SetColorScheme(&cs); tb.SetIndent(0); } HBITMAP hBmp = NULL; bool fp = CMPCPngImage::FileExists(CString(L"toolbar")); if (s.fDisableXPToolbars && !fp) { /* int col = s.clrFaceABGR; int r, g, b, R, G, B; r = col & 0xFF; g = (col >> 8) & 0xFF; b = col >> 16; */ hBmp = CMPCPngImage::LoadExternalImage(L"toolbar", IDB_PLAYERTOOLBAR_PNG, IMG_TYPE::PNG, s.nThemeBrightness, s.nThemeRed, s.nThemeGreen, s.nThemeBlue); } else if (fp) { hBmp = CMPCPngImage::LoadExternalImage(L"toolbar", 0, IMG_TYPE::UNDEF); } BITMAP bitmapBmp; if (NULL != hBmp) { ::GetObject(hBmp, sizeof(bitmapBmp), &bitmapBmp); if (fp && bitmapBmp.bmWidth != bitmapBmp.bmHeight * 15) { if (s.fDisableXPToolbars) { hBmp = CMPCPngImage::LoadExternalImage(L"", IDB_PLAYERTOOLBAR_PNG, IMG_TYPE::PNG, s.nThemeBrightness, s.nThemeRed, s.nThemeGreen, s.nThemeBlue); ::GetObject(hBmp, sizeof(bitmapBmp), &bitmapBmp); } else { DeleteObject(hBmp); hBmp = NULL; } } } if (NULL != hBmp) { CBitmap *bmp = DNew CBitmap(); bmp->Attach(hBmp); SetSizes(CSize(bitmapBmp.bmHeight + 7, bitmapBmp.bmHeight + 6), CSize(bitmapBmp.bmHeight, bitmapBmp.bmHeight)); SAFE_DELETE(m_pButtonsImages); m_pButtonsImages = DNew CImageList(); if (32 == bitmapBmp.bmBitsPixel) { m_pButtonsImages->Create(bitmapBmp.bmHeight, bitmapBmp.bmHeight, ILC_COLOR32 | ILC_MASK, 1, 0); m_pButtonsImages->Add(bmp, static_cast<CBitmap*>(0)); } else { m_pButtonsImages->Create(bitmapBmp.bmHeight, bitmapBmp.bmHeight, ILC_COLOR24 | ILC_MASK, 1, 0); m_pButtonsImages->Add(bmp, RGB(255, 0, 255)); } m_nButtonHeight = bitmapBmp.bmHeight; tb.SetImageList(m_pButtonsImages); fDisableImgListRemap = true; delete bmp; DeleteObject(hBmp); } if (s.fDisableXPToolbars) { if (!fDisableImgListRemap) { SwitchRemmapedImgList(IDB_PLAYERTOOLBAR, 0);// 0 Remap Active SwitchRemmapedImgList(IDB_PLAYERTOOLBAR, 1);// 1 Remap Disabled } } else { fDisableImgListRemap = true; if (NULL == fp) { SwitchRemmapedImgList(IDB_PLAYERTOOLBAR, 2);// 2 Undo Active if (!fDisableImgListRemap) { SwitchRemmapedImgList(IDB_PLAYERTOOLBAR, 3);// 3 Undo Disabled } } } if (::IsWindow(m_volctrl.GetSafeHwnd())) { m_volctrl.Invalidate(); } CMainFrame* pFrame = (CMainFrame*)GetParentFrame(); OAFilterState fs = pFrame->GetMediaState(); TBBUTTONINFO bi; bi.cbSize = sizeof(bi); bi.dwMask = TBIF_IMAGE; if (fs == State_Running) { bi.iImage = 1; } else { bi.iImage = 0; } tb.SetButtonInfo(ID_PLAY_PLAY, &bi); }