home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 25 / nopv25.iso / 040A / TMTP100O.ZIP / EXAMPLES / OS2 / SKELETON / ABOUT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-06-25  |  3.1 KB  |  107 lines

  1. { About Dialog Handler }
  2.  
  3. unit about;
  4. interface
  5.  
  6. uses Os2Types, os2PmApi;
  7.  
  8. const
  9.  
  10.  DB_RAISED     =  $0400;
  11.  DB_DEPRESSED  =  $0800;
  12.  
  13. procedure DisplayAbout (hwnd: HWND; pszAppName: Pchar {PSZ});
  14.  
  15. implementation
  16.  
  17. { ----------------------  Dialog Function ----------------------- }
  18.  
  19. function AboutDlgProc conv arg_cdecl (hWnd: HWND; msg: ULONG; mp1, mp2: MPARAM): Mresult;
  20.   var
  21.     bHandled: boolean;
  22.     mReturn: MRESULT;
  23.     ulScrWidth, ulScrHeight: ulong;
  24.     Rectl: os2types.Rectl;
  25.     Swp: os2pmapi.swp;
  26.     hps: os2types.HPS;
  27. begin
  28.     bHandled := TRUE;
  29.     mReturn  := 0;
  30.  
  31.     case msg of
  32.        WM_INITDLG:
  33.           begin
  34.             { Center dialog on screen }
  35.             ulScrWidth  := WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN);
  36.             ulScrHeight := WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN);
  37.             WinQueryWindowRect (hWnd, Rectl);
  38.             WinSetWindowPos (hWnd, HWND_TOP, (ulScrWidth-Rectl.xRight) div 2,
  39.                 (ulScrHeight-Rectl.yTop) div 2, 0, 0, SWP_MOVE + SWP_ACTIVATE);
  40.  
  41.             { Set application title }
  42.             WinSetDlgItemText (hWnd, 10001, Pchar (mp2));
  43.           end;
  44.  
  45.        WM_PAINT:
  46.           begin
  47.             hps := WinBeginPaint (hWnd,0,nil);
  48.             WinQueryWindowRect (hWnd, Rectl);
  49.             WinFillRect (hps, Rectl, CLR_PALEGRAY);
  50.             WinDrawBorder (hps, Rectl,
  51.                 WinQuerySysValue(HWND_DESKTOP,SV_CXDLGFRAME),
  52.                 WinQuerySysValue(HWND_DESKTOP,SV_CYDLGFRAME),
  53.                 CLR_DARKGRAY, CLR_WHITE, DB_RAISED);
  54.             declare
  55.                var p: pointl;
  56.             begin
  57.                p.x := rectl.xleft;
  58.                p.y := rectl.ybottom;
  59.                GpiMove (hps, p);
  60.             end;
  61.             Inc (Rectl.xRight);
  62.             Inc (Rectl.yTop);
  63.             declare
  64.               var p: pointl;
  65.             begin
  66.               p.x := rectl.xright;
  67.               p.y := rectl.ytop;
  68.               GpiBox (hps, DRO_OUTLINE, p, 0, 0);
  69.             end;
  70.             WinQueryWindowPos (WinWindowFromID (hWnd, 10002), Swp);
  71.             Rectl.xLeft   := Swp.x-1;
  72.             Rectl.yBottom := Swp.y-1;
  73.             Rectl.xRight  := Swp.x + Swp.cx + 1;
  74.             Rectl.yTop    := Swp.y + Swp.cy + 1;
  75.             WinDrawBorder (hps, Rectl, 1, 1,
  76.                 CLR_DARKGRAY, CLR_WHITE, DB_DEPRESSED);
  77.             WinQueryWindowPos (WinWindowFromID (hWnd, 10003), Swp);
  78.             Rectl.xLeft    := Swp.x-1;
  79.             Rectl.yBottom  := Swp.y-1;
  80.             Rectl.xRight   := Swp.x + Swp.cx + 1;
  81.             Rectl.yTop     := Swp.y + Swp.cy + 1;
  82.             WinDrawBorder (hps, Rectl, 1, 1,
  83.                 CLR_DARKGRAY, CLR_WHITE, DB_DEPRESSED);
  84.             WinEndPaint (hps);
  85.           end;
  86.  
  87.        WM_COMMAND:
  88.           WinDismissDlg (hWnd, DID_OK);
  89.  
  90.        else
  91.             bHandled := FALSE;
  92.     end;
  93.  
  94.     if not bHandled then
  95.         mReturn := WinDefDlgProc (hWnd, msg, mp1, mp2);
  96.  
  97.     result  := mReturn;
  98. end;
  99.  
  100. procedure DisplayAbout (hwnd: HWND; pszAppName: Pchar);
  101. begin
  102.     WinDlgBox (HWND_DESKTOP, hWnd, @AboutDlgProc, 0, 10000, pszAppName);
  103.     --return;
  104. end;
  105.  
  106. end.
  107.