.ELSEIF uMsg==WM_PAINT
invoke BeginPaint,hWnd,addr ps
mov hdc,eax
invoke GetClientRect,hdc,addr rect
mov eax, dword ptr
invoke dwtoa, eax, dword ptr



invoke DrawText,hdc,addr texbuffer,4,addr rect,DT_SINGLELINE ;i suspect here but....???

invoke EndPaint,hWnd,addr ps

What am i doing wrong here to get an illegal operation.


Thanx in advance
Posted on 2003-01-01 18:12:20 by IwasTitan

invoke DrawText,hdc,addr texbuffer,4,addr rect,DT_SINGLELINE ;i suspect here but....???

Have you tried to "lea the adresses" (se example) or use offset instead of addr?
e.g.
lea eax,
lea edx,
invoke DrawText, hdc, eax, 4, edx, DT_SINGLELINE

Could you post the actual error message, it might make it easier to determinate the error.
Posted on 2003-01-01 18:39:49 by scientica
change "addr texbuffer" to "texbuffer"

texbuffer seems to be a pointer, and passing a pointer to a pointer leads to the error. But if texbuffer is a local dword, and you expect the maximum drawn value to be 4-digit, then change the
"invoke dwtoa, eax, dword ptr " to
"invoke dwtoa, eax, addr texbuffer"
place a disassembly of the code, together with error state's EIP and EAX to give us better view.
Posted on 2003-01-01 18:40:56 by Ultrano
This is what i have now with no crashing but still no text on screen.

Maybe its because the values i am converting to text are from the OSVERSIONINFO structure and they are small values.

How would i write the values of the structure to the screen as decimal numbers which would eliminate DrawText altogether i guess.

This is my first time attempting to display info in the client area that is not in a DATA string.

.ELSEIF uMsg==WM_PAINT
invoke BeginPaint,hWnd,addr ps
mov hdc,eax
invoke GetClientRect,hdc,addr rect
mov eax, dword ptr
invoke dwtoa,eax, addr texbuffer
lea eax,
lea edx,
invoke DrawText, hdc, eax, 4, edx, DT_SINGLELINE
invoke EndPaint,hWnd,addr ps
Posted on 2003-01-01 19:04:34 by IwasTitan
IwasTitan,
This is what is causing the DrawText() to malfunction:
[color=sienna]invoke GetClientRect,hdc,addr rect[/color]

[color=red]invoke GetClientRect,hWnd,addr rect[/color]
Wierd isnt it? noone noticed that you used HDC where it should
have been a handle to the window? ( ;) )

Small Tip: look into the ADDR,INVOKE, etc. macros. The best
thing is actually to look at the disassembly of an invoke call.
Get yourself a good debugger and experiment with it. Look under
the hood of the macros. Use the command line switches like:
/Fl /Sc /Sg with ML.EXE
[color=sienna].nolist  ;dont list the stuff here

.nocref ;
...
include
includelib ..
...
.list ; start listing all the code below
.cref ;
.code[/color]

This will output a .lst file wich contains the whole code with the macros
shown as assembly code. Search the board or read about the switches
for more information. Probably you know the switches etc. above.
But you never know so I put some info for those who want to read it. :alright:
Posted on 2003-01-01 19:53:25 by natas
:) natas was quicker than me.
well, I'll add just a lil thingie:
invoke something,ADDR rect
makes


lea eax,[ebp+4] ; this is if the rect is local
push eax
call something

and thus modifies the eax register if you need the address of a local var.
you will be automatically notified if you use eax and it's dirty, but if you won't be notified if you use eax later, and think it's the same you had set it before the invoke.
Instead of string size 4 in the DrawText, use -1 to automatically find the len of the string, otherwise 1 will be printed "1 ??" ;)
Posted on 2003-01-01 20:07:58 by Ultrano
Thanx to all for tips, advice, and noticing my typo error.

Got text on screen now.

:alright:
Posted on 2003-01-01 20:29:29 by IwasTitan