CWnd::MessageBox Fonksiyonu
CWnd sınıfının MessageBox üye fonksiyonu default argümanlara sahip olduğu için kullanılması kolay bir fonksiyondur.

int MessageBox(LPCTSTR lpszText, LPCTSTR lpszCaption = NULL,
UINT nType = MB_OK);
Sınıf Çalışması
İskelet MFC programını kullanarak ana pencerede farenin sol tuşuna basıldığında MessageBox fonksiyonu ile bir mesaj yazdırınız.

MESSAGEBOX.H

#ifndef _MESSAGEBOX_H_
#define _MESSAGEBOX_H_

class CGenericApp : public CWinApp {
public:
virtual BOOL InitInstance(void);
};

class CMainWnd : public CFrameWnd {
public:
CMainWnd(void);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
DECLARE_MESSAGE_MAP()
};

#endif
MESSAGEBOX.CPP

#include
#include “messagebox.h”

CGenericApp theApp;

BOOL CGenericApp::InitInstance(void)
{
m_pMainWnd = new CMainWnd();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}

BEGIN_MESSAGE_MAP(CMainWnd, CFrameWnd)
ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()

CMainWnd::CMainWnd(void)
{
Create(NULL, “LbuttonDown Uygulaması”, WS_OVERLAPPEDWINDOW);
}

void CMainWnd::OnLButtonDown(UINT nFlags, CPoint point)
{
MessageBox(”Mouse un Sol tuşuna basabildiniz”);