// MFC_Framework.h // NKU CSC 402 Kirby // ------------------------------------------------------------------ // A quick way to test your pixel-based algorithms for CSC 480. // Knowledge of MFC not required! // // You #include this file (once!) in your own file, and simply // provide an implementation of the function: // // void paint( CDC& dc, int width, int height ) ; // // To set/get a colored pixel in your paint() function, you call // // dc.SetPixel( x, y, RGB(r,g,b) ) ; // COLORREF c= dc.GetPixel( x, y ) ; // // where r,g,b range from 0 to 255. The width and height parameters // passed to your paint() are the dimensions of the drawing area, with // the origin (0,0) at the upper left. // // Build as a Win32 Windows (NOT Console) application. // Set Properties | General | Use of MFC: "Use MFC in a shared DLL" // ------------------------------------------------------------------ #define WINVER 0x400 // ok for Windows 2000 or later #include void paint( CDC& dc, int width, int height ) ; const int WINDOW_WIDTH= 700 ; const int WINDOW_HEIGHT= 500 ; class Frame : public CFrameWnd { public: Frame() { Create( NULL, "MFC Framework", WS_OVERLAPPEDWINDOW, CRect(0,0,WINDOW_WIDTH,WINDOW_HEIGHT) ) ; } private: int width, height ; protected: void OnPaint() { paint( CPaintDC( this ), width, height ) ; } void OnSize( UINT nType, int cx, int cy ) { width= cx ; height= cy ; } DECLARE_MESSAGE_MAP() } ; BEGIN_MESSAGE_MAP( Frame, CFrameWnd ) ON_WM_PAINT() ON_WM_SIZE() END_MESSAGE_MAP() struct App : public CWinApp { virtual BOOL InitInstance() { m_pMainWnd= new Frame ; m_pMainWnd->ShowWindow( m_nCmdShow ) ; m_pMainWnd->UpdateWindow() ; return true ; } } ; App app ;