uses dialogs

#define HCBT_MOVESIZE       0
#define HCBT_MINMAX         1
#define HCBT_QS             2
#define HCBT_CREATEWND      3
#define HCBT_DESTROYWND     4
#define HCBT_ACTIVATE       5
#define HCBT_CLICKSKIPPED   6
#define HCBT_KEYSKIPPED     7
#define HCBT_SYSCOMMAND     8
#define HCBT_SETFOCUS       9

#define WH_MIN              -1
#define WH_MSGFILTER        -1
#define WH_JOURNALRECORD    0
#define WH_JOURNALPLAYBACK  1
#define WH_KEYBOARD         2
#define WH_GETMESSAGE       3
#define WH_CALLWNDPROC      4
#define WH_CBT              5
#define WH_SYSMSGFILTER     6
#define WH_MOUSE            7
'#if defined(_WIN32_WINDOWS)
#define WH_HARDWARE         8
'#endif
#define WH_DEBUG            9
#define WH_SHELL           10
#define WH_FOREGROUNDIDLE  11
'#if(WINVER >= 0x0400)
#define WH_CALLWNDPROCRET  12
'#endif /* WINVER >= 0x0400 */

'#if (_WIN32_WINNT >= 0x0400)
#define WH_KEYBOARD_LL     13
#define WH_MOUSE_LL        14
'#endif // (_WIN32_WINNT >= 0x0400)

'#if(WINVER >= 0x0400)
'#if (_WIN32_WINNT >= 0x0400)
#define WH_MAX             14
'#else
'#define WH_MAX             12
'#endif // (_WIN32_WINNT >= 0x0400)
'#else
'#define WH_MAX             11
'#endif

#define WH_MINHOOK         WH_MIN
#define WH_MAXHOOK         WH_MAX

'sys constants (equates are limited to 32bit)

sys HWND_TOP        = 0
sys HWND_BOTTOM     = 1
sys HWND_TOPMOST    =-1
sys HWND_NOTOPMOST  =-2

sys HWND_DESKTOP    = 0
sys HWND_BROADCAST  = 0xffff

'#if(WINVER >= 0x0500
sys HWND_MESSAGE     =-3
'#endif /* WINVER >= 0x0500 */

sys HWND_DESKTOP       = 0


type CBT_CREATEWND
  sys lpcs 'CREATESTRUCT PTR
  sys hWndInsertAfter
end type
'____________________________________________________________________________

function MessageBoxProc(byval nCode as dword, byval hWin as sys, byval lparam as sys) as sys callback
 static sys hStatic, hFont, hIcon, hButton        'type CREATESTRUCT        type CBT_CREATEWND
 static long DialogWidth, DialogHeight            '  lpCreateParams as sys    lpcs as sys 'CREATESTRUCT
                                                  '  hInstance as sys        hWndInsertAfter as sys
 if nCode = HCBT_CREATEWND                        '  hMenu as sys          end type
  CBT_CREATEWND cbtWin    at lparam              '  hWndParent as sys
  CREATESTRUCT  cbtStruct at cbtWin.lpcs          '  cy as long
                                                  '  cx as long
  ZSTRING zClass[64]                              '  y as long
  GetClassName(hWin, @zClass, 64)                '  x as long
                                                  '  style as long
  if zClass = "#32770"                            '  lpszName as char ptr
    cbtStruct.cx = cbtStruct.cx * 2              '  lpszClass as char ptr
    DialogWidth = cbtStruct.cx                    '  ExStyle as long
    DialogHeight = cbtStruct.cy                  'end type
    'hIcon = LoadIcon(BYVAL NULL, IDI_INFORMATION)
    hIcon = ExtractIcon(GetModuleHandle(""), "Shell32.dll", 294)
    SendMessage(hWin, WM_SETICON, ICON_SMALL, hIcon)

  elseif zClass = "Static"
    if (cbtStruct.Style AND %SS_ICON) 'Icon id = 0x14
      cbtStruct.x  = 3 'Move icon near the left border
    else 'Static id = 0xFFFF
      cbtStruct.x  =  38
      cbtStruct.y  = cbtStruct.y - 20
      cbtStruct.cy = cbtStruct.cy + 35
      cbtStruct.cx = DialogWidth - 50
      hStatic      = hWin
    endif

  elseif zClass = "Button"
    if cbtStruct.hMenu = IDOK
      cbtStruct.x = DialogWidth  - cbtStruct.cx - 20
      cbtStruct.y = DialogHeight - cbtStruct.cy - 40
      hButton    = hWin
    endif
  end if

 elseif nCode = HCBT_ACTIVATE
  LOGFONT LF
  LF.LFHeight  = 48 '%FW_NORMAL
  LF.LFItalic  = FALSE
  LF.LFFaceName = "Segoe UI"
  hFont = CreateFontIndirect(@LF)
  'hFont = GetObject(GetStockObject(%ANSI_FIXED_FONT), SIZEOF(LF), @LF)
  'hFont = GetObject(GetStockObject(%ANSI_VAR_FONT), SIZEOF(LF), BYVAL VARPTR(LF))
  SendMessage(hStatic, WM_SETFONT, hFont, 0)

 elseif nCode = HCBT_DESTROYWND
  if hFont then DeleteObject(hFont)
  IF hIcon THEN DestroyIcon(hIcon)

 elseif nCode = HCBT_SETFOCUS
 end if

end function
'____________________________________________________________________________

 sys hMsgBoxHook = SetWindowsHookEx(WH_CBT, @MessageBoxProc, GetModuleHandle(""), GetCurrentThreadId())

 MessageBox(HWND_DESKTOP, "Hooked message box", "Hooked message box", MB_OK | MB_SYSTEMMODAL | MB_TOPMOST | MB_ICONINFORMATION)

 UnhookWindowsHookEx(hMsgBoxHook)

 end
'_____________________________________________________________________________
'