hi all.. wonderin if I could get some help...
I have set up a SetTextColor proc and a SetFont/TextFont proc up.. as I am trying to make some of the code hidden.. nothing seems to be printing in the client window.. when I have the code inline however it works fine. (See tutorial for More Text to see code for the RGB macro)
please see code below and thanx in advance.
============ MAIN PROGRAM ====================
:: :: :: ::
.data
FontText db "Quik Font testing...",0
FontText2 db "with this script type of font...",0
FontName db "script",0
F_Comic db "comic",0
:: :: :: ::
.ELSEIF uMsg==WM_PAINT
invoke BeginPaint, hWnd, ADDR ps
invoke SetTxtColors, 255,255,255, 0,0,0
invoke GTEXT, ADDR FontText,0,0, ADDR FontName, FW_BOLD, 32, 24
___________________________________________________
============ GIO.ASM ======================
SetTxtColors proto:BYTE,:BYTE,:BYTE, :BYTE,:BYTE,:BYTE
GTEXT proto:PTR DWORD,:DWORD,:DWORD,:PTR DWORD,:DWORD,:DWORD,:DWORD
GetMouseXY proto:DWORD,:DWORD
MemCopy proto:PTR BYTE,:PTR BYTE,:DWORD
.data
F_DebugA db "before the loop",0
.data?
hitpoint POINT <>
.code
SetTxtColors proc RT:BYTE,GTT:BYTE,BTT:BYTE, RB:BYTE,GB:BYTE,BB:BYTE
RGB RT,GTT,BTT
invoke SetTextColor,hdc,eax
RGB RB,GB,BB
invoke SetBkColor,hdc,eax
invoke MessageBox, NULL, F_DebugA, NULL, MB_OK
ret
SetTxtColors endp
GTEXT proc Text2Disp:PTR DWORD, x:DWORD, y:DWORD, fontname2:PTR DWORD,FontType:DWORD,XWid:DWORD,YWid:DWORD
mov hdc,eax
invoke CreateFont,XWid,YWid,0,0,FontType,0,0,0,OEM_CHARSET,\
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,\
DEFAULT_QUALITY,DEFAULT_PITCH or FF_SCRIPT,\
fontname2
invoke SelectObject, hdc, eax
mov hfont,eax
invoke TextOut,hdc,x,y, ADDR Text2Disp, SIZEOF Text2Disp
invoke SelectObject,hdc,hfont
ret
GTEXT endp
I have set up a SetTextColor proc and a SetFont/TextFont proc up.. as I am trying to make some of the code hidden.. nothing seems to be printing in the client window.. when I have the code inline however it works fine. (See tutorial for More Text to see code for the RGB macro)
please see code below and thanx in advance.
============ MAIN PROGRAM ====================
:: :: :: ::
.data
FontText db "Quik Font testing...",0
FontText2 db "with this script type of font...",0
FontName db "script",0
F_Comic db "comic",0
:: :: :: ::
.ELSEIF uMsg==WM_PAINT
invoke BeginPaint, hWnd, ADDR ps
invoke SetTxtColors, 255,255,255, 0,0,0
invoke GTEXT, ADDR FontText,0,0, ADDR FontName, FW_BOLD, 32, 24
___________________________________________________
============ GIO.ASM ======================
SetTxtColors proto:BYTE,:BYTE,:BYTE, :BYTE,:BYTE,:BYTE
GTEXT proto:PTR DWORD,:DWORD,:DWORD,:PTR DWORD,:DWORD,:DWORD,:DWORD
GetMouseXY proto:DWORD,:DWORD
MemCopy proto:PTR BYTE,:PTR BYTE,:DWORD
.data
F_DebugA db "before the loop",0
.data?
hitpoint POINT <>
.code
SetTxtColors proc RT:BYTE,GTT:BYTE,BTT:BYTE, RB:BYTE,GB:BYTE,BB:BYTE
RGB RT,GTT,BTT
invoke SetTextColor,hdc,eax
RGB RB,GB,BB
invoke SetBkColor,hdc,eax
invoke MessageBox, NULL, F_DebugA, NULL, MB_OK
ret
SetTxtColors endp
GTEXT proc Text2Disp:PTR DWORD, x:DWORD, y:DWORD, fontname2:PTR DWORD,FontType:DWORD,XWid:DWORD,YWid:DWORD
mov hdc,eax
invoke CreateFont,XWid,YWid,0,0,FontType,0,0,0,OEM_CHARSET,\
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,\
DEFAULT_QUALITY,DEFAULT_PITCH or FF_SCRIPT,\
fontname2
invoke SelectObject, hdc, eax
mov hfont,eax
invoke TextOut,hdc,x,y, ADDR Text2Disp, SIZEOF Text2Disp
invoke SelectObject,hdc,hfont
ret
GTEXT endp
I think the problem in proc GTEXT:
MOV hdc,eax
You must pass hdc as parameter to this func
MOV hdc,eax
You must pass hdc as parameter to this func
Thanks for the quick reply, I just tried as you suggested and still no dice..
besides the hdc I declared it in the .data of a .INC file so it would be global?
may have to rework these routines
besides the hdc I declared it in the .data of a .INC file so it would be global?
may have to rework these routines
Well from looking at the code what Alexy said is right.
At the end of the SetTxtColors proc eax will equal the return value from thn MessageBox call. Ignoring the pushs, calls, etc the next instruction is mov hdc,eax. When you do this you end up with an invalid value in hDc.
When you later pass hDc to the TextOut function windows spots its invalid and doesn't draw any text.
At the end of the SetTxtColors proc eax will equal the return value from thn MessageBox call. Ignoring the pushs, calls, etc the next instruction is mov hdc,eax. When you do this you end up with an invalid value in hDc.
When you later pass hDc to the TextOut function windows spots its invalid and doesn't draw any text.
doh! absolutely right!
I had the MOV hdc,eax in the wrong spot. Moved it to right after
the BeginPaint invocation and it works up to a point (will it ever end)..
seems to only print out the first 4 letters of the string, as if it is printing a DWORD (4 bytes)? instead of the string...
thanks again for your help
I AM NOT WORTHY!!!
Posted on 2001-08-28 16:32:13 by drarem
I had the MOV hdc,eax in the wrong spot. Moved it to right after
the BeginPaint invocation and it works up to a point (will it ever end)..
seems to only print out the first 4 letters of the string, as if it is printing a DWORD (4 bytes)? instead of the string...
thanks again for your help
I AM NOT WORTHY!!!
Posted on 2001-08-28 16:32:13 by drarem
Your 4 byte DWORD theory is quite close. SIZEOF Text2Disp is a built in MACRO that gives you the lenght of the variable, a four byte DWORD, not the lenght of the string it points to.
Use the StrLen function from the masmlib to work this out at runtime.
include \masm32\include\masm32.inc
includelib \masm32\lib\masm32.lib
.code
invoke StrLen,addr Text2Disp
invoke TextOut,hdc,x,y, ADDR Text2Disp, eax
Note I'm not sure if the addr should be used here. You'll have to test it to find out.
Use the StrLen function from the masmlib to work this out at runtime.
include \masm32\include\masm32.inc
includelib \masm32\lib\masm32.lib
.code
invoke StrLen,addr Text2Disp
invoke TextOut,hdc,x,y, ADDR Text2Disp, eax
Note I'm not sure if the addr should be used here. You'll have to test it to find out.
Thank you :) works like a charm.. brings back old MS-DOS C coding memories.
It also fixes the FONT issues too, where any font I specified came out script.. (cept for comic)...
guess knowing in advance which font to use or distributing will have to be another hurdle to jump, as well as my style.
please critique if you want, i could use it..
l8a
It also fixes the FONT issues too, where any font I specified came out script.. (cept for comic)...
guess knowing in advance which font to use or distributing will have to be another hurdle to jump, as well as my style.
please critique if you want, i could use it..
l8a