' Desktop image as a background to your form for Rapid-Q

$TYPECHECK ON

CONST WM_SYSCOMMAND = &H0112
CONST SC_SIZE = 61440
CONST SC_MOVE = 61456
CONST SC_MINIMIZE = 61472
CONST SC_MAXIMIZE = 61488
CONST SC_CLOSE = 61536
CONST SC_RESTORE = 61728

CONST WM_SIZING = 532
CONST WM_MOVING = 534

DECLARE FUNCTION PaintDesktop LIB "USER32" ALIAS "PaintDesktop" (HDC AS INTEGER) AS INTEGER
DECLARE FUNCTION GetDC LIB "USER32" ALIAS "GetDC" (HWND AS INTEGER) AS INTEGER

DECLARE SUB FormWndProc (Hwnd&, uMsg&, wParam&, lParam&)
DECLARE SUB PaintForm


DIM Form AS QForm
DIM Button AS QBUtton
Button.Parent = Form

'Form.Center
Form.WndProc = FormWndProc
Form.OnPaint = PaintForm
Form.ShowModal

SUB FormWndProc (Hwnd&, uMsg&, wParam&, lParam&)
  IF uMsg& = WM_MOVING OR uMsg& = WM_SIZING THEN
    PaintForm
  END IF
  IF uMsg& = 6 THEN Form.Show
  IF uMsg& = WM_SYSCOMMAND THEN
    'Application.Minimize
    'Form.Visible = 0
    'IF wParam& = SC_MINIMIZE THEN Application.Minimize
  END IF
END SUB

SUB PaintForm
  PaintDesktop GetDC(Form.Handle)
END SUB
