MainFrm.cpp
资源名称:ictprop.rar [点击查看]
上传用户:tenhai
上传日期:2021-02-19
资源大小:492k
文件大小:5k
源码类别:
组合框控件
开发平台:
Visual C++
- // MainFrm.cpp : implementation of the CMainFrame class
- //
- #include "stdafx.h"
- #include "prop.h"
- #include "MainFrm.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame
- IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
- BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- // DO NOT EDIT what you see in these blocks of generated code !
- ON_WM_CREATE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- static UINT indicators[] =
- {
- ID_SEPARATOR, // status line indicator
- ID_INDICATOR_CAPS,
- ID_INDICATOR_NUM,
- ID_INDICATOR_SCRL,
- };
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame construction/destruction
- CMainFrame::CMainFrame()
- {
- // TODO: add member initialization code here
- }
- CMainFrame::~CMainFrame()
- {
- }
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
- 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 toolbarn");
- return -1; // fail to create
- }
- if (!m_wndStatusBar.Create(this) ||
- !m_wndStatusBar.SetIndicators(indicators,
- sizeof(indicators)/sizeof(UINT)))
- {
- TRACE0("Failed to create status barn");
- return -1; // fail to create
- }
- CreateInputBar();
- // TODO: Delete these three lines if you don't want the toolbar to
- // be dockable
- m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
- EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(&m_wndToolBar);
- return 0;
- }
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- if( !CMDIFrameWnd::PreCreateWindow(cs) )
- return FALSE;
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame diagnostics
- #ifdef _DEBUG
- void CMainFrame::AssertValid() const
- {
- CMDIFrameWnd::AssertValid();
- }
- void CMainFrame::Dump(CDumpContext& dc) const
- {
- CMDIFrameWnd::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame message handlers
- BOOL CMainFrame::CreateInputBar()
- {
- const int nDropHeight = 150;
- if(!m_wndInputBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_BOTTOM, IDS_INPUT)
- || !m_wndInputBar.LoadToolBar(IDR_INPUTBAR))
- {
- TRACE0("Failed to create inputbarn");
- return FALSE;
- }
- CRect rect;
- m_wndInputBar.GetItemRect(0,&rect);
- rect.top = 0;
- rect.bottom = rect.top + nDropHeight;
- rect.left=100;
- rect.right = rect.left + 300;
- if(!m_wndInputBar.m_comboBox.Create(WS_CHILD| WS_VSCROLL |
- CBS_DROPDOWN | WS_VISIBLE | WS_TABSTOP | WS_HSCROLL | CBS_AUTOHSCROLL |
- LBS_SORT,
- rect, &m_wndInputBar, IDS_INPUT))
- {
- TRACE0("Failed to create combo-boxn");
- return FALSE;
- }
- m_wndInputBar.m_comboBox.AddString("build [gf]");
- m_wndInputBar.m_comboBox.AddString("parse [sf]");
- m_wndInputBar.m_comboBox.AddString("quit ");
- m_wndInputBar.m_comboBox.SetCurSel(0);
- m_wndInputBar.m_comboBox.m_strInput="build [gf]";
- m_wndInputBar.SetBarStyle(m_wndInputBar.GetBarStyle() |
- CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
- m_wndInputBar.ModifyStyle(0,TBSTYLE_FLAT);
- //m_wndInputBar.EnableDocking(CBRS_ALIGN_ANY);
- //EnableDocking(CBRS_ALIGN_ANY);
- // Create a font for the combobox
- LOGFONT logFont;
- memset(&logFont, 0, sizeof(logFont));
- if (!::GetSystemMetrics(SM_DBCSENABLED))
- {
- // Since design guide says toolbars are fixed height so is the font.
- logFont.lfHeight = -12;
- logFont.lfWeight = FW_BOLD;
- logFont.lfPitchAndFamily = VARIABLE_PITCH | FF_SWISS;
- CString strDefaultFont;
- strDefaultFont.LoadString(IDS_DEFAULT_FONT);
- lstrcpy(logFont.lfFaceName, strDefaultFont);
- if (!m_wndInputBar.m_font.CreateFontIndirect(&logFont))
- TRACE0("Could Not create font for combon");
- else
- m_wndInputBar.m_comboBox.SetFont(&m_wndInputBar.m_font);
- }
- else
- {
- m_wndInputBar.m_font.Attach(::GetStockObject(SYSTEM_FONT));
- m_wndInputBar.m_comboBox.SetFont(&m_wndInputBar.m_font);
- }
- /*
- HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
- if (hFont == NULL)
- hFont = (HFONT)GetStockObject(ANSI_VAR_FONT);
- m_cmbInput.SendMessage(WM_SETFONT, (WPARAM)hFont);
- */
- return TRUE;
- }