News:

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

For....Next Loop !!!!!!!

Started by WindDancer, March 09, 2005, 02:50:08 PM

Previous topic - Next topic

WindDancer

Hi out there ,

first of all I did what you have said, I read the Tuts of Iczelion and played around with the code !!!!!!!!!!! :P
Then I tried to modify it and it will also work, but I haven't found a good Tut which explains some code constructs like a For...Next Loop or If...Then or Select Case... or something like that in asm ! :'(

Now the problem is that I have this Code (Iczelion Tut 02 only a msgbox appears) :


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

.data

   MsgBoxCaption  db "Iczelion Tutorial No.2",0
   MsgBoxText db "Win32 Assembly is Great!",0

.code

start:

   invoke MessageBox, NULL, addr MsgBoxText, addr MsgBoxCaption, MB_OK
   invoke ExitProcess, NULL

end start



Now I have one MSGBOX on the Screen !!!!!!!!!!!!!!!!!!
But how can I get 200 of the same MSGBOXES on different Coordinates on Screen ?????????????????????


Please help me and thanx a lot to everybody of you !!!!!!!!!!!!!!!! :dance:



Still learning........ :U

>>> WindDancer <<<

KetilO

Hi

Answer is, you can't.

1. A message box is modal, meaning that the execution stops until the box is closed.
2. The position of a message box cannot be changed. It will always center the screen.

You can try this:

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

.data

   MsgBoxCaption  db "Iczelion Tutorial No.2",0
   MsgBoxText db "Win32 Assembly is Great!",0

.code

start:

   xor eax,eax
   .while eax<10
      push eax
      invoke MessageBox, NULL, addr MsgBoxText, addr MsgBoxCaption, MB_OK
      pop eax
      inc eax
   .endw
   invoke ExitProcess, NULL

end start

KetilO

WindDancer

Many, Many thanx KetilO,

that helps a lot !!!!!!!
Hmmmmmmmmm MSGBOXES are modal sure!!!!!!!!!!!
can I do it with 200 Little Forms ?????


>>> WindDancer <<<


KetilO

You can do it with modeless dialogs or with normal windows.

KetilO

AeroASM

For a loop, the best way to do it is like this:


mov ecx,10         ;loop 10 times
LoopStart:
;YOUR CODE HERE
sub ecx,1            ;decrement ecx
jnz LoopStart       ;carry on looping until ecx = 0


This is like this in pseudo-VB:


For ecx = 10 To 1 Step -1
'YOUR CODE HERE
Next ecx