|
-
Oct 5th, 2000, 04:15 PM
#1
Thread Starter
Frenzied Member
I am making an app using only API(no MFC).Now ,the problem is that i don't know how to change the backcolor of a window or the text in that window.I tried to use the SetBkColor function but don't know how.I don't know how to use the COLORREF structure.
Any help appreciated.
-
Oct 5th, 2000, 05:08 PM
#2
I also code in only API and i would also like to know how to do this.
-
Oct 5th, 2000, 05:16 PM
#3
Monday Morning Lunatic
COLORREF isn't a structure. It's a typedef alias (a type that is created from another standard type, in this case an unsigned long).
So, you pass the values as:
Code:
SetBkColor(..., RGB(255,255,255), ...);
...using the RGB macro. The values are stored as 0x00BBGGRR internally.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 6th, 2000, 11:58 AM
#4
Thread Starter
Frenzied Member
I tried this but it doesn't work:
Code:
HWND db=FindWindow(NULL,"bb");
HDC dbdc = GetDC(db);
SetBkColor(dbdc,RGB(255,0,128));
WHY??
-
Oct 7th, 2000, 08:07 AM
#5
Fanatic Member
Okay, I'm not exactly a C++ expert, but:
Code:
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.hbrBackground = GetSysColorBrush(COLOR_BTNFACE) ;
//Other wcex stuff
Works fine.
Also:
Code:
case WM_PAINT:
HDC hdc;
PAINTSTRUCT ps;
RECT rct;
HBRUSH hBrush;
POINT p;
GetWindowRect(hWnd, &rct);
p.x = rct.top;
p.y = rct.left;
ScreenToClient(hWnd, &p);
rct.top = p.x;
rct.left = p.y;
p.x = rct.bottom;
p.y = rct.right;
ScreenToClient(hWnd, &p);
rct.bottom = p.x;
rct.right = p.y;
hBrush = GetSysColorBrush(COLOR_BTNFACE);
hdc = BeginPaint(hWnd, &ps);
FillRect(hdc, &rct, hBrush);
DeleteObject((HGDIOBJ) hBrush);
ReleaseDC(hWnd, hdc);
break;
Works I think.
I hope.
Oh, well.
Bye!
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
|