You are on page 1of 5

• RunAppWizard to create an SDI application

& Use the resource editor to edit the application's main menu as follows
3. Use the resource editor to update the application's toolbar-Edit the
IDR_MAINFRAME toolbar resource
4. Give the ID to each Button
5. USE ClassWizard to add command and update command UI messages for
ID_CIRCLE,ID_SQUARE &ID_PATTERN
6. In the file ex14aView.h,
private:
CRect m_rect;
BOOL m_bCircle;
BOOL m_bPattern;
7. void CEx14aView::OnDrawCircle()
{

m_bCircle = TRUE;
m_rect += CPoint(25, 25);
InvalidateRect(m_rect); }
8. void CEx14aView::OnDrawSquare()
{ m_bCircle = FALSE;

m_rect += CPoint(25, 25);


InvalidateRect(m_rect);
}
9. void CEx14aView::OnDrawPattern() //toggles
{ m_bPattern ^= 1; }
10. void CEx14aView::OnUpdateDrawCircle (CCmdUI* pCmdUI)
{ pCmdUI->Enable(!m_bCircle); }
11.voidCEx14aView::OnUpdateDrawSquare(CCmdUI* pCmdUI)
{ pCmdUI->Enable(m_bCircle); }
12. void CEx14aView::OnUpdateDrawPattern(CCmdUI* pCmdUI)
{ pCmdUI->SetCheck(m_bPattern); }
StatusBar
• neither accepts user input nor generates command messages
• to display text in panes under program control
• supports two types of text panes
o message line panes
o status indicator panes

• The Status Bar Definition

• The static indicators array that AppWizard generates in the MainFrm.cpp file defines the
panes for the application's status bar.
• The constant ID_SEPARATOR identifies a message line pane;
• the other constants are string resource IDs that identify indicator panes

Get access to the status bar object


CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->
m_pMainWnd;
CStatusBar* pStatus = &pFrame->m_wndStatusBar;

Display String in Massage Line-SetPaneText


pStatus->SetPaneText(0, "message line for first pane");
Pane No.:
0-leftmost pane
1-next pane to the right and so forth.

The Status Indicator


• status indicator pane is linked to a single resource-supplied string that is displayed or
hidden by logic in an associated update command UI message handler function.
• –Contains Indicators .
• An indicator is identified by a string resource ID.
• same ID is used to route update command UI messages.
• For example Caps Lock indication by status bar
In Mainframe.cpp
• ON_UPDATE_COMMAND_UI(ID_INDICATOR_CAPS,
OnUpdateKeyCapsLock)
• void MainFrame::OnUpdateKeyCapsLock(CCmdUI* pCmdUI)
{ pCmdUI->Enable(::GetKeyState(VK_CAPITAL) & 1); }

For Left Button Status


• ON_UPDATE_COMMAND_UI(ID_LEFT, OnLeft)
• void MainFrame::OnLeft(CCmdUI* pCmdUI)
{ pCmdUI->Enable(::GetKeyState(VK_LBUTTON) & 1); }

• InMainframe.h
void Onleft(CCmdUI* j);

• Taking Control of the Status Bar


Avoid Default status bar and have your own status bar
• To assign your own ID, you must replace this call
m_wndStatusBar.Create(this); with this call
• m_wndStatusBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_BOTTOM,
ID_MY_STATUS_BAR);
Example

You might also like