Solved

Transparent Dialog Box

Posted on 1998-05-15
7
668 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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…

911 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

17 Experts available now in Live!

Get 1:1 Help Now