[技术学习]在Linux平台学习Windows开发技术(二)----给MFC程序来个消息映射...

来个复杂点的MFC程序,加个消息映射和消息框。


Mak efile(注意Makefile进化了):

###########################################################################################
# Makefile for MFC Application with wineLib on Linux(Ubuntu 9.10)
# *****************************************************************************************
# * Previous steps:
# * 1. Install wine 1.1.35
# *wgethttp://ibiblio.org/pub/linux/system/emulators/wine/wine-1.1.35.tar.bz2
# *unzip && ./configure && install
# *
# *Q: configure: error: FreeType development files not found.
# * A:sudo apt-get installlibfreetype6-dev
# *
# * 2. Copy all the files of Vistual Studio 6 to wine directory.
# *
# * Notice:
# * When you make with this Makefile at first time,there are some errors about "err:module". Dont worry,make again,you will be success.
# *
# * Creator: [email protected]
# * Date:2010年 01月 03日 星期日 17:20:53 CST
# ****************************************************************************************

WINE = /home/thinkhy/work/wine/wine-1.1.35/wine


LINK = LINK.EXE
LFLAG = /subsystem:windows #/OPT:REF

CC = CL.EXE
CFLAG =/MT /c #/GX /D "_AFXDLL"


INCLUDE = /I. /I/home/thinkhy/.wine/drive_c/Program/ Files/Microsof/ Visual/ Studio/VC98/Include /
/I/home/thinkhy/.wine/drive_c/Program/ Files/Microsof/ Visual/ Studio/VC98/MFC/Include
LIB = /LIBPATH:/home/thinkhy/.wine/drive_c/Program/ Files/Microsof/ Visual/ Studio/VC98/Lib /LIBPATH:/home/thinkhy/.wine/drive_c/Program/ Files/Microsof/ Visual/ Studio/VC98/MFC/Lib

RES =
SRC = ./mfc2.cpp
OBJ = ./mfc2.obj
OUTFILE = mfc2.exe
OUTPUT = /OUT:$(OUTFILE)

all : compile link

compile : $(SRC)
$(WINE) $(CC) $(SRC) $(CFLAG) $(INCLUDE)

link : $(OBJ)
$(WINE) $(LINK) $(LFLAG) $(LIB) $(OBJ) $(RES) $(OUTPUT)

clean:
- rm $(OBJ)
- rm $(OUTFILE)
touch $(SRC)
###########################################################################################

测试文件

/* ***********************************************************
* File: mfc2.cpp
* Author: [email protected]
* Refer: http://www.codersource.net/mfc_tutorial_Part2.html
*********************************************************** */
// MFC2.cpp - MFC Tutorial Part 2 from CoderSource.net

#include "AFXWIN.H"

class MFC_Tutorial_Window :public CFrameWnd
{
public :
MFC_Tutorial_Window()
{
Create(NULL ,"MFC Tutorial Part 2 CoderSource Window" );
}

void OnLButtonDown(UINT nFlags, CPoint point);
DECLARE_MESSAGE_MAP()
};

BEGIN_MESSAGE_MAP(MFC_Tutorial_Window, CFrameWnd)
ON_WM_LBUTTONDOWN() // Macro to map the left button click to the handler
END_MESSAGE_MAP()

void MFC_Tutorial_Window::OnLButtonDown(UINT nFlags, CPoint point)
{
CFrameWnd::OnLButtonDown(nFlags, point);
MessageBox("Hello, World" );
}

class MyApp :public CWinApp
{
MFC_Tutorial_Window *wnd;
public :
BOOL InitInstance()
{
wnd = new MFC_Tutorial_Window();
m_pMainWnd = wnd;
m_pMainWnd->ShowWindow(1 );
return 1 ;
}
//CDialog cd;
};

MyApp theApp;
在窗口里左击,弹出一个MessageBox,COOL! 按扭中出现乱码的问题待明天解决。
[技术学习]在Linux平台学习Windows开发技术(二)----给MFC程序来个消息映射...
参考资料:http://www.codersource.net/mfc_tutorial_Part1.html