Status Bar에 새로운 팬(Pane) 추가

Download Report

Transcript Status Bar에 새로운 팬(Pane) 추가

Status Bar
 CMainFrame
static UINT indicators[] =
{
ID_SEPARATOR,
// status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
…
}
•
자동으로 만들어진 code임
프로그래밍 응용 #16
1
Status Bar에 새로운 팬(Pane) 추가
 팬(Pane) : Status Bar의 구역을 Pane이라고 함
• 아래에서는 4개의 Pane으로 이루어져 있음
0
1
2
3
 새로운 팬 추가 : 2개의 팬을 추가
static UINT indicators[] =
{
ID_SEPARATOR,
// status line indicator
ID_SEPARATOR
// 새로 추가
ID_SEPARATOR
// 새로 추가
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
프로그래밍 응용 #16
2
Status Bar에 새로운 팬(Pane) 추가
 추가된 팬
0
추가된 2개의 팬
1
2
3 4
5
 추가되는 팬의 성질 지정 가능
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
...
m_wndStatusBar.SetPaneInfo(1,ID_SEPARATOR, SBPS_NORMAL, 150);
m_wndStatusBar.SetPaneInfo(2,ID_SEPARATOR, SBPS_NORMAL, 150);
return 0;
팬의 너비
}
•
•
SBPS_NOBORDERS, SBPS_POPOUT, SBPS_DISABLED, SBPS_NORMAL
SBPS_STRETCH : 각 팬들 너비 만큼 지정하고 나머지 전부 차지. Status Bar의 팬중에
서 오직 하나만이 SBPS_STRETCH style을 가질 수 있음
프로그래밍 응용 #16
3
Status Bar에 새로운 팬(Pane) 추가
 CMainFrame의 headfile (MainFrm.h)
class CMainFrame : public CFrameWnd
{
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
m_wndStatusBar의 속성을 public으로
바꿈
class CMainFrame : public CFrameWnd
{
public:
CStatusBar m_wndStatusBar;
protected: // control bar embedded members
프로그래밍 응용 #16
4
Status Bar에 표시
 현재 마우스의 위치를 Status Bar에 표시함
#include "MainFrm.h"
void CLecture161View::OnMouseMove(UINT nFlags, CPoint point)
{
CMainFrame *pFrame = (CMainFrame *) AfxGetMainWnd();
CString str;
str.Format("x = %d, y = %d",point.x, point.y);
pFrame->m_wndStatusBar.SetPaneText(2,str);
CView::OnMouseMove(nFlags, point);
}
• AfxGetMainWnd : 메인 프레임 원도우의 인스턴스 포인터를 얻어내는 함수
프로그래밍 응용 #16
5
Status Bar에 Stop Watch 시계 표시
UINT second = 0;
void CLecture161View::OnClockStart()
{
SetTimer(0,100,NULL);
}
void CLecture161View::OnTimer(UINT nIDEvent)
{
}
프로그래밍 응용 #16
6
Message Box
 int AfxMessageBox(string, UINT nType = MB_OK, UINT nIDHelp = 0);
• nType에 지정할 수 있는 type
MB_ABORTRETRYIGNORE
MB_ICONEXCLAMATION
MB_OK
MB_ICONINFORMATION
MB_OKCANCEL
MB_ICONQUESTION
MB_RETRYCANCEL
MB_ICONSTOP
MB_YESNO
ME_YESNOCANCEL
AfxMessageBox("메세지 박스 테스트",MB_OK);
AfxMessageBox("메세지 박스 테스트",MB_YESNO | MB_ICONQUESTION);
프로그래밍 응용 #16
7
Message Box
 Return Value
• IDABORT, IDCANCEL,IDIGNORE,IDNO,IDOK,IDRETRY,IDYES
if ( AfxMessageBox(“test”,MB_YESNO) == IDYES) {
…
}
프로그래밍 응용 #16
8