🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer
Article #306

Problem with a Dialog Box

#306
From: Pat Gleason
Date: Thu, 06 Aug 1992 15:11
82 lines
3313 bytes
Hi guys...I am back again with another "I don't understand PM
programming question". I have a dialog box that I call whenever
I need to tell the user something. This code was generated with 
CasePM 2.2 and I have modified it slightly (but quite a while
back). If I stay in the program (my program always has the focus),
everything works great. However, if while the dialog box is 
displayed, I double-click on an icon (and enter that program)
and then return to my program, when I click on the OK button
(which should clear the Dialog Box) the dialog box does
not disappear.

As always, thanks in advance.

An example of the code I am using is below:


USHORT DisplayInfoBox(HWND hWnd, char *string)
{
   strcpy(GlobalErrorString, string);
   return(WinDlgBox(HWND_DESKTOP, hWnd, (PFNWP)MDINFOMsgProc,
             0, IDLG_MDXXX, (PBYTE)hWnd));
}

/***************************************************************************/
/*                                                                         */
/* Dialog Window Procedure - Display Info Box                              */
/*                                                                         */
/***************************************************************************/
MRESULT EXPENTRY MDINFOMsgProc(HWND hWndDlg, USHORT message, MPARAM mp1, MPARAM mp2)
{ 
 static SHORT sfValidate = TRUE;
 static HWND  hWndParent;
          
 switch(message)
   {
    case WM_INITDLG:
         hWndParent = (HWND)mp2;
         cwCenter(hWndDlg, (HWND)hWndParent);
         WinSetDlgItemText(hWndDlg, IDD_MDINFOTEXT, GlobalErrorString);
         break; /* End of WM_INITDLG */

    case WM_CONTROL:
         switch(SHORT1FROMMP(mp1))
           {
           } 
         break; /* End of WM_CONTROL */
   
    case WM_COMMAND:
         switch(SHORT1FROMMP(mp1))
           {
            case DID_OK: /* Button text: "OK"                              */
                 WinDismissDlg(hWndDlg, TRUE);
                 break;
            case DID_CANCEL: /* Button text: "Cancel"                              */
                 WinDismissDlg(hWndDlg, FALSE);
                 break;

           }
         break; /* End of WM_COMMAND */

    case WM_CLOSE:
         WinDismissDlg(hWndDlg, FALSE);
         break; /* End of WM_CLOSE */
  
    case WM_FAILEDVALIDATE:
         WinAlarm(HWND_DESKTOP, WA_ERROR);
         sfValidate = FALSE;
         WinSetFocus(HWND_DESKTOP, WinWindowFromID(hWndDlg, SHORT1FROMMP(mp1)));
         sfValidate = TRUE;
         return((MRESULT)TRUE);
         break; /* End of WM_FAILEDVALIDATE */

    default:
         return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
         break;
   }
 return FALSE;
} 
-- 
============================================================================
Pat Gleason                       | "Cubs fans are 90 percent scar tissue"
pgleason@ncratl.atlantaga.ncr.com |  George Will
Technical Details
Message-ID: <296@ncratl.AtlantaGA.NCR.COM>
Path: arc1-ca.pugleaf.net!sparky!uunet!psinntp!ncrlnk!ncratl!pgleason

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!psinntp!ncrlnk!ncratl!pgleason
From: pgleason@ncratl.AtlantaGA.NCR.COM (Pat Gleason)
Newsgroups: comp.os.os2.programmer
Subject: Problem with a Dialog Box
Message-ID: <296@ncratl.AtlantaGA.NCR.COM>
Date: 6 Aug 92 15:11:32 GMT
Organization: NCR Engineering and Manufacturing Atlanta -- Atlanta, GA
Lines: 82