programming tools for Windows applications development
  Home  |   SwiftForth Archive  |   SwiftX Archive  |

Sample code: CenterDialog

From: Charles Melice <mail_at_forthcad.com>
Date: Thu, 26 Oct 2000 19:58:37 +0200

{ ==================================================================
  CenterDialog ( hdlg -- ) Center a dialogbox in its parent window
  To use in the WM_INITDIALOG dialogproc message.
  ================================================================== }

Function: SetWindowPos ( hwnd hwndInsertAfter x y cx cy fuFlags -- bool )

: CenterDialog ( hwnd -- )
    8 CELLS R-ALLOC DUP 4 CELLS + LOCALS| rp rd hdlg |
    hdlg GetParent rp GetWindowRect drop
    hdlg rd GetWindowRect drop
    rp @RECT ROT + 2/ >R + 2/ \ s: xpc r: ypc
    rd @RECT ROT - >R SWAP - 2/ - \ s: x r: ypc -cyd
    2R> 2/ - \ s: x y r:
    hdlg 0 2SWAP 0 0 SWP_NOSIZE SWP_NOACTIVATE OR SetWindowPos drop ;

\ eof
Received on Thu Oct 26 2000 - 11:06:02 PDT

This archive was generated by hypermail 2.2.0 : Thu Nov 20 2008 - 03:04:29 PST