home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / WIN_UTL2 / VULCAN.ZIP / VULSRC.ZIP / CANCEL.CPP < prev    next >
C/C++ Source or Header  |  1994-02-08  |  2KB  |  63 lines

  1. // CANCEL.CPP Part of VULCAN
  2. // Copyright (c) 1993 John Deurbrouck
  3. #include<windows.h>
  4. #include"resource.h"
  5. #include"vulcan.hpp"
  6. #include"cancel.hpp"
  7. #include"browse.hpp"
  8.  
  9. static FARPROC lpfnCancelDlgProc=NULL;
  10. static int goner=0;
  11. HWND hCancelDlg=NULL;
  12.  
  13. BOOL FAR PASCAL _export CancelDlgProc(HWND hDlg,unsigned message,WORD wParam,
  14. LONG lParam){
  15.     switch(message){
  16.     case WM_COMMAND:
  17.         if(IDCANCEL==wParam){
  18.             goner=1;
  19.             DestroyWindow(hDlg);
  20.             hCancelDlg=NULL;
  21.         }
  22.         return TRUE;
  23.     case WM_INITDIALOG:
  24.         EnableMenuItem(GetSystemMenu(hDlg,FALSE),SC_CLOSE,MF_GRAYED);
  25.         SetFocus(GetDlgItem(hDlg,IDCANCEL));
  26.         SetWindowPos(hDlg,0,0,0,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER);
  27.         return FALSE; // because we set focus
  28.     default:
  29.         return FALSE;
  30.     }
  31. }
  32. void start_cancel_dialog_box(void){
  33.     goner=0;
  34.     lpfnCancelDlgProc=MakeProcInstance((int(__far __pascal *)
  35.         (void))CancelDlgProc,hMainInstance);
  36.     hCancelDlg=CreateDialog(hMainInstance,
  37.         MAKEINTRESOURCE(IDD_CANCELVULCANIZE),CURR_WINDOW,lpfnCancelDlgProc); //==++
  38.     if(hCancelDlg!=NULL)EnableWindow(CURR_CANCEL_WINDOW,FALSE);
  39. }
  40. int check_cancel_dialog_box(void){
  41.     MSG msg;
  42.     while(PeekMessage(&msg,NULL,0,0,PM_REMOVE)){
  43.         if((!hCancelDlg)||(!IsDialogMessage(hCancelDlg,&msg))){
  44.             TranslateMessage(&msg);
  45.             DispatchMessage(&msg);
  46.         }
  47.     }
  48.     if(goner)return 1;
  49.     return 0;
  50. }
  51. void set_cancel_dialog_box_text(LPSTR verb,LPSTR object){
  52.     if(hCancelDlg==NULL)return;
  53.     if(verb!=NULL)SetDlgItemText(hCancelDlg,IDC_VERB,verb);
  54.     if(object!=NULL)SetDlgItemText(hCancelDlg,IDC_OBJECT,object);
  55. }
  56. void end_cancel_dialog_box(void){
  57.     if((hCancelDlg!=NULL)&&!goner){
  58.         SendMessage(hCancelDlg,WM_COMMAND,IDCANCEL,0L);
  59.     }
  60.     if(lpfnCancelDlgProc!=NULL)FreeProcInstance(lpfnCancelDlgProc);
  61.     EnableWindow(CURR_CANCEL_WINDOW,TRUE);
  62. }
  63.