How do you skin a window?

This is a discussion on How do you skin a window? within the Windows Programming forums, part of the Platform Specific Boards category; Is there an easy way to skin all the windows in an app? I have my controls set up as ...

  1. #1
    Registered User Invincible's Avatar
    Join Date
    Feb 2002
    Posts
    210

    How do you skin a window?

    Is there an easy way to skin all the windows in an app? I have my controls set up as child windows, and I've added a bmp to the main window. But this leaves all my static controls bare. Is there a way I can skin right over the top of these without skinning each seperate control. And optionally, omitt some of the controls?

    I added the bitmap to my windows registration like this:


    Code:
    background.lbStyle =BS_PATTERN;
    background.lbHatch = (long) LoadImage(hInst, "Bitmap.bmp", 
    IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
    wcx.hbrBackground = CreateBrushIndirect(&background);
    I would have thought the child/control windows would inherit the bitmap. I was wrong.

    If there is no easy way to make the child windows inherit the bitmap, then how would you go about preserving the layout of the bitmap?
    "The mind, like a parachute, only functions when open."

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    25
    look into handling the OnPaintMessage for the child windows...
    and erase the background from there each time this is the only way that I can think of....
    inZane
    --true programmer's don't comment--
    --programmer wannabes complain about it--

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    46
    Why not just use a transparent brush for the child windows? Wouldn't that allow the image of the main window to be seen?

  4. #4
    Registered User Invincible's Avatar
    Join Date
    Feb 2002
    Posts
    210
    good ideas, I'll try them both. thanks
    "The mind, like a parachute, only functions when open."

  5. #5
    Registered User Invincible's Avatar
    Join Date
    Feb 2002
    Posts
    210
    Wow. This is just crazy. Trying to do anything in Win32 is like pulling teeth. You practically have to build you application around the style of window you want. I tried WS_EX_TRANSPARENT and it seems to have no effect on my controls. Can't erase the background in OnPaint(), even if I could it would erase the text in my static control. There doesn't seem to be an easy way to do this. I had some success with using a different style of static control, but it either covered my caption or screwed up the formatting. And after all that, when text drawn to the control, the characters still had the original control color around them. Maybe if I handle a device context I can get the effect I want. Anyone have any more suggestions on how to go about doing this?
    "The mind, like a parachute, only functions when open."

  6. #6
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    The child wnd's won't 'inherit' the bitmap, you will either have to subclass the controls and paint them yourself or at least prevent windows from painting their backgrounds, or use owner-drawn controls. WM_DRAWITEM is the important message in this regard.

    I would have expected the WS_EX_TRANSPARENT style to help out with some controls. If it's static controls then perhaps handling the WM_CTLCOLORSTATIC (there are analagous msgs for other controls) might work:

    SetBkMode((HDC)wParam, TRANSPARENT);

    edit: use the above fn within the handler.

  7. #7
    Registered User Invincible's Avatar
    Join Date
    Feb 2002
    Posts
    210
    Ken saves the day again

    I handled WM_CTLCOLORSTATIC and passed the SetBkMode((HDC) wParam, TRANSPARENT) ... but initially it didn't work. I had to change all my static controls to the SS_SIMPLE style before it would work properly, which messes up my formatting a bit (something I can live with because I now have an Iceman background on my app) but can you think of any reason the SS_RIGHT, CENTER, and LEFT styles would cause a call to SetBkMode to be invalid?
    "The mind, like a parachute, only functions when open."

  8. #8
    Registered User Invincible's Avatar
    Join Date
    Feb 2002
    Posts
    210
    Ok ... see this is exactly what I'm talking about with the API. I ran into another problem using the simple style. My static controls weren't being redrawn on WM_SETTEXT. So I was getting overlapping characters. Now read this straight from MSDN:

    SS_SIMPLE Designates a simple rectangle and displays a single line of text flush-left in the rectangle. The line of text cannot be shortened or altered in any way. (The controlís parent window or dialog box must not process the WM_CTLCOLOR message.)
    Which is exactly what I had to do to get the SetBkMode() to even work... I get more confused everyday.
    "The mind, like a parachute, only functions when open."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  2. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 10:06 AM
  3. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 10:50 AM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 09:01 PM

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