Is there a way to make the message box bigger?
Thanks,
Andy
invoke MessageBox,0,OFFSET successtext,OFFSET started,MB_OK
Thanks,
Andy
invoke MessageBox,0,OFFSET successtext,OFFSET started,MB_OK
What do you mean by "bigger"? It automatically resizes itself to contain the whole text you put in it (plus an optional icon). Just copy some Shakespeare into it and watch it go fullscreen ^^'
Hey Andy,
To modify the MessageBox's size you'll need to setup a custom window handler for the MessageBox using a process wide hook. It's not really as hard as it sounds, check out this pseudo/asm code.
Just a bit of a warning, you get a performance penalty with each hook/wndproc/etc you install. Each one means you are going to be receiving more messages which need to be processed. The example uses a process wide hook because a system wide hook would send you all messages killing execution time. Process wide hooks only get those of the current process. Also it's even more simplified/optimized by only receiving the computer based training messages (WH_CBT) which means you aren't being sent a majority of the messages you normally would when using journal hooks. You should be able to take the above code, insert your sizing code where specified, then just call CSMsgBox instead of MessageBox. But there are no guarantees as I've not tested the code at all.
Regards,
Bryant Keller
To modify the MessageBox's size you'll need to setup a custom window handler for the MessageBox using a process wide hook. It's not really as hard as it sounds, check out this pseudo/asm code.
.DATA
handleMsgBox DWORD 0
.CODE
CSMsgBoxProc PROC nCode:DWORD, wParam:WPARAM, lParam:LPARAM
LOCAL handleThis:DWORD
MOV EAX, nCode
CMP EAX, HCBT_ACTIVATE
JNE CALLNEXT
MOV EAX, wParam
MOV handleThis, EAX
; MODIFY SIZE HERE
XOR EAX, EAX
RET
CALLNEXT:
PUSH lParam
PUSH wParam
PUSH nCode
PUSH handleThis
CALL CallNextHookEx
RET
CSMsgBoxProc ENDP
CSMsgBox PROC hParent:DWORD, strMessage:DWORD, strTitle:DWORD, nStyle:DWORD
LOCAL dwReturn:DWORD
CALL GetCurrentThreadId
PUSH EAX
PUSH 0
PUSH OFFSET CSMsgBoxProc
PUSH WH_CBT
CALL SetWindowsHookEx
MOV handleMsgBox, EAX
PUSH nStyle
PUSH strTitle
PUSH strMessage
PUSH handleParent
CALL MessageBox
MOV dwReturn, EAX
PUSH handleMsgBox
CALL UnhookWindowsHookEx
MOV EAX, dwReturn
RET
CSMsgBox ENDP
Just a bit of a warning, you get a performance penalty with each hook/wndproc/etc you install. Each one means you are going to be receiving more messages which need to be processed. The example uses a process wide hook because a system wide hook would send you all messages killing execution time. Process wide hooks only get those of the current process. Also it's even more simplified/optimized by only receiving the computer based training messages (WH_CBT) which means you aren't being sent a majority of the messages you normally would when using journal hooks. You should be able to take the above code, insert your sizing code where specified, then just call CSMsgBox instead of MessageBox. But there are no guarantees as I've not tested the code at all.
Regards,
Bryant Keller
What do you mean by "bigger"? It automatically resizes itself to contain the whole text you put in it (plus an optional icon). Just copy some Shakespeare into it and watch it go fullscreen ^^'
Thanks.
You gave me an idea.
I put some spaces after the text and the box got bigger.
Now I will see if I can automate getting the text centered.
Andy
If you want predictable behavior you'll need to use hooks. Otherwise the same messagebox will look different from user to user because of font sizes, resolution, custom shell styles, etc.
Other solution is to use customizable task dialogs (they kinda supersede messageboxes), but these are only available on Vista/win7.
Other solution is to use customizable task dialogs (they kinda supersede messageboxes), but these are only available on Vista/win7.