Solved

Transparent Dialog Box

Posted on 1998-05-15
7
676 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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.

 

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

632 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