Quote.ELSEIF uMsg==WM_CREATE
invoke CreateWindowEx,NULL,ADDR ButtonClass,NULL,\
WS_CHILD or WS_VISIBLE or BS_PUSHBUTTON or BS_CENTER or BS_VCENTER,\
275,10,80,25,hWnd,NULL,hInstance,NULL
mov hwndButton,eax
invoke GetDC,hwndButton
mov hdc,eax
invoke GetClientRect,hwndButton1,ADDR rect
invoke SetTextColor,hdc,0FF0008h
invoke DrawText,hdc,ADDR Button1Text,-1,ADDR rect,DT_CENTER or DT_VCENTER or DT_SINGLELINE
invoke ReleaseDC,hWnd,hdc
Why am i not getting the desired result ? (The color of the text on button does not change)
if i leave the "LPCTSTR lpWindowName" to NULL in CreateWindowEx then there is no text on the button.
Use WM_CTLCOLORBTN together with an owner drawn button instead.
The problem is not in DrawText but in WM_CREATE.
The WM_CREATE happen before the window appears on the screen.
Therefor the text does not appears in the above message.
You must use DrawText in WM_PAINT,that is,when the window
appears on the screen already.
Manos.
Yup i got you .You are right about WM_CREATE .I tried WM_PAINT and WM_CTLCOLORBTN but none worked. i think i have to learn more :toothy anyway thanks for the help.
You have to handle the WM_PAINT of Button,not of parent window.
Therefor a way is to subclass the Button window.
Manos.
Hello
I have a Problem with my DrawText function
Use LogFont:
LogFont LOGFONT <19,12,0,0,FW_NORMAL,0,0,0,OEM_CHARSET,0,0,0,0,"Courier New">
And here my DrawText Function:
invoke SelectObject,hDC,pFont
invoke SetTextColor,hDC,0A600h
invoke SetBkColor,hDC,0
invoke DrawText,hDC,offset szString,2,addr Rect,DT_BOTTOM
and a little Rect Calculation
Now the Problem is that not correct Draw my Text Char
(http://i53.tinypic.com/2v84jly.jpg)
Can you tell me what is wrong must i set the correct LogFont?
Hi G`HOST,
I will make a list of the problems and misconceptions.
1) The WM_CREATE is fine, but you cannot draw the button from there, it is in the parent's wndproc, anything you draw will be overwritten.
2) Using the WM_PAINT in the parent's wndproc has the same problem as above.
3) Don't try to process the WM_PAINT of a button, it is a combination of multiple windows that are displayed dependent on the button state.
4) if you do try to paint the button, you will also need to use DrawFrameControl as well as a few other specialized drawing routines.
5) The owner drawn button is your best solution, it allows you to draw your button face without worrying about the 5 or 6 other drawing requirements.
6) If you do decide to process WM_PAINT you have to subclass the button, you can't do it from the parent wndproc.
Edgar
Quote from: remus2k on January 06, 2011, 05:46:52 PM
Hello
I have a Problem with my DrawText function
Use LogFont:
LogFont LOGFONT <19,12,0,0,FW_NORMAL,0,0,0,OEM_CHARSET,0,0,0,0,"Courier New">
And here my DrawText Function:
invoke SelectObject,hDC,pFont
invoke SetTextColor,hDC,0A600h
invoke SetBkColor,hDC,0
invoke DrawText,hDC,offset szString,2,addr Rect,DT_BOTTOM
and a little Rect Calculation
Now the Problem is that not correct Draw my Text Char
(http://i53.tinypic.com/2v84jly.jpg)
Can you tell me what is wrong must i set the correct LogFont?
You have to create the font and use it's handle in SelectObject. Also you should make sure that you select it out when you're done.
invoke CreateFontIndirect, offset LogFont
mov hFont, eax
...
invoke SelectObject,hDC,hFont
mov hOldFont, eax
...
invoke SelectObject,hDC,hOldFont
also - make sure that the font you are selecting supports the charset you are requesting
i don't think "Courier New" supports OEM_CHARSET
find out which fonts support the charset you want to use, then pick from that list
i use the "Termnal" font - but there may be others
I think it is a rect calculations probelm from my scroller
Use i without a scroller Draw this text correct with this font Settings
yes - scrolling is a bit tricky to learn for n00bs like me because there are so many different ways to do it
without knowing about it, you have to pick a method - lol
i am looking at examples that use ScrollWindow
i think for text, it is the best way (a simpler way is to redraw the whole screen)
search the forum (and google) for "ScrollWindow"
there are more advanced techniques - but i think they might be a little complicated for text
Tedd, Manos, and others have posted some good example code
No my scroller works fine only not with this Font?
and scroll a window is a not good solution