News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Customizing message boxes

Started by Vortex, July 12, 2007, 05:11:34 PM

Previous topic - Next topic

Vortex

Here is an example of a message box displaying a customized button. The demo is based on the article :

http://www.catch22.net/tuts/msgbox.asp


#include "CustMsgBox.inc"

.data
msg1 db 'This is a customized message box',0
capt db 'Hello!',0
buttontext db 'Click here',0
hMboxHook dd ?
pButtonText dd ?

.code

start:

invoke CustomMsgBox,0,ADDR msg1,ADDR capt,ADDR buttontext
invoke ExitProcess,0

mboxCBTProc FRAME nCode,wParam,lParam

cmp d[nCode],0
jb >
cmp d[nCode],HCBT_ACTIVATE
jne >
invoke GetDlgItem,[wParam],IDOK
invoke SetWindowText,eax,[pButtonText]
xor eax,eax
ret
:
invoke CallNextHookEx,[hMboxHook],[nCode],[wParam],[lParam]
ret
ENDF

CustomMsgBox FRAME hWnd,message,caption,buttontext

mov eax,[buttontext]
mov [pButtonText],eax
invoke GetCurrentThreadId
invoke SetWindowsHookEx,WH_CBT,ADDR mboxCBTProc,NULL,eax
mov [hMboxHook],eax
invoke MessageBox,0,[message],[caption],MB_OK
invoke UnhookWindowsHookEx,[hMboxHook]
ret
ENDF



[attachment deleted by admin]

Vortex

Here is the GoAsm version of the demo where the message box is moved to a thread.

[attachment deleted by admin]

jorgon

Author of the "Go" tools (GoAsm, GoLink, GoRC, GoBug)

Vortex

Simplified code to detect the message box.