now MSW stuff is complete
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
71
samples/mfc/makefile.b32
Normal file
71
samples/mfc/makefile.b32
Normal file
@@ -0,0 +1,71 @@
|
||||
#
|
||||
# File: makefile.bcc
|
||||
# Author: Andre Beltman
|
||||
# Created: 1995
|
||||
# Updated:
|
||||
# Copyright: (c) 1995, AIAI, University of Edinburgh
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile : Builds mfc example (DOS).
|
||||
|
||||
# WXWIN and BCCDIR are set by parent make
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
!include $(WXDIR)\src\makeb32.env
|
||||
|
||||
WXLIBDIR = $(WXDIR)\lib
|
||||
WXINC = $(WXDIR)\include\msw
|
||||
WXBASESRC = $(WXDIR)\src\base
|
||||
WXBASEINC = $(WXDIR)\include\base
|
||||
WXLIB = $(WXLIBDIR)\wx32.lib
|
||||
FAFALIB = $(WXLIBDIR)\fafa.lib
|
||||
ITSYLIB = $(WXLIBDIR)\itsy.lib
|
||||
XPMLIB = $(WXLIBDIR)\xpm.lib
|
||||
DIBLIB = $(WXLIBDIR)\dib.lib
|
||||
GAUGELIB = $(WXLIBDIR)\gauge.lib
|
||||
WXTREELIB = $(WXLIBDIR)\wxtree.lib
|
||||
RCPARSERLIB = $(WXLIBDIR)\rcparser.lib
|
||||
PROLOGLIB = $(WXLIBDIR)\prologio.lib
|
||||
LIBS=$(WXLIB) cw32 import32 ctl3d32 $(FAFALIB) $(ITSYLIB) $(DIBLIB)\
|
||||
$(XPMLIB) $(PROLOGLIB) $(RCPARSERLIB) $(GAUGELIB) $(WXTREELIB)
|
||||
|
||||
TARGET=hello
|
||||
|
||||
!if "$(FINAL)" == "0"
|
||||
LINKFLAGS=/v /Tpe /L$(WXLIBDIR);$(BCCDIR)\lib
|
||||
OPT = -Od
|
||||
DEBUG_FLAGS= -v
|
||||
!else
|
||||
LINKFLAGS=/Tpe /L$(WXLIBDIR);$(BCCDIR)\lib
|
||||
OPT = -Od
|
||||
DEBUG_FLAGS =
|
||||
!endif
|
||||
CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG)
|
||||
|
||||
OBJECTS = hello.obj
|
||||
|
||||
$(TARGET).exe: $(OBJECTS) $(TARGET).def $(TARGET).res
|
||||
tlink32 $(LINKFLAGS) @&&!
|
||||
c0w32.obj $(OBJECTS)
|
||||
$(TARGET)
|
||||
nul
|
||||
$(LIBS)
|
||||
$(TARGET).def
|
||||
!
|
||||
brc32 -K $(TARGET).res
|
||||
|
||||
.$(SRCSUFF).obj:
|
||||
bcc32 $(CPPFLAGS) -c {$< }
|
||||
|
||||
.c.obj:
|
||||
bcc32 $(CPPFLAGS) -P- -c {$< }
|
||||
|
||||
hello.obj: hello.$(SRCSUFF)
|
||||
|
||||
$(TARGET).res : $(TARGET).rc $(WXDIR)\include\msw\wx.rc
|
||||
brc32 -r /i$(BCCDIR)\include /i$(WXDIR)\include\msw /i$(WXDIR)\contrib\fafa $(TARGET)
|
||||
|
||||
clean:
|
||||
-erase *.obj *.exe *.res *.map *.rws
|
||||
|
76
samples/mfc/makefile.bcc
Normal file
76
samples/mfc/makefile.bcc
Normal file
@@ -0,0 +1,76 @@
|
||||
#
|
||||
# File: makefile.bcc
|
||||
# Author: Julian Smart
|
||||
# Created: 1993
|
||||
# Updated:
|
||||
# Copyright: (c) 1993, AIAI, University of Edinburgh
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile : Builds mfc example (DOS).
|
||||
|
||||
!if "$(BCCDIR)" == ""
|
||||
!error You must define the BCCDIR variable in autoexec.bat, e.g. BCCDIR=d:\bc4
|
||||
!endif
|
||||
|
||||
!if "$(WXWIN)" == ""
|
||||
!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx
|
||||
!endif
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
!include $(WXDIR)\src\makebcc.env
|
||||
|
||||
THISDIR = $(WXDIR)\samples\mfc
|
||||
WXLIB = $(WXDIR)\lib\wx.lib
|
||||
|
||||
LIBS=$(WXLIB) mathwl cwl import
|
||||
INC=-I$(WXDIR)\include\base -I$(WXDIR)\include\msw
|
||||
CFG=$(WXDIR)\src\wxwin.cfg
|
||||
|
||||
!ifndef FINAL
|
||||
FINAL=0
|
||||
!endif
|
||||
|
||||
!if "$(FINAL)" == "0"
|
||||
LINKFLAGS=/v/Vt /Twe /L$(WXDIR)\lib;$(BCCDIR)\lib
|
||||
OPT = -Od
|
||||
DEBUG_FLAGS= -v
|
||||
!else
|
||||
LINKFLAGS=/Twe /L$(WXDIR)\lib;$(BCCDIR)\lib
|
||||
OPT = -O2
|
||||
DEBUG_FLAGS =
|
||||
!endif
|
||||
CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG)
|
||||
|
||||
HEADERS = hello.h
|
||||
SOURCES = hello.$(SRCSUFF)
|
||||
OBJECTS = hello.obj
|
||||
|
||||
hello: hello.exe
|
||||
|
||||
all: hello.exe
|
||||
|
||||
hello.exe: $(WXLIB) hello.obj hello.def hello.res
|
||||
tlink $(LINKFLAGS) @&&!
|
||||
c0wl.obj hello.obj
|
||||
hello
|
||||
nul
|
||||
$(LIBS)
|
||||
hello.def
|
||||
!
|
||||
rc -30 -K hello.res
|
||||
|
||||
.$(SRCSUFF).obj:
|
||||
bcc $(CPPFLAGS) -c {$< }
|
||||
|
||||
hello.obj: hello.$(SRCSUFF)
|
||||
|
||||
hello.res : hello.rc $(WXDIR)\include\msw\wx.rc
|
||||
rc -r /i$(BCCDIR)\include /i$(WXDIR)\include\msw /i$(WXDIR)\contrib\fafa hello
|
||||
|
||||
clean:
|
||||
-erase *.obj
|
||||
-erase *.exe
|
||||
-erase *.res
|
||||
-erase *.map
|
||||
-erase *.rws
|
89
samples/mfc/makefile.dos
Normal file
89
samples/mfc/makefile.dos
Normal file
@@ -0,0 +1,89 @@
|
||||
#
|
||||
# File: makefile.dos
|
||||
# Author: Julian Smart
|
||||
# Created: 1993
|
||||
# Updated:
|
||||
# Copyright: (c) 1993, AIAI, University of Edinburgh
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile : Builds MFC compatibility example (DOS).
|
||||
# Use FINAL=1 argument to nmake to build final version with no debugging
|
||||
# info.
|
||||
|
||||
# Set WXDIR for your system
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
!include $(WXDIR)\src\makemsc.env
|
||||
|
||||
THISDIR = $(WXDIR)\samples\mfc
|
||||
WXLIB = $(WXDIR)\lib\wx.lib
|
||||
MFCINC = c:\msvc\mfc\include
|
||||
LIBS=lafxcwD $(WXLIB) oldnames libw llibcew commdlg ddeml shell mmsystem # mfcoleui compobj storage ole2 ole2disp
|
||||
#LIBS=lafxcwD llibcew libw commdlg shell
|
||||
INC=-I$(MFCINC) -I$(WXDIR)\include\base -I$(WXDIR)\include\msw
|
||||
DUMMY=$(WXDIR)\src\msw\dummy.obj
|
||||
|
||||
# Set this to nothing if using MS C++ 7
|
||||
ZOPTION=/Z7
|
||||
|
||||
!ifndef FINAL
|
||||
FINAL=0
|
||||
!endif
|
||||
|
||||
PRECOMP = # /YuWX_PREC.H /Fp$(WXDIR)\src\msw\wx.pch
|
||||
|
||||
!if "$(FINAL)" == "0"
|
||||
CPPFLAGS=/D_DEBUG /AL /W3 /Zi $(ZOPTION) /G2sw /Od $(INC) $(PRECOMP) /Dwx_msw
|
||||
#CPPFLAGS=/AL /Zp /GA /G2 /Gyf /Od /W3 $(INC) /D_DEBUG
|
||||
LINKFLAGS=/NOD /CO /NOE /ONERROR:NOEXE /SEG:256 /STACK:12000
|
||||
!else
|
||||
CPPFLAGS=/AL /W3 /G2sw $(INC) /Ox $(PRECOMP) /Dwx_msw
|
||||
LINKFLAGS=/NOD /NOE /ONERROR:NOEXE /SEG:256
|
||||
!endif
|
||||
|
||||
HEADERS = hello.h
|
||||
SOURCES = hello.$(SRCSUFF)
|
||||
OBJECTS = hello.obj
|
||||
|
||||
hello: hello.exe
|
||||
|
||||
all: wx hello.exe
|
||||
|
||||
wx:
|
||||
cd $(WXDIR)\src\msw
|
||||
nmake -f makefile.dos FINAL=$(FINAL)
|
||||
cd $(THISDIR)
|
||||
|
||||
wxclean:
|
||||
cd $(WXDIR)\src\msw
|
||||
nmake -f makefile.dos clean
|
||||
cd $(THISDIR)
|
||||
|
||||
|
||||
hello.exe: $(DUMMY) $(WXLIB) hello.obj hello.def hello.res
|
||||
link $(LINKFLAGS) @<<
|
||||
$(DUMMY) hello.obj,
|
||||
hello,
|
||||
NUL,
|
||||
$(LIBS),
|
||||
hello.def
|
||||
;
|
||||
<<
|
||||
rc -31 -K hello.res
|
||||
|
||||
hello.obj: hello.h hello.$(SRCSUFF) $(DUMMY)
|
||||
cl @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
hello.res : hello.rc $(WXDIR)\include\msw\wx.rc
|
||||
rc -r /i$(MFCINC) /i$(WXDIR)\include\msw /i$(WXDIR)\contrib\fafa hello
|
||||
|
||||
clean:
|
||||
-erase *.obj
|
||||
-erase *.sbr
|
||||
-erase *.exe
|
||||
-erase *.res
|
||||
-erase *.map
|
||||
-erase *.pdb
|
66
samples/mfc/makefile.nt
Normal file
66
samples/mfc/makefile.nt
Normal file
@@ -0,0 +1,66 @@
|
||||
#
|
||||
# File: makefile.nt
|
||||
# Author: Julian Smart
|
||||
# Created: 1993
|
||||
# Updated:
|
||||
# Copyright: (c) 1993, AIAI, University of Edinburgh
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile : Builds MFC/wxWin example (MS VC++).
|
||||
# Use FINAL=1 argument to nmake to build final version with no debugging
|
||||
# info
|
||||
|
||||
# Set WXDIR for your system
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
EXTRALIBS=# mfc42.lib
|
||||
EXTRAINC=-Ig:\DevStudio\mfc\include
|
||||
EXTRAFLAGS=/D_AFXDLL
|
||||
|
||||
!include $(WXDIR)\src\ntwxwin.mak
|
||||
|
||||
THISDIR = $(WXDIR)\samples\mfc
|
||||
PROGRAM=mfctest
|
||||
|
||||
OBJECTS = $(PROGRAM).obj
|
||||
|
||||
$(PROGRAM): $(PROGRAM).exe
|
||||
|
||||
all: wx $(PROGRAM).exe
|
||||
|
||||
wx:
|
||||
cd $(WXDIR)\src\msw
|
||||
nmake -f makefile.nt FINAL=$(FINAL)
|
||||
cd $(THISDIR)
|
||||
|
||||
wxclean:
|
||||
cd $(WXDIR)\src\msw
|
||||
nmake -f makefile.nt clean
|
||||
cd $(THISDIR)
|
||||
|
||||
$(PROGRAM).exe: $(DUMMYOBJ) $(WXLIB) $(OBJECTS) $(PROGRAM).res
|
||||
$(link) @<<
|
||||
-out:$(PROGRAM).exe
|
||||
$(LINKFLAGS)
|
||||
$(DUMMYOBJ) $(OBJECTS) $(PROGRAM).res
|
||||
$(LIBS)
|
||||
<<
|
||||
|
||||
|
||||
$(PROGRAM).obj: $(PROGRAM).h $(PROGRAM).$(SRCSUFF) $(DUMMYOBJ)
|
||||
$(cc) @<<
|
||||
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||
<<
|
||||
|
||||
$(PROGRAM).res : $(PROGRAM).rc $(WXDIR)\include\wx\msw\wx.rc
|
||||
$(rc) -r /i$(WXDIR)\include -fo$@ $(PROGRAM).rc
|
||||
|
||||
clean:
|
||||
-erase *.obj
|
||||
-erase *.sbr
|
||||
-erase *.exe
|
||||
-erase *.res
|
||||
-erase *.map
|
||||
-erase *.pdb
|
||||
|
47
samples/mfc/makefile.wat
Normal file
47
samples/mfc/makefile.wat
Normal file
@@ -0,0 +1,47 @@
|
||||
#
|
||||
# Makefile for WATCOM
|
||||
#
|
||||
# Created by D.Chubraev, chubraev@iem.ee.ethz.ch
|
||||
# 8 Nov 1994
|
||||
#
|
||||
|
||||
WXDIR = ..\..
|
||||
|
||||
!include $(WXDIR)\src\makewat.env
|
||||
|
||||
WXLIB = $(WXDIR)\lib
|
||||
NAME = hello
|
||||
LNK = $(name).lnk
|
||||
OBJS = $(name).obj
|
||||
|
||||
# Required for multi-threaded MFC apps
|
||||
EXTRACPPFLAGS = -bm -oaxt-zp4-ei-xs-zo-w3-bm-bt=nt -d_WINDOWS -d_MBCS
|
||||
refmain = _wstart2_
|
||||
|
||||
|
||||
PRECOMP=
|
||||
|
||||
all: $(name).exe
|
||||
|
||||
$(name).exe : $(OBJS) $(name).res $(LNK) $(WXLIB)\wx$(LEVEL).lib
|
||||
wlink @$(LNK)
|
||||
$(BINDCOMMAND) -d_MBCS $(name).res
|
||||
|
||||
$(name).res : $(name).rc $(WXDIR)\include\msw\wx.rc
|
||||
$(RC) $(RESFLAGS1) $(name).rc
|
||||
|
||||
$(LNK) : makefile.wat
|
||||
%create $(LNK)
|
||||
@%append $(LNK) debug all
|
||||
@%append $(LNK) system $(LINKOPTION)
|
||||
@%append $(LNK) $(MINDATA)
|
||||
@%append $(LNK) $(MAXDATA)
|
||||
@%append $(LNK) $(STACK)
|
||||
@%append $(LNK) name $(name)
|
||||
@%append $(LNK) file $(WXLIB)\wx$(LEVEL).lib
|
||||
@for %i in ($(EXTRALIBS)) do @%append $(LNK) file %i
|
||||
@for %i in ($(OBJS)) do @%append $(LNK) file %i
|
||||
|
||||
clean: .SYMBOLIC
|
||||
-erase *.obj *.bak *.err *.pch *.lib *.lnk *.res *.exe *.rex
|
||||
|
408
samples/mfc/mfctest.cpp
Normal file
408
samples/mfc/mfctest.cpp
Normal file
@@ -0,0 +1,408 @@
|
||||
// hello.cpp : Defines the class behaviors for the application.
|
||||
// Hello is a simple program which consists of a main window
|
||||
// and an "About" dialog which can be invoked by a menu choice.
|
||||
// It is intended to serve as a starting-point for new
|
||||
// applications.
|
||||
//
|
||||
// This is a part of the Microsoft Foundation Classes C++ library.
|
||||
// Copyright (C) 1992 Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// This source code is only intended as a supplement to the
|
||||
// Microsoft Foundation Classes Reference and Microsoft
|
||||
// WinHelp documentation provided with the library.
|
||||
// See these sources for detailed information regarding the
|
||||
// Microsoft Foundation Classes product.
|
||||
|
||||
// *** MODIFIED BY JULIAN SMART TO DEMONSTRATE CO-EXISTANCE WITH wxWINDOWS ***
|
||||
//
|
||||
// This sample pops up an initial wxWindows frame, with a menu item
|
||||
// that allows a new MFC window to be created. Note that CDummyWindow
|
||||
// is a class that allows a wxWindows window to be seen as a CWnd
|
||||
// for the purposes of specifying a valid main window to the
|
||||
// MFC initialisation.
|
||||
//
|
||||
// You can easily modify this code so that an MFC window pops up
|
||||
// initially as the main frame, and allows wxWindows frames to be
|
||||
// created subsequently:
|
||||
//
|
||||
// (1) Make MyApp::OnInit return NULL, not create a window.
|
||||
// (2) Restore the MFC code to create a window in InitInstance, and remove
|
||||
// creation of CDummyWindow.
|
||||
//
|
||||
// IMPORTANT NOTE: to compile this sample, you must first edit
|
||||
// wx/src/msw/wx_main.cc, set NOWINMAIN to 1, and remake wxWindows
|
||||
// (it only needs to recompile wx_main.cc).
|
||||
// This eliminates the duplicate WinMain function which MFC implements.
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#ifdef new
|
||||
#undef new
|
||||
#endif
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#ifdef DrawText
|
||||
#undef DrawText
|
||||
#endif
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#include "mfctest.h"
|
||||
|
||||
#include "wx/wx.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// theApp:
|
||||
// Just creating this application object runs the whole application.
|
||||
//
|
||||
CTheApp theApp;
|
||||
|
||||
// wxWindows elements
|
||||
|
||||
// Define a new application type
|
||||
class MyApp: public wxApp
|
||||
{ public:
|
||||
bool OnInit(void);
|
||||
wxFrame *CreateFrame(void);
|
||||
};
|
||||
|
||||
DECLARE_APP(MyApp)
|
||||
|
||||
class MyCanvas: public wxScrolledWindow
|
||||
{
|
||||
public:
|
||||
MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size);
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnMouseEvent(wxMouseEvent& event);
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
class MyChild: public wxFrame
|
||||
{
|
||||
public:
|
||||
MyCanvas *canvas;
|
||||
MyChild(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
|
||||
~MyChild(void);
|
||||
Bool OnClose(void);
|
||||
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
void OnNew(wxCommandEvent& event);
|
||||
void OnActivate(wxActivateEvent& event);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
// For drawing lines in a canvas
|
||||
long xpos = -1;
|
||||
long ypos = -1;
|
||||
|
||||
// Initialise this in OnInit, not statically
|
||||
wxPen *red_pen;
|
||||
wxFont *small_font;
|
||||
|
||||
// ID for the menu quit command
|
||||
#define HELLO_QUIT 1
|
||||
#define HELLO_NEW 2
|
||||
|
||||
DECLARE_APP(MyApp)
|
||||
IMPLEMENT_APP(MyApp)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// CMainWindow constructor:
|
||||
// Create the window with the appropriate style, size, menu, etc.
|
||||
//
|
||||
CMainWindow::CMainWindow()
|
||||
{
|
||||
LoadAccelTable( "MainAccelTable" );
|
||||
Create( NULL, "Hello Foundation Application",
|
||||
WS_OVERLAPPEDWINDOW, rectDefault, NULL, "MainMenu" );
|
||||
}
|
||||
|
||||
// OnPaint:
|
||||
// This routine draws the string "Hello, Windows!" in the center of the
|
||||
// client area. It is called whenever Windows sends a WM_PAINT message.
|
||||
// Note that creating a CPaintDC automatically does a BeginPaint and
|
||||
// an EndPaint call is done when it is destroyed at the end of this
|
||||
// function. CPaintDC's constructor needs the window (this).
|
||||
//
|
||||
void CMainWindow::OnPaint()
|
||||
{
|
||||
CString s = "Hello, Windows!";
|
||||
CPaintDC dc( this );
|
||||
CRect rect;
|
||||
|
||||
GetClientRect( rect );
|
||||
dc.SetTextAlign( TA_BASELINE | TA_CENTER );
|
||||
dc.SetTextColor( ::GetSysColor( COLOR_WINDOWTEXT ) );
|
||||
dc.SetBkMode(TRANSPARENT);
|
||||
dc.TextOut( ( rect.right / 2 ), ( rect.bottom / 2 ),
|
||||
s, s.GetLength() );
|
||||
}
|
||||
|
||||
// OnAbout:
|
||||
// This member function is called when a WM_COMMAND message with an
|
||||
// IDM_ABOUT code is received by the CMainWindow class object. The
|
||||
// message map below is responsible for this routing.
|
||||
//
|
||||
// We create a ClDialog object using the "AboutBox" resource (see
|
||||
// hello.rc), and invoke it.
|
||||
//
|
||||
void CMainWindow::OnAbout()
|
||||
{
|
||||
CDialog about( "AboutBox", this );
|
||||
about.DoModal();
|
||||
}
|
||||
|
||||
void CMainWindow::OnTest()
|
||||
{
|
||||
wxMessageBox("This is a wxWindows message box.\nWe're about to create a new wxWindows frame.", "wxWindows", wxOK);
|
||||
wxGetApp().CreateFrame();
|
||||
}
|
||||
|
||||
// CMainWindow message map:
|
||||
// Associate messages with member functions.
|
||||
//
|
||||
// It is implied that the ON_WM_PAINT macro expects a member function
|
||||
// "void OnPaint()".
|
||||
//
|
||||
// It is implied that members connected with the ON_COMMAND macro
|
||||
// receive no arguments and are void of return type, e.g., "void OnAbout()".
|
||||
//
|
||||
BEGIN_MESSAGE_MAP( CMainWindow, CFrameWnd )
|
||||
//{{AFX_MSG_MAP( CMainWindow )
|
||||
ON_WM_PAINT()
|
||||
ON_COMMAND( IDM_ABOUT, OnAbout )
|
||||
ON_COMMAND( IDM_TEST, OnTest )
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CTheApp
|
||||
|
||||
// InitInstance:
|
||||
// When any CTheApp object is created, this member function is automatically
|
||||
// called. Any data may be set up at this point.
|
||||
//
|
||||
// Also, the main window of the application should be created and shown here.
|
||||
// Return TRUE if the initialization is successful.
|
||||
//
|
||||
BOOL CTheApp::InitInstance()
|
||||
{
|
||||
TRACE( "HELLO WORLD\n" );
|
||||
|
||||
SetDialogBkColor(); // hook gray dialogs (was default in MFC V1)
|
||||
|
||||
wxEntry((WXHINSTANCE) m_hInstance, (WXHINSTANCE) m_hPrevInstance, m_lpCmdLine, m_nCmdShow, FALSE);
|
||||
|
||||
/*
|
||||
m_pMainWnd = new CMainWindow();
|
||||
m_pMainWnd->ShowWindow( m_nCmdShow );
|
||||
m_pMainWnd->UpdateWindow();
|
||||
*/
|
||||
|
||||
if (wxTheApp && wxTheApp->GetTopWindow())
|
||||
{
|
||||
m_pMainWnd = new CDummyWindow((HWND) wxTheApp->GetTopWindow()->GetHWND());
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int CTheApp::ExitInstance()
|
||||
{
|
||||
wxApp::CleanUp();
|
||||
|
||||
return CWinApp::ExitInstance();
|
||||
}
|
||||
|
||||
// Override this to provide wxWindows message loop
|
||||
// compatibility
|
||||
|
||||
BOOL CTheApp::PreTranslateMessage(MSG *msg)
|
||||
{
|
||||
if (wxTheApp && wxTheApp->ProcessMessage((WXMSG*) msg))
|
||||
return TRUE;
|
||||
else
|
||||
return CWinApp::PreTranslateMessage(msg);
|
||||
}
|
||||
|
||||
BOOL CTheApp::OnIdle(LONG lCount)
|
||||
{
|
||||
if (wxTheApp)
|
||||
return wxTheApp->ProcessIdle();
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* wxWindows elements
|
||||
********************************************************************/
|
||||
|
||||
bool MyApp::OnInit(void)
|
||||
{
|
||||
// Don't exit app when the top level frame is deleted
|
||||
// SetExitOnFrameDelete(FALSE);
|
||||
|
||||
// Create a red pen
|
||||
red_pen = new wxPen("RED", 3, wxSOLID);
|
||||
|
||||
// Create a small font
|
||||
small_font = new wxFont(10, wxSWISS, wxNORMAL, wxNORMAL);
|
||||
|
||||
wxFrame* frame = CreateFrame();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxFrame *MyApp::CreateFrame(void)
|
||||
{
|
||||
MyChild *subframe = new MyChild(NULL, "Canvas Frame", wxPoint(10, 10), wxSize(300, 300),
|
||||
wxDEFAULT_FRAME);
|
||||
|
||||
subframe->SetTitle("wxWindows canvas frame");
|
||||
|
||||
// Give it a status line
|
||||
subframe->CreateStatusBar();
|
||||
|
||||
// Make a menubar
|
||||
wxMenu *file_menu = new wxMenu;
|
||||
|
||||
file_menu->Append(HELLO_NEW, "&New MFC Window");
|
||||
file_menu->Append(HELLO_QUIT, "&Close");
|
||||
|
||||
wxMenuBar *menu_bar = new wxMenuBar;
|
||||
|
||||
menu_bar->Append(file_menu, "&File");
|
||||
|
||||
// Associate the menu bar with the frame
|
||||
subframe->SetMenuBar(menu_bar);
|
||||
|
||||
int width, height;
|
||||
subframe->GetClientSize(&width, &height);
|
||||
|
||||
MyCanvas *canvas = new MyCanvas(subframe, wxPoint(0, 0), wxSize(width, height));
|
||||
wxCursor *cursor = new wxCursor(wxCURSOR_PENCIL);
|
||||
canvas->SetCursor(cursor);
|
||||
subframe->canvas = canvas;
|
||||
|
||||
// Give it scrollbars
|
||||
// canvas->SetScrollbars(20, 20, 50, 50, 4, 4);
|
||||
|
||||
subframe->Show(TRUE);
|
||||
// Return the main frame window
|
||||
return subframe;
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
|
||||
EVT_PAINT(MyCanvas::OnPaint)
|
||||
EVT_MOUSE_EVENTS(MyCanvas::OnMouseEvent)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// Define a constructor for my canvas
|
||||
MyCanvas::MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size):
|
||||
wxScrolledWindow(parent, -1, pos, size)
|
||||
{
|
||||
}
|
||||
|
||||
// Define the repainting behaviour
|
||||
void MyCanvas::OnPaint(wxPaintEvent& event)
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
|
||||
dc.SetFont(small_font);
|
||||
dc.SetPen(wxGREEN_PEN);
|
||||
dc.DrawLine(0, 0, 200, 200);
|
||||
dc.DrawLine(200, 0, 0, 200);
|
||||
|
||||
dc.SetBrush(wxCYAN_BRUSH);
|
||||
dc.SetPen(wxRED_PEN);
|
||||
dc.DrawRectangle(100, 100, 100, 50);
|
||||
dc.DrawRoundedRectangle(150, 150, 100, 50, 20);
|
||||
|
||||
dc.DrawEllipse(250, 250, 100, 50);
|
||||
dc.DrawSpline(50, 200, 50, 100, 200, 10);
|
||||
dc.DrawLine(50, 230, 200, 230);
|
||||
dc.DrawText("This is a test string", 50, 230);
|
||||
}
|
||||
|
||||
// This implements a tiny doodling program! Drag the mouse using
|
||||
// the left button.
|
||||
void MyCanvas::OnMouseEvent(wxMouseEvent& event)
|
||||
{
|
||||
wxClientDC dc(this);
|
||||
dc.SetPen(wxBLACK_PEN);
|
||||
long x, y;
|
||||
event.Position(&x, &y);
|
||||
if (xpos > -1 && ypos > -1 && event.Dragging())
|
||||
{
|
||||
dc.DrawLine(xpos, ypos, x, y);
|
||||
}
|
||||
xpos = x;
|
||||
ypos = y;
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(MyChild, wxFrame)
|
||||
EVT_MENU(HELLO_QUIT, MyChild::OnQuit)
|
||||
EVT_MENU(HELLO_NEW, MyChild::OnNew)
|
||||
EVT_ACTIVATE(MyChild::OnActivate)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
MyChild::MyChild(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size, const long style):
|
||||
wxFrame(frame, -1, title, pos, size, style)
|
||||
{
|
||||
canvas = NULL;
|
||||
}
|
||||
|
||||
MyChild::~MyChild(void)
|
||||
{
|
||||
}
|
||||
|
||||
void MyChild::OnQuit(wxCommandEvent& event)
|
||||
{
|
||||
Close(TRUE);
|
||||
}
|
||||
|
||||
void MyChild::OnNew(wxCommandEvent& event)
|
||||
{
|
||||
CMainWindow *mainWin = new CMainWindow();
|
||||
mainWin->ShowWindow( TRUE );
|
||||
mainWin->UpdateWindow();
|
||||
}
|
||||
|
||||
void MyChild::OnActivate(wxActivateEvent& event)
|
||||
{
|
||||
if (event.GetActive() && canvas)
|
||||
canvas->SetFocus();
|
||||
}
|
||||
|
||||
Bool MyChild::OnClose(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
// Dummy MFC window for specifying a valid main window to MFC, using
|
||||
// a wxWindows HWND.
|
||||
CDummyWindow::CDummyWindow(HWND hWnd):CWnd()
|
||||
{
|
||||
Attach(hWnd);
|
||||
}
|
||||
|
||||
// Don't let the CWnd destructor delete the HWND
|
||||
CDummyWindow::~CDummyWindow(void)
|
||||
{
|
||||
Detach();
|
||||
}
|
||||
|
21
samples/mfc/mfctest.def
Normal file
21
samples/mfc/mfctest.def
Normal file
@@ -0,0 +1,21 @@
|
||||
; hello.def : Declares the module parameters for the application.
|
||||
;
|
||||
; This is a part of the Microsoft Foundation Classes C++ library.
|
||||
; Copyright (C) 1992 Microsoft Corporation
|
||||
; All rights reserved.
|
||||
;
|
||||
; This source code is only intended as a supplement to the
|
||||
; Microsoft Foundation Classes Reference and Microsoft
|
||||
; WinHelp documentation provided with the library.
|
||||
; See these sources for detailed information regarding the
|
||||
; Microsoft Foundation Classes product.
|
||||
|
||||
NAME Hello
|
||||
DESCRIPTION 'Hello Microsoft Foundation Classes Windows Application'
|
||||
|
||||
EXETYPE WINDOWS
|
||||
|
||||
CODE PRELOAD MOVEABLE DISCARDABLE
|
||||
DATA PRELOAD MOVEABLE MULTIPLE
|
||||
|
||||
HEAPSIZE 1024
|
66
samples/mfc/mfctest.h
Normal file
66
samples/mfc/mfctest.h
Normal file
@@ -0,0 +1,66 @@
|
||||
// hello.h : Declares the class interfaces for the application.
|
||||
// Hello is a simple program which consists of a main window
|
||||
// and an "About" dialog which can be invoked by a menu choice.
|
||||
// It is intended to serve as a starting-point for new
|
||||
// applications.
|
||||
//
|
||||
// This is a part of the Microsoft Foundation Classes C++ library.
|
||||
// Copyright (C) 1992 Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// This source code is only intended as a supplement to the
|
||||
// Microsoft Foundation Classes Reference and Microsoft
|
||||
// WinHelp documentation provided with the library.
|
||||
// See these sources for detailed information regarding the
|
||||
// Microsoft Foundation Classes product.
|
||||
|
||||
#ifndef __MFCTEST_H__
|
||||
#define __MFCTEST_H__
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// CMainWindow:
|
||||
// See hello.cpp for the code to the member functions and the message map.
|
||||
//
|
||||
class CMainWindow : public CFrameWnd
|
||||
{
|
||||
public:
|
||||
CMainWindow();
|
||||
|
||||
//{{AFX_MSG( CMainWindow )
|
||||
afx_msg void OnPaint();
|
||||
afx_msg void OnAbout();
|
||||
afx_msg void OnTest();
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
// A dummy CWnd pointing to a wxWindow's HWND
|
||||
class CDummyWindow: public CWnd
|
||||
{
|
||||
public:
|
||||
CDummyWindow(HWND hWnd);
|
||||
~CDummyWindow(void);
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// CTheApp:
|
||||
// See hello.cpp for the code to the InitInstance member function.
|
||||
//
|
||||
class CTheApp : public CWinApp
|
||||
{
|
||||
public:
|
||||
BOOL InitInstance();
|
||||
int ExitInstance();
|
||||
|
||||
// Override this to provide wxWindows message loop
|
||||
// compatibility
|
||||
BOOL PreTranslateMessage(MSG *msg);
|
||||
BOOL OnIdle(LONG lCount);
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // __MFCTEST_H__
|
BIN
samples/mfc/mfctest.ico
Normal file
BIN
samples/mfc/mfctest.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 766 B |
108
samples/mfc/mfctest.rc
Normal file
108
samples/mfc/mfctest.rc
Normal file
@@ -0,0 +1,108 @@
|
||||
//Microsoft App Studio generated resource script.
|
||||
//
|
||||
#include "wx/msw/wx.rc"
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
AFX_IDI_STD_FRAME ICON DISCARDABLE "MFCTEST.ICO"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
MAINMENU MENU DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "&Test wxWindows", IDM_TEST
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&About Hello...\tF1", IDM_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
MAINACCELTABLE ACCELERATORS MOVEABLE PURE
|
||||
BEGIN
|
||||
VK_F1, IDM_ABOUT, VIRTKEY
|
||||
END
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
ABOUTBOX DIALOG DISCARDABLE 34, 22, 144, 75
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "About Hello"
|
||||
FONT 8, "Helv"
|
||||
BEGIN
|
||||
CTEXT "Microsoft Windows",IDC_STATIC,0,5,144,8
|
||||
CTEXT "Microsoft Foundation Classes",IDC_STATIC,0,14,144,8
|
||||
CTEXT "Hello, Windows!",IDC_STATIC,0,23,144,8
|
||||
CTEXT "Version 2.0",IDC_STATIC,0,36,144,8
|
||||
DEFPUSHBUTTON "OK",IDOK,56,53,32,14,WS_GROUP
|
||||
END
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
18
samples/mfc/resource.h
Normal file
18
samples/mfc/resource.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// App Studio generated include file.
|
||||
// Used by HELLO.RC
|
||||
//
|
||||
#define IDM_ABOUT 100
|
||||
#define IDM_TEST 101
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
#define _APS_NEXT_RESOURCE_VALUE 110
|
||||
#define _APS_NEXT_COMMAND_VALUE 32768
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 112
|
||||
#endif
|
||||
#endif
|
12
samples/mfc/stdafx.h
Normal file
12
samples/mfc/stdafx.h
Normal file
@@ -0,0 +1,12 @@
|
||||
// This is a part of the Microsoft Foundation Classes C++ library.
|
||||
// Copyright (C) 1992 Microsoft Corporation
|
||||
// All rights reserved.
|
||||
//
|
||||
// This source code is only intended as a supplement to the
|
||||
// Microsoft Foundation Classes Reference and Microsoft
|
||||
// WinHelp documentation provided with the library.
|
||||
// See these sources for detailed information regarding the
|
||||
// Microsoft Foundation Classes product.
|
||||
|
||||
|
||||
#include <afxwin.h>
|
Reference in New Issue
Block a user