I have this bit of coding out of Ivor Horton's "Introduction to Microsoft Visual C++ 6.0". Book is great and everything but this is the extent of an actual Windows app. Anyone mind throwing out a little coding for a button that would do something simple like a MessageBox or changing the main window's title?
If anyone wouldn't mind giving an explanation of what's going on with things like "virtual BOOL InitInstance();" (what the hell is virtual?!) or the line "class COurApp : public CWinApp (what's with the public CWinApp after the colon?) it'd really be appreciated.PHP Code:#include <afxwin.h> // For the class library
// Window Class definition
class COurWnd : public CFrameWnd
{
};
// Application class definition
class COurApp : public CWinApp
{
public:
virtual BOOL InitInstance();
private:
COurWnd* GetMainWindow() { return static_cast<COurWnd*>(m_pMainWnd); }
};
// Function to create an instance of the main window
BOOL COurApp::InitInstance(void)
{
// Construct an object of our C++ window class
m_pMainWnd = new COurWnd;
// Call Create() to create the underlying window
GetMainWindow()->Create(NULL, _T("Our Simple Window"));
// Call ShowWindow() to display the window
GetMainWindow()->ShowWindow(m_nCmdShow);
return TRUE;
}
// Application object definition oat global scope
COurApp AnApplication;




Reply With Quote