home *** CD-ROM | disk | FTP | other *** search
/ Windows Graphics Programming / Feng_Yuan_Win32_GDI_DirectX.iso / Samples / Chapt_05 / FrameWindow / FrameWindow.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-20  |  2.5 KB  |  74 lines

  1. //-----------------------------------------------------------------------------------//
  2. //              Windows Graphics Programming: Win32 GDI and DirectDraw               //
  3. //                             ISBN  0-13-086985-6                                   //
  4. //                                                                                   //
  5. //  Written            by  Yuan, Feng                             www.fengyuan.com   //
  6. //  Copyright (c) 2000 by  Hewlett-Packard Company                www.hp.com         //
  7. //  Published          by  Prentice Hall PTR, Prentice-Hall, Inc. www.phptr.com      //
  8. //                                                                                   //
  9. //  FileName   : frametest.cpp                                                         //
  10. //  Description: SDI frame window demo, Chapter 5                                    //
  11. //  Version    : 1.00.000, May 31, 2000                                              //
  12. //-----------------------------------------------------------------------------------//
  13.  
  14. #define STRICT
  15. #define WIN32_LEAN_AND_MEAN
  16.  
  17. #include <windows.h>
  18. #include <assert.h>
  19. #include <tchar.h>
  20.  
  21. #include "..\..\include\win.h"
  22. #include "..\..\include\Toolbar.h"
  23. #include "..\..\include\Canvas.h"
  24. #include "..\..\include\Status.h"
  25. #include "..\..\include\FrameWnd.h"
  26.  
  27. #include "Resource.h"
  28.  
  29.  
  30. const TBBUTTON tbButtons[] =
  31. {
  32.     { STD_FILENEW,     IDM_FILE_NEW,   TBSTATE_ENABLED, TBSTYLE_BUTTON, { 0, 0 }, IDS_FILENEW,   0 },
  33.     { STD_HELP,      IDM_APP_ABOUT,  TBSTATE_ENABLED, TBSTYLE_BUTTON, { 0, 0 }, IDS_HELPABOUT, 0 }
  34. };
  35.  
  36.  
  37. class KMyFrame : public KFrame
  38. {
  39.     void GetWndClassEx(WNDCLASSEX & wc)
  40.     {
  41.         KFrame::GetWndClassEx(wc);
  42.         wc.hIcon  = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_GRAPH));
  43.     }
  44.  
  45. public:
  46.     KMyFrame(HINSTANCE hInstance, const TBBUTTON * pButtons, int nCount,
  47.             KToolbar * pToolbar, KCanvas * pCanvas, KStatusWindow * pStatus) :
  48.         KFrame(hInstance, pButtons, nCount, pToolbar, pCanvas, pStatus)
  49.     {
  50.     }
  51.  
  52. };
  53.  
  54. int WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR lpCmd, int nShow)
  55. {
  56.     KToolbar       toolbar;
  57.     KCanvas        canvas;
  58.     KStatusWindow  status;
  59.  
  60.     KMyFrame       frame(hInst, tbButtons, 2, & toolbar, & canvas, & status);
  61.  
  62.     frame.CreateEx(0, _T("ClassName"), _T("Program Name"),
  63.                  WS_OVERLAPPEDWINDOW,
  64.                  CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 
  65.                  NULL, LoadMenu(hInst, MAKEINTRESOURCE(IDR_MAIN)), hInst);
  66.  
  67.     frame.ShowWindow(nShow);
  68.     frame.UpdateWindow();
  69.  
  70.     frame.MessageLoop();
  71.  
  72.     return 0;
  73. }
  74.