Transparent Window

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

Blokey
blokeyAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
WynConnect With a Mentor Commented:
Use region APIs

First construct a region ,then setwindowrgn() to set it.

Regards
Wyn
0
 
cdesignerCommented:
hmmm
what you want?

same transparent areas?

this can be made with regions
0
 
blokeyAuthor Commented:
is it possible to give me any examples?

Blokey
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
akalmaniCommented:
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.
0
 
cdesignerCommented:
0
 
akalmaniCommented:
Hi blokey !!
 I am sorry its
cs.dwExStyle = WS_EX_TRANSPARENT;
0
 
WynCommented:
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
 
 
0
All Courses

From novice to tech pro — start learning today.