#pragma once ///////////////////////////////////////////////////////////////////// // FrameWindow.h - Demonstrate how to use ATL Window Classes to // // build a framewindow application. // // // // Jim Fawcett, CSE775 - Distributed Objects, Spring 2007 // ///////////////////////////////////////////////////////////////////// /* * Module Operations * ================= * This project illustrates how to use the ATL Windows classes to * simplify the creation of a Framewindow that may host controls. * * Build Process * ============= * Required Files: * FrameWindow.h, FrameWindow.cpp, stdafx.h, * FrameWindow.ico, FrameWindow.rc, small.ico * * Build Command: * devenv FrameWindow.vcproj /rebuild debug * * Maintenance History * =================== * ver 1.0 : 27 Feb 07 * - first release */ #include "resource.h" class CMainWindow : public CWindowImpl { public: CMainWindow(); ~CMainWindow(); /////////////////////////////////////////////////////////////////// // msg map macros build a switch statment in a CWindowImpl equivalent // to WinProc, CWindowImpl::ProcessMessages(...) BEGIN_MSG_MAP(CMainWindow) MESSAGE_HANDLER(WM_CREATE, OnCreate ) MESSAGE_HANDLER(WM_PAINT, OnPaint ) MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButton) MESSAGE_HANDLER(WM_DESTROY, OnDestroy) MESSAGE_HANDLER(WM_SIZE, OnSize ) COMMAND_HANDLER(IDM_ABOUT, 0, OnAbout ) COMMAND_HANDLER(IDM_EXIT, 0, OnExit ) COMMAND_HANDLER(IDC_EDIT2, EN_CHANGE, OnEditChange) END_MSG_MAP() // private: /////////////////////////////////////////////// // state used to avoid recreating windows // artifacts as messages roll in HFONT font; COLORREF backgroundColor; PAINTSTRUCT ps; HDC hdc; HGDIOBJ oldfont; COLORREF oldcolor; /////////////////////////////////////////////// // state used to provide access to windows HINSTANCE hInst; // This executable HWND hEdit; // Framewindow HWND hEdit1; // First edit control HWND hEdit2; // secont edit control /////////////////////////////////////////////////////////////////// // Creates edit control HWND CreateEditControl( LPCTSTR text, int x, int y, int width, int height, short ID ); /////////////////////////////////////////////////////////////////// // msg handlers LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnLButton(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnAbout(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnExit(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); LRESULT OnEditChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); /////////////////////////////////////////////////////////////////// // helper function from atlctrls.h int GetLine(HWND hEdit, int nIndex, LPTSTR lpszBuffer, int nMaxLength) const; BOOL SetReadOnly(HWND hEdit, BOOL bReadOnly = TRUE); };