home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / wint1_92 / shaw / dialog.cpp < prev    next >
C/C++ Source or Header  |  1991-11-04  |  1KB  |  46 lines

  1. // dialog.cpp RHS 10/15/91
  2.  
  3. #include"dialog.h"
  4.  
  5. WinDialog::WinDialog(char *dialogname, FARPROC DialogProc, HWND hWnd)
  6.     {
  7.     Init(dialogname,DialogProc,hWnd);
  8.     lpDialog = MakeProcInstance((FARPROC)DialogProc, GetInstance());
  9.     results = DialogBox(GetInstance(), dialogname, hWnd, lpDialog);
  10.     FreeProcInstance(lpDialog);
  11.     }
  12.  
  13. void WinDialog::SetProc(FARPROC DialogProc)
  14.     {   
  15.     if(lpDialog)
  16.         FreeProcInstance(lpDialog);
  17.     lpDialog = MakeProcInstance((FARPROC)DialogProc, GetInstance());
  18.     }
  19.  
  20. void WinDialog::Init(char *name,FARPROC DialogProc,HWND hWnd)
  21.     {
  22.     SetProc(DialogProc);
  23.     SetName(name);
  24.     SetParent(hWnd);
  25.     results = 0;
  26.     WHandle = 0;
  27.     }
  28.  
  29. void WinDialog::SetDlgIcon(HICON hIcon)
  30.     {
  31.     if(WHandle)
  32.         SetClassWord(WHandle,GCW_HICON,hIcon);
  33.     }
  34.  
  35. int WinDialog::Run(void)
  36.     {
  37.     if(lpDialog && name && hWndParent)
  38.         {
  39.         results = DialogBox(GetInstance(), name, hWndParent, lpDialog);
  40.         FreeProcInstance(lpDialog);
  41.         return results;
  42.         }
  43.     return 0;
  44.     }
  45.  
  46.