Solved

Transparent Dialog Box

Posted on 1998-05-15
7
665 Views
Last Modified: 2013-12-03
I want to take a Dialog I created in the resource editor and use it as the only window in the application (as far as a user is concerned).  The problem is that anything which is not a control in the dialog is transparent.  I am using the Win32 API's.  I have checked in the resource editor, and 'visible' is checked and 'transparent' is not.  Here is the code:

#include<windows.h>
#include<commctrl.h>
#include"resource.h"


HINSTANCE Gclient_instance;
LS_Client* client = 0;
BOOL CALLBACK ClientFunc(HWND,UINT,WPARAM,LPARAM);
LRESULT CALLBACK mydialogproc(HWND,UINT,WPARAM,LPARAM);



int WINAPI WinMain(
      HINSTANCE hInstance, // handle to current instance
      HINSTANCE hPrevInstance, // handle to previous instance
      LPSTR lpCmdLine, // pointer to command line
      int nCmdShow  // show state of window
      ){
      Gclient_instance = hInstance;
      InitCommonControls();
      
      //DialogBox(Gclient_instance,MAKEINTRESOURCE(IDD_CLIENT_WINDOW),HWND_DESKTOP,(DLGPROC)ClientFunc);
      HWND x = CreateDialog(Gclient_instance,MAKEINTRESOURCE(IDD_CLIENT_WINDOW),HWND_DESKTOP,(DLGPROC)ClientFunc);
      MSG Msg;

      while(GetMessage(&Msg,0,0,0))
      {
            TranslateMessage(&Msg);
            DispatchMessage(&Msg);
      }



      return 0;

}




//&&&&&&&&&&&&&&&&&&& Actual Viewed Window &&&&&&&&&&&&&&&&&&//

BOOL CALLBACK ClientFunc(  HWND hwnd,  // handle to dialog box
  UINT uMsg,     // message  
      WPARAM wParam, // first message parameter
  LPARAM lParam  // second message parameter
      )
      
      {
      PAINTSTRUCT ps;
      HDC hDC;
            static LS_Client* clientwin = 0;
            
            /*if(clientwin == 0)
            {
                  HWND lv = GetDlgItem(hwnd,LV_CONTEXT);
                  HWND statcontext = GetDlgItem(hwnd,STATIC_CURRENT_CONTEXT);

                  InitCommonControls();
                  
                  clientwin = new LS_Client(Gclient_instance,LS_CLIENT_MENU);
                  clientwin->SetControls(lv,statcontext);
                  clientwin->GetTarget().AddColumn("Users Whose Password You May Change",0,100);
                  ShowWindow(hwnd,SW_SHOWNORMAL);
                  UpdateWindow(clientwin->GetContext().GetHandle());
                  //(clientwin.GetContext())
            }*/

            switch(uMsg)
            {
                  
                  case WM_PAINT:
                  {
                        //MessageBox(0,"WM_PAINT"," ",MB_OK);
                        hDC=BeginPaint(hwnd,&ps);
                        EndPaint(hwnd,&ps);
                        //ShowWindow(hWnd,SW_HIDE);
                        return(1);
                  }
                  case WM_INITDIALOG:
                  {
                        //DialogBox(Gclient_instance,MAKEINTRESOURCE(IDD_CLIENT_WINDOW),hwnd,(DLGPROC)ClientFunc);
                        //ShowWindow(hwnd,SW_SHOW);
                        //MessageBox(0,"End Init"," ",MB_OK);
                        //return 1;
                        HWND lv = GetDlgItem(hwnd,LV_CONTEXT);
                        HWND statcontext = GetDlgItem(hwnd,STATIC_CURRENT_CONTEXT);

                        //InitCommonControls();

                  
                        clientwin = new LS_Client(Gclient_instance,LS_CLIENT_MENU);
                        clientwin->SetControls(lv,statcontext);
                        clientwin->GetTarget().AddColumn("Users Whose Password You May Change",0,303);
                        //ShowWindow(hwnd,SW_SHOWNORMAL);
                        UpdateWindow(clientwin->GetContext().GetHandle());
                        break;
                  }
                  
                  case WM_COMMAND:
                  {

                        /////////////// SWITCH_JOE ///////////
                        switch(LOWORD(wParam))
                        {
                        
                              case B_SELECT:
                              {
                                    UpdateWindow(clientwin->GetContext().GetHandle());
                              }
                              case B_CHANGE:
                              {
                                    UpdateWindow(clientwin->GetContext().GetHandle());
                              }
                              case M_EXIT:
                              {

                              }

                        }
                        ////////////// ~SWITCH_JOE //////////
                        break;
                  }
                  case WM_DESTROY:
                  {
                        PostQuitMessage(1);
                        break;
                  }




            }//switch
            return 1;
      }









0
Comment
Question by:rwinkler
  • 5
7 Comments
 
LVL 1

Author Comment

by:rwinkler
ID: 1402055
Edited text of question
0
 
LVL 1

Author Comment

by:rwinkler
ID: 1402056
Edited text of question
0
 
LVL 1

Author Comment

by:rwinkler
ID: 1402057
Edited text of question
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Accepted Solution

by:
overworked earned 50 total points
ID: 1402058
You're returning 1 for WM_PAINT when you should be returning FALSE or 0 since returning 1 or TRUE will keep the message from reaching dialog children.
0
 

Expert Comment

by:bbarber
ID: 1402059
I agree with the above.  But here's some more cool code you might want to try at your whim.


   static HBRUSH      Return_Brush;
            case WM_CTLCOLOR:
                switch( HIWORD( lParam ) )
                {
                      case CTLCOLOR_BTN:
                      case CTLCOLOR_STATIC:
                      case CTLCOLOR_DLG:
                            if( hbrBlack != GetTextColor( ( HDC )wParam ) )
                            {
                                  SetTextColor( ( HDC )wParam, RGB( 0, 0, 0 ) );
                            }
                            if( TRANSPARENT != GetBkMode( ( HDC )wParam ) )
                            {
                                  SetBkMode( ( HDC )wParam, TRANSPARENT );
                            }
                            if( hbrGray != GetBkColor( ( HDC )wParam ) )
                            {
                                  SetBkColor( ( HDC )wParam, RGB( 192, 192, 192 ) );
                            }
                            return( Gray_Brush );
                      
                      case CTLCOLOR_MSGBOX:
                      case CTLCOLOR_EDIT :
                            if( LOWORD( lParam ) == GetDlgItem( hDlg, IDD_BOX6 ) ||
                                LOWORD( lParam ) == GetDlgItem( hDlg, IDD_BOX11 )||
                                     LOWORD( lParam ) == GetDlgItem( hDlg, IDD_BOX13 ) )
                            {
                                  if( hbrBlack != GetTextColor( ( HDC )wParam ) )
                                  {
                                        SetTextColor( ( HDC )wParam, RGB( 0, 0, 0 ) );
                                  }
                                  if( TRANSPARENT != GetBkMode( ( HDC )wParam ) )
                                  {
                                        SetBkMode( ( HDC )wParam, TRANSPARENT );
                                  }
                                  SetBkColor( ( HDC )wParam, RGB( 192, 192, 192 ) );
                                  return( Gray_Brush );
                            }
                            if( hbrBlack != GetTextColor( ( HDC )wParam ) )
                            {
                                    SetTextColor( ( HDC )wParam, RGB( 0, 0, 0 ) );
                            }
                            if( TRANSPARENT != GetBkMode( ( HDC )wParam ) )
                              {
                                    SetBkMode( ( HDC )wParam, TRANSPARENT );
                            }
                            if( hbrGray != GetBkColor( ( HDC )wParam ) )
                              {
                                    SetBkColor( ( HDC )wParam, RGB( 255, 255, 255 ) );
                            }
                            return( White_Brush );
                }
                return( ( HBRUSH )NULL );

0
 
LVL 1

Author Comment

by:rwinkler
ID: 1402060
Unfortunately, this gave the same result.  I still get a window which is transparent (ie, invisible), except for the controls.  I have added a message box when either button is pressed, but the message box refuses to acquire focus.  Doh.
0
 
LVL 1

Author Comment

by:rwinkler
ID: 1402061
You were on the right track.  It was the return 1 at the very end of the proc that was the problem...causing it to ignore every other message besides those I'd explicitly handled.  Thanks for the help :)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now