You are on page 1of 5

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

Creating Floating Pop-Up Menus


void CMyView::OnContextMenu(CWnd *pWnd,
CPoint point)
{
CMenu menu; menu.LoadMenu(IDR_MYFLOATINGMENU); menu.GetSubMenu(0) -
>TrackPopupMenu
(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
point.x, point.y, this);
}

• Extended Command Processing


• BEGIN_MESSAGE_MAP(CMyView, CView)
ON_COMMAND_EX_RANGE(IDM_ZOOM_1,
IDM_ZOOM_2, OnZoom)
END_MESSAGE_MAP()
• ON_COMMAND_RANGE( id1, id2, Fxn )
• ON_COMMAND_EX_RANGE
• ON_UPDATE_COMMAND_UI_RANGE

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

Locating the Main FrameWindow


• The toolbar and status bar objects you'll be working with are attached to the application's
main frame window, not to the view window
• find the main frame window through the application object.
CMainFrame* pFrame = (CMainFrame*)
AfxGetApp()->m_pMainWnd;
CToolBar* pToolBar = &pFrame->m_wndToolBar;

Example

You might also like