home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tricks of the Windows Gam…ming Gurus (2nd Edition)
/
Disc2.iso
/
common
/
msdev98
/
bin
/
ide
/
statbar.dll
/
TEXTCODE
/
146
Wrap
Text File
|
1998-06-18
|
10KB
|
279 lines
###############################################################
## This file contains the code fragments that are included in
## the users' code. There are numerous constraints.
## o ## lines are processed.
## o Keywords such as:- (in all upper case!)
## access = [public | private | protected | dontcare]
## placement = [begin | end ]
## start <-- beginning of code
## stop <-- end of code
## o First line of code should be the prototype
## o Code completion should be with ## end
## o All other ## lines are discarded.
## o All lines outside of start/stop are discarded
###############################################################
###############################################################
## PROTECTED
## BEGIN
## START *-*-*-* OnMenuSelect *-*-*-*
afx_msg void %s::OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu)
BH %s::OnMenuSelect(nItemID, nFlags, hSysMenu);
BH
// CG: The following block was inserted by 'Status Bar' component.
{
// Restore first pane of the statusbar?
if (nFlags == 0xFFFF && hSysMenu == 0 && m_nStatusPane1Width != -1)
{
m_bMenuSelect = FALSE;
m_wndStatusBar.SetPaneInfo(0,
m_nStatusPane1ID, m_nStatusPane1Style, m_nStatusPane1Width);
m_nStatusPane1Width = -1; // Set it to illegal value
}
else
{
m_bMenuSelect = TRUE;
}
}
## STOP *-*-*-* OnMenuSelect *-*-*-*
##-------------------------------------------------------------
## PROTECTED
## BEGIN
## START *-*-*-* OnMenuSelect *-*-*-*
afx_msg void %s::OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu)
BH CMDIChildWnd::OnMenuSelect(nItemID, nFlags, hSysMenu);
BH
// CG: The following block was inserted by 'Status Bar' component.
{
static BOOL bMenuActive = FALSE;
if (bMenuActive || hSysMenu != NULL)
{
GetParentFrame()->PostMessage(WM_MENUSELECT,
MAKELONG(nItemID, nFlags), (LPARAM)hSysMenu);
}
bMenuActive = hSysMenu != NULL;
}
## STOP *-*-*-* OnMenuSelect *-*-*-*
###############################################################
###############################################################
## PROTECTED
## BEGIN
## START *-*-*-* OnInitMenuPopup *-*-*-*
afx_msg void %s::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
BH %s::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
BH
// CG: The following block was inserted by 'Status Bar' component.
{
// store width of first pane and its style
if (m_nStatusPane1Width == -1 && m_bMenuSelect)
{
m_wndStatusBar.GetPaneInfo(0, m_nStatusPane1ID,
m_nStatusPane1Style, m_nStatusPane1Width);
m_wndStatusBar.SetPaneInfo(0, m_nStatusPane1ID,
SBPS_NOBORDERS|SBPS_STRETCH, 16384);
}
}
## STOP *-*-*-* OnInitMenuPopup *-*-*-*
##-------------------------------------------------------------
## PROTECTED
## BEGIN
## START *-*-*-* OnInitMenuPopup *-*-*-*
afx_msg void %s::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
BH CMDIChildWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
BH
// CG: The following block was inserted by 'Status Bar' component.
{
GetParentFrame()->PostMessage(WM_INITMENUPOPUP,
(WPARAM)pPopupMenu->GetSafeHmenu(), MAKELONG(nIndex, bSysMenu));
}
## STOP *-*-*-* OnInitMenuPopup *-*-*-*
###############################################################
###############################################################
## PUBLIC
## BEGIN
## START *-*-*-* Constructor *-*-*-*
%s::%s()
// CG: The following block was inserted by 'Status Bar' component.
{
m_nStatusPane1Width = -1;
m_bMenuSelect = FALSE;
}
## STOP *-*-*-* Constructor *-*-*-*
###############################################################
###############################################################
## PUBLIC
## BEGIN
## START *-*-*-* InitInstance *-*-*-*
BOOL %s::InitInstance()
// CG: The following block was inserted by 'Status Bar' component.
{
//Set up date and time defaults so they're the same as system defaults
setlocale(LC_ALL, "");
}
## STOP *-*-*-* InitInstance *-*-*-*
###############################################################
###############################################################
## PROTECTED
## END
## START *-*-*-* OnCreate *-*-*-*
afx_msg int %s::OnCreate(LPCREATESTRUCT lpCreateStruct)
// CG: The following block was inserted by 'Status Bar' component.
{
// Find out the size of the static variable 'indicators' defined
// by AppWizard and copy it
int nOrigSize = sizeof(indicators) / sizeof(UINT);
UINT* pIndicators = new UINT[nOrigSize + 2];
memcpy(pIndicators, indicators, sizeof(indicators));
// Call the Status Bar Component's status bar creation function
if (!InitStatusBar(pIndicators, nOrigSize, 60))
{
TRACE0("Failed to initialize Status Bar\n");
return -1;
}
delete[] pIndicators;
}
## STOP *-*-*-* OnCreate *-*-*-*
##-------------------------------------------------------------
## PROTECTED
## END
## START *-*-*-* OnCreate *-*-*-*
afx_msg int %s::OnCreate(LPCREATESTRUCT lpCreateStruct)
// CG: The following block was inserted by 'Status Bar' component.
{
// Create an array for status bar indicators
UINT pIndicators[3] = { ID_SEPARATOR };
if (!m_wndStatusBar.Create(this) ||
!InitStatusBar(pIndicators, 1, 60))
{
TRACE0("Failed to create Status Bar\n");
return -1;
}
// TODO: If you have a call to EnableDocking() and DockControlBar()
// before this line, move them to right after this comment. This
// insures that the docking area remains above the status bar.
}
## STOP *-*-*-* OnCreate *-*-*-*
###############################################################
###############################################################
## PROTECTED
## BEGIN
## START *-*-*-* OnUpdateDate *-*-*-*
afx_msg void %s::OnUpdateDate(CCmdUI* pCmdUI)
// CG: This function was inserted by 'Status Bar' component.
// Get current date and format it
CTime time = CTime::GetCurrentTime();
CString strDate = time.Format(%s);
// BLOCK: compute the width of the date string
CSize size;
{
HGDIOBJ hOldFont = NULL;
HFONT hFont = (HFONT)m_wndStatusBar.SendMessage(WM_GETFONT);
CClientDC dc(NULL);
if (hFont != NULL)
hOldFont = dc.SelectObject(hFont);
size = dc.GetTextExtent(strDate);
if (hOldFont != NULL)
dc.SelectObject(hOldFont);
}
// Update the pane to reflect the current date
UINT nID, nStyle;
int nWidth;
m_wndStatusBar.GetPaneInfo(m_nDatePaneNo, nID, nStyle, nWidth);
m_wndStatusBar.SetPaneInfo(m_nDatePaneNo, nID, nStyle, size.cx);
pCmdUI->SetText(strDate);
pCmdUI->Enable(TRUE);
## STOP *-*-*-* OnUpdateDate *-*-*-*
###############################################################
###############################################################
## PROTECTED
## BEGIN
## START *-*-*-* OnUpdateTime *-*-*-*
afx_msg void %s::OnUpdateTime(CCmdUI* pCmdUI)
// CG: This function was inserted by 'Status Bar' component.
// Get current date and format it
CTime time = CTime::GetCurrentTime();
CString strTime = time.Format(%s);%s
// BLOCK: compute the width of the date string
CSize size;
{
HGDIOBJ hOldFont = NULL;
HFONT hFont = (HFONT)m_wndStatusBar.SendMessage(WM_GETFONT);
CClientDC dc(NULL);
if (hFont != NULL)
hOldFont = dc.SelectObject(hFont);
size = dc.GetTextExtent(strTime);
if (hOldFont != NULL)
dc.SelectObject(hOldFont);
}
// Update the pane to reflect the current time
UINT nID, nStyle;
int nWidth;
m_wndStatusBar.GetPaneInfo(m_nTimePaneNo, nID, nStyle, nWidth);
m_wndStatusBar.SetPaneInfo(m_nTimePaneNo, nID, nStyle, size.cx);
pCmdUI->SetText(strTime);
pCmdUI->Enable(TRUE);
## STOP *-*-*-* OnUpdateTime *-*-*-*
###############################################################
###############################################################
## PRIVATE
## BEGIN
## START *-*-*-* InitStatusBar *-*-*-*
BOOL %s::InitStatusBar(UINT *pIndicators, int nSize, int nSeconds)
// CG: This function was inserted by 'Status Bar' component.
## STOP *-*-*-* InitStatusBar *-*-*-*
###############################################################
## PRIVATE
## BEGIN
## START *-*-*-* InitStatusBar *-*-*-*
BOOL %s::InitStatusBar(UINT *pIndicators, int nSize, int nSeconds)
// Create an index for the DATE pane
m_nDatePaneNo = nSize++;
pIndicators[m_nDatePaneNo] = ID_INDICATOR_DATE;
## STOP *-*-*-* InitStatusBar *-*-*-*
##-------------------------------------------------------------
## PRIVATE
## BEGIN
## START *-*-*-* InitStatusBar *-*-*-*
BOOL %s::InitStatusBar(UINT *pIndicators, int nSize, int nSeconds)
// Create an index for the TIME pane
m_nTimePaneNo = nSize++;
nSeconds = %s;
pIndicators[m_nTimePaneNo] = ID_INDICATOR_TIME;
## STOP *-*-*-* InitStatusBar *-*-*-*
##-------------------------------------------------------------
## PRIVATE
## BEGIN
## START *-*-*-* InitStatusBar *-*-*-*
BOOL %s::InitStatusBar(UINT *pIndicators, int nSize, int nSeconds)
// TODO: Select an appropriate time interval for updating
// the status bar when idling.
m_wndStatusBar.SetTimer(0x1000, nSeconds * 1000, NULL);
return m_wndStatusBar.SetIndicators(pIndicators, nSize);
## STOP *-*-*-* InitStatusBar *-*-*-*
############################################################### `