|
-
Oct 26th, 2001, 03:57 PM
#1
Thread Starter
Addicted Member
Drawing Text :) :confused: :)
- Win32 API I need help on
- TextOut (not really but it applies)
- SetBkColor //doesn't work
- SetTextColor //doesn't work
ok i am making a cheap old api spy to help myself learn about strings and pointers and so on and I want to do TextOut with a Black Background Rect and a White Text face and i try doing it like so
Code:
COLORREF cBack, cTxt;
char txtOut = "Some Text";
cBack = RGB(0, 0, 0);
cTxt = RGB(255, 255, 255);
SetBkColor(GetDC(hwnd), cBack);
SetTextColor(GetDC(hwnd), cTxt);
TextOut(GetDC(hwnd), 5, 5, txtOut, strlen(txtOut));
And basicly my window gets Text on it but it is not formated with the color values i used it is using the default.
so what is the problem? I thought it might be that be the COLORREF coming up bad but i used FillRect to flash my windw RGB and it works, so any ideas?
Thanks
Magiaus
Visual Basic 6.0 SP5
Visual C++ 6.0 SP5
The only sovereign you can allow to rule you is reason.
-
Oct 26th, 2001, 04:51 PM
#2
PowerPoster
I think you can only change the backcolor and textcolor this way when you have created a dialogbox.
If you have dialogbox then this code should work:
PHP Code:
HBRUSH cBack;
COLORREF cTxt;
char *txtOut = "Some Text";
cBack = (HBRUSH)CreateSolidBrush(RGB(255, 255, 0));
cTxt = RGB(255, 255, 255);
switch(Message)
{
case WM_CTLCOLORDLG:
SetBkMode(GetDC(hwnd), TRANSPARENT);
SetTextColor(GetDC(hwnd), cTxt);
return (LONG)cBack;
case WM_PAINT:
TextOut(GetDC(hwnd), 5, 5, txtOut, strlen(txtOut));
-
Oct 26th, 2001, 05:51 PM
#3
Thread Starter
Addicted Member
i'll give that a go after i get done taking my brake and let you know
Magiaus
Visual Basic 6.0 SP5
Visual C++ 6.0 SP5
The only sovereign you can allow to rule you is reason.
-
Oct 27th, 2001, 04:59 AM
#4
No, it's just that you need the same dc for setting the colors and drawing, but you requested a new one for each thing.
Code:
COLORREF cBack, cTxt;
char* txtOut = "Some Text"; // typo here
cBack = RGB(0, 0, 0);
cTxt = RGB(255, 255, 255);
HDC hdc = GetDC(hwnd);
SetBkColor(hdc, cBack);
SetTextColor(hdc, cTxt);
TextOut(hdc, 5, 5, txtOut, strlen(txtOut));
ReleaseDC(hdc); // you should always call that
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|