Link to home
Start Free TrialLog in
Avatar of bradsoblesky
bradsoblesky

asked on

The transparent Dialog

when i make a transparent dialog doing all this:

BOOL CWhatisthisDlg::OnEraseBkgnd(CDC* pDC)
{
//over ride OnErase

//return CDialog::OnEraseBkgnd(pDC);

return TRUE;
}

BOOL CWhatisthisDlg::PreCreateWindow(CREATESTRUCT& cs)
{
cs.dwExStyle = WS_EX_TRANSPARENT;
cs.style = WS_BORDER | WS_CAPTION;
      
return CDialog::PreCreateWindow(cs);
}

void CWhatisthisDlg::OnMove(int x, int y)
{
CDialog::OnMove(x, y);
      
Invalidate();
UpdateWindow();
      
}

My problem is when i move the dialog if i move it a short distance it shows the dialog in it's previous position and not what's behind it. if you could create a quick program and edit the sections i posted above you would see what it is i'm trying to accomplish, i do not wish to create a region, i want the dialog to appear like it's glass when you click on it you are still clicking on the dialog, what i have now works fine but as you can see when you move it you can see where it was previously.

Avatar of vachooho
vachooho
Flag of United States of America image

ASKER CERTIFIED SOLUTION
Avatar of hiap_ho
hiap_ho

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hiap_ho
hiap_ho

http://www.codeguru.com/dialog/transparent_dialog.shtml
I have tried above code before and to my disappointment, some of the part is not transparant. And when you tried to reduced the size of the dialog box, well it leaves some messy drawing out of the dialog box =(
Ups forget to tell you something, do put some color at the spot where you want anything to appear. Let's say you title bar, or button or edit box ? or maybe some parts of the dialog box where you want it to appear ? It's a bit difficult to make the adjustment though, but it's really is transparant, and transparant at the place you want it to be =)

Have a nice day,

Hiap Ho
Avatar of bradsoblesky

ASKER

What happens when you click on the transparent area? If it selects what is in the background this is not what i want. I only want the dialog to appear transparent but really be like it has a glass window you can see through it but it's still there.
On more things the function is not very perfect yet. It'll leave some white patches some spaces to the low right of the transparant color if you use the dialog box with frame and title bar. If you use it with dialog box without title bar and without frame, it will work perfectly.

Regards,

Hiap Ho
200 points requires at least a correct answer i wish to repost and give more details so it can be answered.
This question has a deletion request Pending
This question no longer is pending deletion
To eliminate this problem just adjust posx and posy value in the OnPaint function

      BitBlt(dc,0,0,bm.bmWidth,bm.bmHeight,memdc,posx,posy,SRCCOPY);

Regards,

Hiap Ho

You don't need to delete the question, you can just edit it =) and all of us will be gladly help you
For this case, it will be a blank and won't appear as a glass window.
Here is an idea, but I'm not sure how to do it. Capture the screen into memory dc, then whenever you move, you'll call repaint that will repaint your dialog background.
Edited text of question.
I've done that, but it does the same thing unless i hide the dialog capture the screen then show it and paint to it which is not prefered.
For this case, it will be a blank and won't appear as a glass window.
Here is an idea, but I'm not sure how to do it. Capture the screen into memory dc, then whenever you move, you'll call repaint that will repaint your dialog background.
ups some error in my connection
repeated comments, sorry
see MS KB article

INFO: Transparent Windows
ID: Q92526
 
Note that Win2000 directly supports transparent (and semi-transparent) windows (that is sorta-how it does the shadowing on the mouse pointer).

Win98 is _supposed_ to support some of the new Win2000 features in this area (eg. transition effect) but although you can make them compile and build, at run-time it just doesn't work.
Also, is it important that you allow the dialog to be dragged?

If not then just force it to be stationary (fairly easy) and then there is no problem.

If you DO wnat to make it draggable, one possibility while movement is to hide, move, capture the background and show. in response to dragging the window.  The problem there is that you get some flicker and poor mouse tracking as you drag.

You can make this a bit better by drawing an outline frame when moving and using a timer so that the dialog does not get made visible again until the user has left it alone for a couple of hundred milli-seconds.
It's dissapointing to post my last 200 points to a question and not get an answer worth 50 but have to give the 200 to someone unfort.