Example #1
0
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CXTMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

	if (!m_wndMenuBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndMenuBar.LoadMenuBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create menubar\n");
		return -1;      // fail to create
	}
	
	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}

	//工具箱
	if (!m_wndToolboxBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_RIGHT
		| CBRS_SIZE_FIXED | CBRS_TOOLTIPS | CBRS_FLYBY, IDW_TOOLBOX_BAR) ||
		!m_wndToolboxBar.LoadToolBar(IDR_TOOLBAR_BOX))
	{
		TRACE0("Failed to create palette bar\n");
		return -1;      // fail to create
	}

	m_wndToolboxBar.ModifyStyle(0, TBSTYLE_FLAT);
	m_wndToolboxBar.SetColumns(3);
	m_wndToolboxBar.SetWindowText(_T("工具箱"));

	//格式工具栏
	// create the format toolbar.
	if (!m_wndFormatBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(0,0,0,0), 59500) ||
		!m_wndFormatBar.LoadToolBar(IDR_FORMATTING))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}

	// set the title for the formatting toolbar.
    m_wndFormatBar.SetWindowText( _T( "格式工具栏" ) );
 	// initialize the color picker dropdown for the toolbar.
    m_wndFormatBar.AddDropDownButton( ID_FORMATTING_COLOR,
		m_crCurrent, CLR_DEFAULT, CPS_XT_EXTENDED | CPS_XT_MORECOLORS ); 

    m_wndFormatBar.AddDropDownButton( ID_FORMATTING_BACK_COLOR,
		m_crFillColor, CLR_DEFAULT, CPS_XT_EXTENDED | CPS_XT_MORECOLORS ); 

	m_wndFormatBar.AddDropDownButton(ID_LINE_WIDTH);
	m_wndFormatBar.AddDropDownButton(ID_LINE_STYPE);
	m_wndFormatBar.AddDropDownButton(ID_LEFTARROW_STYLE);
	m_wndFormatBar.AddDropDownButton(ID_RIGHTARROW_STYLE);

	m_wndFormatBar.AutoSizeToolbar();
	// initialize the style, font and size combo boxes.
	if ( !InitComboFont ( ) ||
         !InitComboSize ( ) )
	{
		return -1;
	}

	// Create the workspace bar.
	if( !m_wndTabDockBar.Create(this, IDW_TABDOCKBAR, _T("导航器窗口"),
		CSize(200, 150), CBRS_LEFT))
	{
		TRACE0("Failed to create workspace dock window\n");
		return -1;		// fail to create
	}

	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}

	// TODO: Delete these three lines if you don't want the toolbar to
	//  be dockable
	m_wndMenuBar.EnableDockingEx(CBRS_ALIGN_ANY, CBRS_XT_ALL_FLAT);
	m_wndToolBar.EnableDockingEx(CBRS_ALIGN_ANY, CBRS_XT_ALL_FLAT);
	m_wndTabDockBar.EnableDockingEx(CBRS_ALIGN_ANY, CBRS_XT_ALL_FLAT|CBRS_XT_GRIPPER_GRAD);
	m_wndToolboxBar.EnableDockingEx(CBRS_ALIGN_ANY, CBRS_XT_ALL_FLAT);
	m_wndFormatBar.EnableDockingEx(CBRS_ALIGN_ANY, CBRS_XT_ALL_FLAT);
	EnableDockingEx(CBRS_ALIGN_ANY, CBRS_XT_ALL_FLAT);
	DockControlBar(&m_wndMenuBar);
	DockControlBar(&m_wndToolBar);
	DockControlBar(&m_wndTabDockBar);
	DockControlBar(&m_wndToolboxBar);
	DockControlBar(&m_wndFormatBar);
	// Set the nubmer of columns for the m_wndToolboxBar bar.
	// Insert company name into the status bar.
	AddLogo();

	// TODO: Remove this line if you don't want cool menus.
	InstallCoolMenus(IDR_MAINFRAME);

// use multiple toolbars to initialize cool menus.
///UINT arToolbars[] = { IDR_MAINFRAME, IDR_TOOLBAR1 };
///InstallCoolMenus( arToolbars, _countof( arToolbars ) );

	XT_DROPDOWNBUTTON* pDDBtn = m_wndFormatBar.FindDropDownButton( ID_FORMATTING_COLOR );
	if ( pDDBtn != NULL ) {
		m_crCurrent = pDDBtn->clrColor;
	}

	return 0;
}
Example #2
0
/*------------------------------------------------
  Initialize
--------------------------------------------------*/
void OnInit(HWND hDlg)
{
	ColorBox colors[2];
	HWND quality_cb = GetDlgItem(hDlg, IDC_FONTQUAL);
	HDC hdc;
	LOGFONT logfont;
	HFONT hfont;
	m_transition=-1; // start transition lock
	// setting of "background" and "text"
	colors[0].hwnd = GetDlgItem(hDlg, IDC_COLFORE);
	colors[0].color = api.GetInt(L"Clock",L"ForeColor",TCOLOR(TCOLOR_DEFAULT));
	colors[1].hwnd = GetDlgItem(hDlg, IDC_COLBACK);
	colors[1].color = api.GetInt(L"Clock",L"BackColor",TCOLOR(TCOLOR_DEFAULT));
	ColorBox_Setup(colors, 2);
	
	// if color depth is 256 or less
	hdc = CreateICA("DISPLAY", NULL, NULL, NULL);
	if(GetDeviceCaps(hdc, BITSPIXEL) <= 8) {
		EnableDlgItem(hDlg, IDC_COLFORE_BTN, FALSE);
		EnableDlgItem(hDlg, IDC_COLBACK_BTN, FALSE);
	}
	DeleteDC(hdc);
	
	InitComboFont(hDlg);
	
	SetComboFontSize(hDlg, TRUE);
	
	
	CheckDlgButton(hDlg, IDC_BOLD, api.GetInt(L"Clock", L"Bold", 0));
	CheckDlgButton(hDlg, IDC_ITALIC, api.GetInt(L"Clock", L"Italic", 0));
	
	hfont = (HFONT)SendMessage(hDlg, WM_GETFONT, 0, 0);
	GetObject(hfont, sizeof(LOGFONT), &logfont);
	logfont.lfWeight = FW_BOLD;
	hfont = CreateFontIndirect(&logfont);
	SendDlgItemMessage(hDlg, IDC_BOLD, WM_SETFONT, (WPARAM)hfont, 0);
	
	logfont.lfWeight = FW_NORMAL;
	logfont.lfItalic = 1;
	hfont = CreateFontIndirect(&logfont);
	SendDlgItemMessage(hDlg, IDC_ITALIC, WM_SETFONT, (WPARAM)hfont, 0);
	
	SendDlgItemMessage(hDlg, IDC_SPINCHEIGHT, UDM_SETRANGE32, (WPARAM)-999,999);
	SendDlgItemMessage(hDlg, IDC_SPINCHEIGHT, UDM_SETPOS32, 0, api.GetInt(L"Clock", L"ClockHeight", 0));
	
	SendDlgItemMessage(hDlg, IDC_SPINCWIDTH, UDM_SETRANGE32, (WPARAM)-999,999);
	SendDlgItemMessage(hDlg, IDC_SPINCWIDTH, UDM_SETPOS32, 0, api.GetInt(L"Clock", L"ClockWidth", 0));
	
	SendDlgItemMessage(hDlg, IDC_SPINLHEIGHT, UDM_SETRANGE32, (WPARAM)-64,64);
	SendDlgItemMessage(hDlg, IDC_SPINLHEIGHT, UDM_SETPOS32, 0, api.GetInt(L"Clock", L"LineHeight", 0));
	
	SendDlgItemMessage(hDlg, IDC_SPINVPOS, UDM_SETRANGE32, (WPARAM)-200,200);
	SendDlgItemMessage(hDlg, IDC_SPINVPOS, UDM_SETPOS32, 0, api.GetInt(L"Clock", L"VertPos", 0));
	
	SendDlgItemMessage(hDlg, IDC_SPINHPOS, UDM_SETRANGE32, (WPARAM)-200,200);
	SendDlgItemMessage(hDlg, IDC_SPINHPOS, UDM_SETPOS32, 0, api.GetInt(L"Clock", L"HorizPos", 0));
	
	SendDlgItemMessage(hDlg, IDC_SPINANGLE, UDM_SETRANGE32, (WPARAM)-360,360);
	SendDlgItemMessage(hDlg, IDC_SPINANGLE, UDM_SETPOS32, 0, api.GetInt(L"Clock", L"Angle", 0));
	
	SendDlgItemMessage(hDlg, IDC_SPINALPHA, UDM_SETRANGE32, 0,100);
	SendDlgItemMessage(hDlg, IDC_SPINALPHA, UDM_SETPOS32, 0, api.GetInt(L"Taskbar", L"AlphaTaskbar", 0));
	
	ComboBox_AddString(quality_cb, L"Default");            // 0 = DEFAULT_QUALITY
	ComboBox_AddString(quality_cb, L"Draft");              // 1 = DRAFT_QUALITY
	ComboBox_AddString(quality_cb, L"Proof");              // 2 = PROOF_QUALITY
	ComboBox_AddString(quality_cb, L"NonAntiAliased");     // 3 = NONANTIALIASED_QUALITY
	ComboBox_AddString(quality_cb, L"AntiAliased (Win7)"); // 4 = ANTIALIASED_QUALITY
	ComboBox_AddString(quality_cb, L"ClearType (WinXP+)"); // 5 = CLEARTYPE_QUALITY
	ComboBox_AddString(quality_cb, L"ClearType Natural");  // 6 = CLEARTYPE_NATURAL_QUALITY
	ComboBox_SetCurSel(quality_cb,api.GetInt(L"Clock",L"FontQuality",CLEARTYPE_QUALITY));
	m_transition=0; // end transition lock, ready to go
}