Professional Documents
Culture Documents
In Ex13adoc
In Ex13adoc
cpp
1. void CEx13aDoc::OnEditClearDocument()
{ m_strText.Empty(); }
2. void CEx13aDoc::OnUpdateEditClearDocument
(CCmdUI* pCmdUI)
{
pCmdUI->Enable(!m_strText.IsEmpty());
}
In CEx13View.cpp : Creation RichEdit Control
• int CEx13aView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{ CRect rect(0, 0, 0, 0);
if (CView::OnCreate(lpCreateStruct) == -1) return -1;
m_rich.Create(ES_AUTOVSCROLL | ES_MULTILINEES_WANTRETURN |
WS_CHILD | WS_VISIBLE | WS_VSCROLL, rect, this, 1);
return 0;
}
2. void CEx13aView::OnSize(UINT nType, int cx, int cy)
{
CRect rect;
CView::OnSize(nType, cx, cy); GetClientRect(rect); m_rich.SetWindowPos(&wndTop,
0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_SHOWWINDOW);
}
position &structure
3. void CEx13aView::OnTransferGetData()
{
CEx13aDoc* pDoc = GetDocument();
m_rich.SetWindowText(pDoc- >m_strText);
m_rich.SetModify(FALSE);
}
4. void CEx13aView::OnTransferStoreData()
{
CEx13aDoc* pDoc = GetDocument(); m_rich.GetWindowText(pDoc->m_strText);
m_rich.SetModify(FALSE);
}
5. void CEx13aView::OnUpdateTransferStoreData
(CCmdUI* pCmdUI)
{
pCmdUI->Enable(m_rich.GetModify());
}
6. Build and Run the application
CHAPTER 3
ToolBar & StatusBar
ToolBar
• A toolbar consists of a number of horizontally (or vertically) arranged graphical buttons
that might be clustered in groups
• Pressing a toolbar button is equivalent to choosing a menu item(WM_COMMAND
messages).
• An update command UI message handler is used to update the button's state
• MFC toolbar can “dock” to any side of its parent window or float in its own mini-frame
window.
• you can change its size and drag it.
• A toolbar can also display tool tips as the user moves the mouse over the toolbar’s buttons.
ToolBar Bitmap:
-Each button on a toolbar appears to have its own bitmap,
but actually a single bitmap serves the entire toolbar.
-has tile, 15 pixels high and 16 pixels wide
-The toolbar bitmap is stored in the file Toolbar.bmp
• Button State:
0: Normal, unpressed state.
TBSTATE_CHECKED Checked (down) state.TBSTATE_ENABLED Available for use.
Button is grayed and unavailable if this state is not set.
TBSTATE_HIDDEN Not visible.
TBSTATE_INDETERMINATE Grayed.
TBSTATE_PRESSED Currently selected (pressed) with
the mouse.
TBSTATE_WRAP Line break follows the button
Example