Results 1 to 5 of 5

Thread: API Color Problem

  1. #1

    Thread Starter
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    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.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  2. #2
    Guest
    I also code in only API and i would also like to know how to do this.

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  4. #4

    Thread Starter
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    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??
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  5. #5
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    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!
    Courgettes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width