Advertisement
Guest User

Untitled

a guest
Oct 28th, 2015
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. #include "DialogWnd.h"
  2.  
  3. DialogWnd::DialogWnd()
  4. {
  5.     InitCommonControls();
  6.     InitWindow(0, 0, 0, 0);
  7. }
  8.  
  9. DialogWnd::DialogWnd(HINSTANCE hInstance, HINSTANCE h0, LPTSTR lpCmdLine, int nCmdShow)
  10. {
  11.     InitCommonControls();
  12.     InitWindow(hInstance, h0, lpCmdLine, nCmdShow);
  13. }
  14.  
  15. DialogWnd::~DialogWnd() {}
  16.  
  17. int DialogWnd::InitWindow(HINSTANCE hInstance, HINSTANCE h0, LPTSTR lpCommandLine, int nCmdShow)
  18. {
  19.     hDialog = reinterpret_cast<HWND>(DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_DIALOG), 0, DialogProc, 0));
  20.     ShowWindow(hDialog, nCmdShow);
  21.  
  22.     while ((ret = GetMessage(&msg, 0, 0, 0)) != 0)
  23.     {
  24.         if (ret == -1) return -1;
  25.         if (!IsDialogMessage(hDialog, &msg))
  26.         {
  27.             TranslateMessage(&msg);
  28.             DispatchMessage(&msg);
  29.         }
  30.     }
  31.  
  32.     return 0;
  33. }
  34.  
  35. INT_PTR DialogWnd::DialogProc(HWND hDialog, UINT uMsg, WPARAM wParam, LPARAM lParam)
  36. {
  37.     switch(uMsg)
  38.     {
  39.     case WM_INITDIALOG:
  40.         SetDlgItemText(hDialog, IDC_EDIT1, _T("off"));
  41.         return TRUE;
  42.  
  43.     case WM_CLOSE:
  44.         return TRUE;
  45.  
  46.     case WM_DESTROY:
  47.         PostQuitMessage(0);
  48.         return TRUE;
  49.     }
  50.     return FALSE;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement