Link to home
Start Free TrialLog in
Avatar of blokey
blokey

asked on

Transparent Window

Is there anyway of making a transparent window on a Win32 platform with vc++?

Blokey
Avatar of cdesigner
cdesigner
Flag of Russian Federation image

hmmm
what you want?

same transparent areas?

this can be made with regions
ASKER CERTIFIED SOLUTION
Avatar of Wyn
Wyn

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 blokey
blokey

ASKER

is it possible to give me any examples?

Blokey
Hi blokey !!
   Set the extended window styles for the window i.e
WS_EX_TRANSPARENT  
Specifies that a window created with this style is to be transparent. That is, any windows that are beneath the window are not obscured by the window. A window created with this style receives WM_PAINT messages only after all sibling windows beneath it have been updated.

U can override PreCreateWindow() and set in the CREATSTRUCT of cs.exStyle.
Hi blokey !!
 I am sorry its
cs.dwExStyle = WS_EX_TRANSPARENT;
Agree.
There are two ways.

One is using extra style ws_ex_transparent.When the wm_paint comes,you can only draw the part you want.

The second is using setwindowrgn(),this is more convenient.

E.G:
//First,let's create a region.

HRGN hgn;
hgn=CreateEllipticRgn(0,0,100,100);
 
//apply this region to the window

SetWindowRgn(hwnd,hgn,TRUE);

.............
//delete the created region
DeleteObjetc(hgn);

This example make your window as transparent elliptic contour.
You can use CombineRgn() to create a rgn which make your window has a hole and or so by specifying xor,or,and parameters in this function.

All in all,the region is the area your window appears in.If you construct a text region(using path),your window will transparent inbounding the region.

Best Regards
Wyn