home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
p
/
ptv3n5.zip
/
STATUS.ZIP
/
STATDEMO.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1992-08-28
|
2KB
|
89 lines
// Status bar demonstration by Tom Swan
#include <owl.h>
#include "status.h"
#include "statdemo.rch"
// The application class
class TStatusApp: public TApplication {
public:
TStatusApp(LPSTR AName, HINSTANCE AnInstance,
HINSTANCE APrevInstance, LPSTR ACmdLine, int ACmdShow)
: TApplication(AName, AnInstance, APrevInstance,
ACmdLine, ACmdShow) {};
virtual void InitMainWindow();
};
// Main window class
class TStatusWin: public TWindow {
PTStatusBar pStatusBar;
public:
TStatusWin(PTWindowsObject AParent, LPSTR ATitle);
virtual BOOL CanClose();
virtual void CMFileExit(RTMessage)
= [CM_FIRST + CM_FILE_EXIT];
virtual void WMSize(RTMessage)
= [WM_FIRST + WM_SIZE];
virtual void WMMenuSelect(RTMessage)
= [WM_FIRST + WM_MENUSELECT];
};
// Initialize TStatusApp's main window
void TStatusApp::InitMainWindow()
{
MainWindow = new TStatusWin(NULL, "Status Bar Demonstration");
}
// Construct main window object
TStatusWin::TStatusWin(PTWindowsObject AParent, LPSTR ATitle)
: TWindow(AParent, ATitle)
{
AssignMenu(ID_MENU);
Attr.X = GetSystemMetrics(SM_CXSCREEN) / 8;
Attr.Y = GetSystemMetrics(SM_CYSCREEN) / 8;
Attr.H = Attr.Y * 6;
Attr.W = Attr.X * 6;
pStatusBar = new TStatusBar(this);
if (pStatusBar == NULL)
Status = EM_INVALIDCHILD;
}
// Return TRUE if window can be closed
BOOL TStatusWin::CanClose()
{
pStatusBar->DisplayString(999); // On-line help message
int result = MessageBox(HWindow, "End program?", "StatDemo",
MB_ICONQUESTION | MB_YESNO) == IDYES;
pStatusBar->DisplayString(0); // Erase the message
return result;
}
// Respond to File|Exit command; exit program
void TStatusWin::CMFileExit(RTMessage)
{
CloseWindow();
}
// Resizing parent window; update child window
void TStatusWin::WMSize(RTMessage msg)
{
TWindow::WMSize(msg);
pStatusBar->AdjustSize(msg.LP.Lo, msg.LP.Hi);
}
// Notate menu selections by passing message to child window
void TStatusWin::WMMenuSelect(RTMessage msg)
{
SendMessage(pStatusBar->HWindow, WM_MENUSELECT,
msg.WParam, msg.LParam);
}
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)
{
TStatusApp StatusApp("StatusApp", hInstance, hPrevInstance,
lpszCmdLine, nCmdShow);
StatusApp.Run();
return StatusApp.Status;
}