Is there a way to show 2 or more messageboxes at the same time?
Posted on 2003-11-26 13:54:40 by n00b
Put them in seperate threads because MessageBox dose not return untill the message has been closed.
Posted on 2003-11-26 13:58:21 by ENF
What do you mean with threads (sucky english).
Posted on 2003-11-26 14:06:07 by n00b
Posted on 2003-11-26 14:09:22 by donkey
Could you please give an example?
Posted on 2003-11-26 14:46:33 by n00b
This just shows how to create a thread. it dosen't use any thread syncronisation so the program eventually quits killing all threads.


.386

.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

.data
MsgTitle db "Hello",0
Msg1 db "Message 1",0
Msg2 db "Message 2",0
Msg3 db "Message 3",0
.data?
ThreadID dd ?

.code

MessageProc PROTO :DWORD

start:

invoke CreateThread, NULL, 0, addr MessageProc, addr Msg1, 0, addr ThreadID
invoke CloseHandle, eax
invoke CreateThread, NULL, 0, addr MessageProc, addr Msg2, 0, addr ThreadID
invoke CloseHandle, eax
invoke CreateThread, NULL, 0, addr MessageProc, addr Msg3, 0, addr ThreadID
invoke CloseHandle, eax

invoke Sleep, 2000
invoke ExitProcess, 0

MessageProc PROC msg:DWORD
invoke MessageBox, NULL, msg, addr MsgTitle, MB_OK
ret
MessageProc ENDP
end start
Posted on 2003-11-26 15:09:49 by ENF
Hi. :)

How about this?
.386

.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

.data
MsgTitle db "Hello",0
Msg1 db "Message 1",0
Msg2 db "Message 2",0
Msg3 db "Message 3",0
.data?
ThreadID dd ?

hThread1 dd ?
hThread2 dd ?
hThread3 dd ?

.code

MessageProc PROTO :DWORD

start:

invoke CreateThread, NULL, 0, addr MessageProc, addr Msg1, 0, addr ThreadID
mov hThread1,eax
push eax
invoke CreateThread, NULL, 0, addr MessageProc, addr Msg2, 0, addr ThreadID
mov hThread2,eax
push eax
invoke CreateThread, NULL, 0, addr MessageProc, addr Msg3, 0, addr ThreadID
mov hThread3,eax
push eax

invoke WaitForMultipleObjects,3,offset hThread1,TRUE,INFINITE

call CloseHandle
call CloseHandle
call CloseHandle
invoke ExitProcess, 0

MessageProc PROC msg:DWORD
invoke MessageBox, NULL, msg, addr MsgTitle, MB_OK
ret
MessageProc ENDP
end start
Posted on 2003-11-26 17:17:02 by QvasiModo
Thats a good solution:alright:
I've never used WaitForMultipleObjects before.
Posted on 2003-11-26 18:48:24 by ENF
Thanks for all the help :)
Posted on 2003-11-27 07:38:39 by n00b
QvasiModo, nice to see that you're doing CloseHandle() on the thread handles! :alright:
Posted on 2003-11-27 07:56:32 by f0dder