Solved

Transparent Dialog Box

Posted on 1998-05-15
7
674 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

713 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