SetBkMode function does not work!

This is a discussion on SetBkMode function does not work! within the Windows Programming forums, part of the Platform Specific Boards category; My window has a grey background, and yet the SetBkMode is not doing anything, instead the text background is still ...

  1. #1
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342

    Question SetBkMode function does not work!

    My window has a grey background, and yet the SetBkMode is not doing anything, instead the text background is still white. Why isn't this working? The compiler doesn't chatch any errors or warnings.

    HDC hdcStatic = (HDC)wParam;
    TextOut(hdc, 20, 20, "Twelve", 12);
    SetTextColor(hdcStatic, RGB(255, 255, 255));
    SetBkMode(hdcStatic, TRANSPARENT);

    Thanks, August.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,691
    So what are you drawing to?
    "hdc" or "hdcStatic"?

    If "hdc" is supposed to be "hdcStatic", you'll want to call TextOut() after you've set the text color and background mode.

    gg

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,691
    Also, the last parameter to TextOut() is the length of the string, which should be 6.

    gg

  4. #4
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    Okay, I have changed it to this, but nothing is happening.

    HDC hdcStatic = (HDC)wParam;
    SetBkMode(hdcStatic, TRANSPARENT);
    SetTextColor(hdcStatic, RGB(255, 255, 255));
    TextOut(hdc, 20, 20, "Twelve", 6);

  5. #5
    I am me, who else?
    Join Date
    Oct 2002
    Posts
    250
    Hmmm well to my knowledge transparent static controls do not work correctly. When I tried to use them they failed. However I found some code on using transparent static controls on I believe codeguru.com. Search for it on google... hopefully you will find it.

  6. #6
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,691
    What is the end result that you are trying to achieve?
    What message is being handled in that code? WM_CTLCOLORSTATIC?
    Why are you calling TextOut() on "hdc" and not "hdcStatic"??

    What is the end result that you are trying to achieve?

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 09:18 PM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 04:06 PM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  5. Change this program so it uses function??
    By stormfront in forum C Programming
    Replies: 8
    Last Post: 11-01-2005, 08:55 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21