main.cpp
#include <afxwin.h> #include "res.h" class CMyDlg : public CDialog { public: CMyDlg(); enum { IDD = IDD_MAIN_DIALOG }; afx_msg void OnTest(); DECLARE_MESSAGE_MAP() }; BEGIN_MESSAGE_MAP(CMyDlg, CDialog) ON_BN_CLICKED(ID_TEST, OnTest) END_MESSAGE_MAP() void CMyDlg::OnTest() { AfxMessageBox("Test"); } CMyDlg::CMyDlg() : CDialog(CMyDlg::IDD) { } class CMyApp : public CWinApp { public: BOOL InitInstance(); }; CMyApp theApp; BOOL CMyApp::InitInstance() { CMyDlg dlg; m_pMainWnd = &dlg; dlg.DoModal(); return FALSE; }
main.rc
#include "res.h" #include "afxres.h" IDD_MAIN_DIALOG DIALOGEX 0, 0, 150, 100 STYLE DS_MODALFRAME | WS_VISIBLE EXSTYLE WS_EX_APPWINDOW CAPTION "main" FONT 8, "MS Sans Serif" BEGIN DEFPUSHBUTTON "Test",ID_TEST,10,10,50,30 END
res.h
#define IDD_MAIN_DIALOG 101 #define ID_TEST 102
編譯、執行
$ export WINEPREFIX=/home/user/.wine_x86 $ box86 wine nmake -f main.mak
完成