Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,

I am trying the below scenario since a long time but unable to succeed.
Inputs: Dialog box with 2 Picture controls, mfcbutton, slider control and few buttons.

1. I need to add a jpg image as complete background of my dialog box.
Solution: I have achieved this by using CImagePreviewStatic.
Below is the link:
https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0CCMQFjABahUKEwiehpHWmYXGAhULq7wKHeNQABo&url=http%3A%2F%2Fwww.codeproject.com%2FArticles%2F6354%2FA-simple-image-preview-class-using-GDI&ei=XDd4VZ7oMovW8gXjoYHQAQ&usg=AFQjCNEcO0kiW8Ie-voNfaGMIDB2P3D0Ig&bvm=bv.95039771,d.dGc&cad=rja[^]
This is working fine for me.

2. 2nd picture control is positioned centered on top of 1st- I have an Bitmap attached or I draw a graph like temperature measurement etc using OnPaint() with SolidBrush to draw polylines etc.

Based on the Slider control input, I now want to make this 2nd picture control transparent in a way that it fades to some maximum value.
Also, the mfcbutton that I mentioned is having a bitmap added, even its transparency should change with respect to slider control value.

I am using Visual Studio 2010 and MFC C++ only.

Please let me know if you are aware of any solutions.
Thank you in advance.
Posted

1 solution

Finally, its my pleasure to post this answer.
Layered Windows as worked just so amazing for me.

This is resolved.

I have used:
C#
// Make this window 70% alpha
SetLayeredWindowAttributes(hwnd, 0, (255 * 70) / 100, LWA_ALPHA);

If I want the remaining area on the dialog to be made transparent, I will just add the RGB color and in last parameter LWA_ALPHA | LWA_COLORKEY

I have added this on VScroll event of the Slider Control. So that the alpha percentage can be controlled by the position of the slider control.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900