home *** CD-ROM | disk | FTP | other *** search
/ PC Administrator / spravce.iso / TaskModule / src / Mywindow.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-06-10  |  3.9 KB  |  106 lines

  1. // MyWindow.cpp: implementation of the CMyWindow class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. /*
  5. Copyright 2001 Anish Mistry. All rights reserved.
  6.  
  7. Redistribution and use in source and binary forms, with or without modification,
  8. are permitted provided that the following conditions are met:
  9.  
  10.    1. Redistributions of source code must retain the above copyright notice, 
  11.    this list of conditions and the following disclaimer.
  12.    2. Redistributions in binary form must reproduce the above copyright notice,
  13.    this list of conditions and the following disclaimer in the documentation 
  14.    and/or other materials provided with the distribution.
  15.  
  16. THIS SOFTWARE IS PROVIDED BY ANISH MISTRY ``AS IS'' AND ANY EXPRESS OR IMPLIED 
  17. WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 
  18. AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS 
  19. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  20. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  21. GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  22. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  23. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25.  
  26. The views and conclusions contained in the software and documentation are those
  27. of the authors and should not be interpreted as representing official policies,
  28. either expressed or implied, of the Anish Mistry or AM Productions.
  29.  
  30. * Variation of the FreeBSD License. http://www.freebsd.org/copyright/freebsd-license.html
  31. */
  32.  
  33. #include "stdafx.h"
  34. #include "MyWindow.h"
  35.  
  36. //////////////////////////////////////////////////////////////////////
  37. // Construction/Destruction
  38. //////////////////////////////////////////////////////////////////////
  39.  
  40. CMyWindow::CMyWindow()
  41. {
  42.     m_hInstance = GetModuleHandle(NULL);
  43.     m_hWnd = NULL;
  44.     m_pWindowClass[0] = '\0';
  45.     // init the ThunkData with the this pointer so that this can be subclassed
  46.     ThunkInit(m_Thunk, this);
  47. }
  48.  
  49. CMyWindow::~CMyWindow()
  50. {
  51.  
  52. }
  53.  
  54. unsigned long int CMyWindow::Init(HWND hParent,char *pWindowName, unsigned long int dwExStyle,unsigned long int dwStyle, int x, int y,int nWidth, int nHeight, HMENU hMenu, int nCmdShow)
  55. {// begin Init
  56.     m_hWnd = CreateWindowEx(dwExStyle,m_pWindowClass,pWindowName,dwStyle,x,y,nWidth,nHeight,hParent,hMenu,m_hInstance,NULL);
  57.     if(!m_hWnd)
  58.         return 0;
  59.     ShowWindow(m_hWnd, nCmdShow);
  60.     UpdateWindow(m_hWnd);
  61.     return 1;
  62. }// end Init
  63.  
  64. HWND CMyWindow::GetSafeHwnd()
  65. {// begin GetSafeHwnd
  66.     return m_hWnd;
  67. }// end GetSafeHwnd
  68.  
  69. LRESULT CMyWindow::WndProc(HWND hWnd,UINT nMessage,WPARAM wParam,LPARAM lParam)
  70. {// begin WndProc
  71.     switch(nMessage)
  72.     {// begin nMessage switch
  73.     case WM_COMMAND:
  74.         OnCommand(wParam,lParam);
  75.         break;
  76.     }// end nMessage swtich
  77.     return DefWindowProc(hWnd, nMessage, wParam, lParam);
  78. }// end WndProc
  79.  
  80. unsigned long int CMyWindow::OnCommand(WPARAM wParam, LPARAM lParam)
  81. {// begin OnCommand
  82.     return 0;
  83. }// end OnCommand
  84.  
  85.  
  86. ATOM CMyWindow::RegisterClass(char *pWindowClass,unsigned long int nIconID, unsigned long int nMenuID)
  87. {// begin RegisterClass
  88.     lstrcpy(m_pWindowClass,pWindowClass);
  89.     WNDCLASSEX wcex = {NULL};
  90.  
  91.     wcex.style            = CS_HREDRAW | CS_VREDRAW;
  92.     wcex.lpfnWndProc    = (WNDPROC)(void *)m_Thunk;
  93.     wcex.cbClsExtra        = 0;
  94.     wcex.cbWndExtra        = 0;
  95.     wcex.hInstance        = m_hInstance;
  96.     wcex.hIcon            = (HICON)LoadImage(m_hInstance, (LPCTSTR)nIconID,IMAGE_ICON,32,32,LR_DEFAULTCOLOR);
  97.     wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
  98.     wcex.hbrBackground    = (HBRUSH)(COLOR_WINDOW+1);
  99.     wcex.lpszMenuName    = (LPCSTR)nMenuID;
  100.     wcex.lpszClassName    = m_pWindowClass;
  101.     wcex.hIconSm        = (HICON)LoadImage(m_hInstance, (LPCTSTR)nIconID,IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
  102.     wcex.cbSize = sizeof(wcex); 
  103.  
  104.     return RegisterClassEx(&wcex);
  105. }// end RegisterClass
  106.