How to create a "system modal" form similar to ATEasy 2.x dialogs

Knowledge Base Article # Q200054

Read Prior Article Read Next Article
Summary The System modal dialog style (DS_SYSMODAL) was dropped as it is no longer supported in Win32. A workaround using User32.dll is possible.
Solution:

The System modal dialog style (DS_SYSMODAL) was dropped as it is no longer supported in Win32. According to MSDN documentation:

This style is obsolete and is included for compatibility with 16-bit versions of Windows. If you specify this style, the system creates the dialog box with the WS_EX_TOPMOST style. This style does not prevent the user from accessing other windows on the desktop. Do not combine this style with the DS_CONTROL style.
You can still make a window top-most by using the following USER32.DLL function, in the Form OnLoad event:

SetWindowPos(Form.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE or SWP_NOMOVE)

Where the parameters are prototype as follows:

DLL User32
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
File = User32.dll

DLL Types
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––

DLL Procedures
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––

Procedure SetWindowPos(hwnd, hwndInsertAfter, x, y, cx, cy, uFlags): Bool
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
hwnd: Val AHandle
hwndInsertAfter: Val AHandle
x: Val Long
y: Val Long
cx: Val Long
cy: Val Long
uFlags: Val DWord


DLL Constants
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
HWND_TOPMOST: AHandle Const = -1
SWP_NOSIZE: Long Const = 1
SWP_NOMOVE: Long Const = 2
SWP_NOZORDER: Long Const = 4


Sample files are available: DownloadQ200054.zip

Article Date 4/10/2003 2:25:52 PM     Updated: 4/16/2014 3:51:29 PM
Keywords ATEasy, DS_SYSMODAL, SetWindowPos(), ZOrder

0 ratings | 0 out of 5
Read Prior Article Read Next Article