CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Join Date
    Sep 2011
    Posts
    75

    Why are my windows transparent?

    Hi All,

    I have several possible related problems, all of them having to do with controls dissapearing and or drawing improperly.

    1)

    First, I have a modeless dialog box that draws everything underneath it. It still has a frame and everything
    here is the .rc file:
    Code:
    IDD_GAL_SAVE DIALOGEX 0, 0, 316, 333
    STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU |WS_VISIBLE
    CAPTION "Gallery Information"
    FONT 8, "MS Shell Dlg", 400, 0, 0x1
    BEGIN
        DEFPUSHBUTTON   "OK",IDOK,106,312,50,14
        PUSHBUTTON      "Cancel",IDCANCEL,160,312,50,14
        CONTROL         "",IDC_SGAL_PREV,"Static",SS_BITMAP | SS_CENTERIMAGE| SS_REALSIZEIMAGE ,181,20,100,100
        PUSHBUTTON      "Take Screenshot...",IDC_SGAL_SHOT,216,126,85,14
        EDITTEXT        IDC_SGAL_DESCR,16,23,141,272,ES_AUTOHSCROLL
    	 COMBOBOX        IDC_SGAL_APPSEL,181,164,117,150,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP
        GROUPBOX        "Description",IDC_SGAL_INFO,7,7,159,297
        GROUPBOX        "Preview Image",IDC_SGAL_PICS,170,7,139,138
        GROUPBOX        "Applications",IDC_SGAL_APP,171,151,138,155
    END

    I have tried using WM_ctlcolordlg and wm_ctlcolorstatic, etc. and tried setting background mode and color to the default 3D face brush color, however nothing paints it in....

    2)

    I have a tab control that has a dialog box (no sys_menu or frame, just a gray box) that occupies the display area of each tab page. Each tab click hides the other page and shows the other. After each click, the group static controls all draw items from the previously displayed dialog box within them.

    3) I have a toolbox control that utilizes an image list attached to the frame window (i am using an mdi architecture), but the toolbox will dissapear randomly, and i have to drag another window over it for it to show again...

    I have created many many dialog boxes in my application but only these windows are giving me trouble for some reason. I feel like it may have something to do with the static group box controls...

    Thanks for any help!

  2. #2
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Why are my windows transparent?

    I feel like it may have something to do with the static group box controls...
    Well, and I believe that's something to do with your dialog/window procedure(s).

    I have tried using WM_ctlcolordlg and wm_ctlcolorstatic, etc. and tried setting background mode and color to the default 3D face brush color, however nothing paints it in....
    What this info has to do with your problem?
    Best regards,
    Igor

  3. #3
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: Why are my windows transparent?

    Quote Originally Posted by kingting View Post
    I have a tab control that has a dialog box (no sys_menu or frame, just a gray box) that occupies the display area of each tab page. Each tab click hides the other page and shows the other.
    What is your "tab pages"? Dialogs or something else?
    Last edited by ovidiucucu; May 8th, 2012 at 05:23 AM.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  4. #4
    Join Date
    Sep 2011
    Posts
    75

    Re: Why are my windows transparent?

    the pages of the tab display are dialog boxes.

    By "paints" I actually meant that using SetBkMode(), SetBkColor(), FillRect(), returning the hbrush that is the COLOR_3DFACE does not work for any of them

  5. #5
    Join Date
    Oct 2010
    Posts
    32

    Re: Why are my windows transparent?

    SetBkMode() does not require a brush but a keyword (OPAQUE or TRANSPARENT)
    SetBkCorlor() does not use a brush but a colorreference

    Don't know about your call to FillRect() though.

    Norbert

  6. #6
    Join Date
    Sep 2011
    Posts
    75

    Re: Why are my windows transparent?

    Actually I just fixed these issues, but the toolbar redrawing issue remains. Do I have to subclass the toolbar control?

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Why are my windows transparent?

    Quote Originally Posted by gummibaer View Post
    Don't know about your call to FillRect() though.
    FillRect API does use HBRUSH, however in most cases it could be a temp brush as in MSDN example
    Code:
    FillRect(hdc, &rect, (HBRUSH) (COLOR_WINDOW+1));
    Victor Nijegorodov

  8. #8
    Join Date
    Oct 2010
    Posts
    32

    Re: Why are my windows transparent?

    Thanks Victor.

    Kingting:

    When you hide your control and uncover it again, then your dialogprocedure receives a WM_PAINT-message. Apparently this is what you must create on your own. Seems you should include a call to InvalidateRect (..).

    Norbert

  9. #9
    Join Date
    Sep 2011
    Posts
    75

    Re: Why are my windows transparent?

    I fill the rectangle of the group box in my WM_PAINT message, however only the small static text (the group label) gets filled in with the brush. My tool bars constantly lose the back gray color as well, yet the buttons remain floating there.

    Thanks for all the help!

  10. #10
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Why are my windows transparent?

    Quote Originally Posted by kingting View Post
    I fill the rectangle of the group box in my WM_PAINT message, however only the small static text (the group label) gets filled in with the brush.
    how do you fill it? Could you show your code?
    Victor Nijegorodov

  11. #11
    Join Date
    Sep 2011
    Posts
    75

    Re: Why are my windows transparent?

    Code:
    case WM_PAINT:
    {
    
    	HDC hdc  = GetDC(hwnd);
    	RECT rect;
    	GetWindowRect(GetDlgItem(hwnd, ID_SM_SKETCH),&rect); 
    	FillRect(hdc, &rect, CreateSolidBrush(GetSysColor(COLOR_3DFACE)));
    	ReleaseDC(hwnd,hdc);
    
    	return FALSE;
    }
    break;

  12. #12
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Why are my windows transparent?

    Incorrect!
    You have to use BeginPaint to get the HDC, not the GetDC.
    Victor Nijegorodov

  13. #13
    Join Date
    Sep 2011
    Posts
    75

    Re: Why are my windows transparent?

    The two do not do the same thing?


    I will try this. Thanks!

  14. #14
    Join Date
    Sep 2011
    Posts
    75

    Re: Why are my windows transparent?

    Hello everybody, I fixed the painting problem. However, my toolbar that I created keeps dissapearing whenever a window passes over it, and it requires me to minimize and restore the window for it to show up again. Any clues?

  15. #15
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Why are my windows transparent?

    Quote Originally Posted by kingting View Post
    my toolbar that I created keeps dissapearing
    Toolbar or "toolbox"?
    How did you create it?
    What type of application are you using?
    Victor Nijegorodov

Page 1 of 2 12 LastLast

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

Featured