Visual C++ 6 | Example of a simple MFC application not using the wizard.

preview_player
Показать описание
Simple MFC application without using the MFC wizard on Visual C++ 6.
Based on the video "MFC Interfaces - Creating Simple Hand-crafted (hacked) MFC Interfaces for C++ Programs" by OneByteAtATime
Music: Eternity Lofi Melody Loop 1 - 75 BPM G# Min by Cymatics
Source Code:
#include ⋖afxwin.h⋗
#include "resource.h"
//---------------------------------------
// Globals
CEdit * pINPUT;
CEdit * pOUTPUT;
CButton * pSTART;

class GAME_FORM : public CDialog
{
public:
GAME_FORM(CWnd* pParent = NULL) : CDialog(GAME_FORM::IDD, pParent) {};
//Dialog data, name of dialog here
enum { IDD = INTERFACE1 };

protected:
virtual void DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); };
//Called right after constructor. Initialize things here
virtual BOOL OnInitDialog()
{
CDialog::OnInitDialog();

pINPUT = (CEdit *)GetDlgItem(CE_INPUT);
pOUTPUT = (CEdit *)GetDlgItem(CE_OUTPUT);
pSTART = (CButton *)GetDlgItem(CB_START);

pINPUT-⋗SetWindowText("Type HERE!");
pOUTPUT-⋗SetWindowText("Click \"START\" to begin!");
return true;
}

public:
//---------------------------------------------
afx_msg void start() { STARTBUTTON(); }
//---------------------------------------------
void STARTBUTTON()
{
MessageBox("BYE!");
pSTART-⋗EnableWindow(false);
}
DECLARE_MESSAGE_MAP()
};
//--------------------------------------------------

//Actual App
class TheGame : public CWinApp
{
public:
TheGame() {};
virtual BOOL InitInstance()
{
CWinApp::InitInstance();
GAME_FORM dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
return false;
}
};

//---------------------------------------------
//Need a Message Map Macro for both CDialog and CWinApp
BEGIN_MESSAGE_MAP(GAME_FORM, CDialog)
ON_COMMAND(CB_START, start)
END_MESSAGE_MAP()
//---------------------------------------------

//Start application
TheGame theApp;

#c++
#visual c++
#visual c++ 6
#visual studio
#visual studio 6
#MFC
#wizard
#no bloated
#bloated
#mfc example
Рекомендации по теме
welcome to shbcf.ru