how to make window transparent topic posted under Win32 Programming which is a part of Programming category in CFanatic Forum

06-04-2007, 04:12 AM
|
|
Member
|
|
Join Date: May 2007
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
how to make window transparent
hi
i want to know how to make windows transparent . and whatever the text scrolling in that window it appear like only text scrolling.window should not appear. i tried with WS_EX_TRANSPARENT,but it is not working the way i want ,is their any other way to do.please help me out to do this.
|

06-04-2007, 04:48 AM
|
 |
Administrator
|
|
Join Date: Sep 2006
Posts: 1,163
Thanks: 57
Thanked 63 Times in 44 Posts
|
|
Re: how to make window transparent
Just having the property will not help and you need to handle the WM_PAINT to do the transparent drawing.
|

06-04-2007, 04:49 AM
|
 |
Senior Member
|
|
Join Date: May 2007
Posts: 273
Thanks: 16
Thanked 12 Times in 12 Posts
|
|
Re: how to make window transparent
You can have the Dialog as OWNER_DRAW and handle the OnDraw.
|

06-04-2007, 04:50 AM
|
 |
Senior Member
|
|
Join Date: May 2007
Posts: 273
Thanks: 16
Thanked 12 Times in 12 Posts
|
|
Re: how to make window transparent
Quote:
Originally Posted by shabbir
Just having the property will not help and you need to handle the WM_PAINT to do the transparent drawing.
|
Oops. Just did not read your one.
|

06-04-2007, 10:21 PM
|
|
Member
|
|
Join Date: May 2007
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Re: how to make window transparent
Quote:
Originally Posted by shabbir
Just having the property will not help and you need to handle the WM_PAINT to do the transparent drawing.
|
can you please explain what i have to do in WM_PAINT.
|

06-04-2007, 10:56 PM
|
 |
Senior Member
|
|
Join Date: May 2007
Posts: 273
Thanks: 16
Thanked 12 Times in 12 Posts
|
|
Re: how to make window transparent
I will try. You need to paint the Dialog in such a manner that it becomes transparent by using the API's like TransparentBlt
|

06-05-2007, 09:14 PM
|
|
Junior Member
|
|
Join Date: Jun 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Re: how to make window transparent
Maybe I do not know what you are talking about exactly...
But check out the results of this snippet on Windows NT (or XP)
Code:
int translevel = 100; /* 0 - 255 */
SetWindowLong(hwnd,GWL_EXSTYLE,GetWindowLong(h,GWL_EXSTYLE)|WS_EX_LAYERED);
SetLayeredWindowAttributes(hwnd,RGB(0,0,0),translevel, 0x02);
|

06-05-2007, 11:47 PM
|
|
Member
|
|
Join Date: May 2007
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Re: how to make window transparent
Quote:
Originally Posted by tiger12506
Maybe I do not know what you are talking about exactly...
But check out the results of this snippet on Windows NT (or XP)
Code:
int translevel = 100; /* 0 - 255 */
SetWindowLong(hwnd,GWL_EXSTYLE,GetWindowLong(h,GWL_EXSTYLE)|WS_EX_LAYERED);
SetLayeredWindowAttributes(hwnd,RGB(0,0,0),translevel, 0x02);
|
thanks for the help,i tried the above code but it is giving error like this:
error C2065: 'SetLayeredWindowAttributes' : undeclared identifier
error C2065: 'WS_EX_LAYERED' : undeclared identifier.
i included both winuser.h and windows.h.
how to come out of this error.
|

06-06-2007, 12:01 PM
|
|
Junior Member
|
|
Join Date: Jun 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Re: how to make window transparent
ummm.... ummm... let me think....
When I say that it only works in windows NT or later, I mean it -- it won't work in win9x
In the Dev-cpp developing environment, there are certain #define s that you have to put before you #include <windows.h> . For example I would have to put #define _WIN32_WINNT 0x500 before i include. It is definitely supposed to be in the winuser header... hmmm... See, I don't know much about VC so I don't know how it handles those defines like that.
The only thing I can come up with that could possible help is to tell you this.
Open up winuser.h
Search for SetLayeredWindowAttributes
If you find it, find out what #ifdef s are preventing it from being defined
If you don't find it, add it in. The declaration should look like this
WINUSERAPI BOOL WINAPI SetLayeredWindowAttributes(HWND,COLORREF,BYTE,DWOR D);
And the same thing for WS_EX_LAYERED\
if you can't find it -- add it in
#define WS_EX_LAYERED 0x80000
Hope this helps
|

06-08-2007, 12:36 AM
|
|
Member
|
|
Join Date: May 2007
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Re: how to make window transparent
Quote:
Originally Posted by tiger12506
ummm.... ummm... let me think....
When I say that it only works in windows NT or later, I mean it -- it won't work in win9x
In the Dev-cpp developing environment, there are certain #define s that you have to put before you #include <windows.h> . For example I would have to put #define _WIN32_WINNT 0x500 before i include. It is definitely supposed to be in the winuser header... hmmm... See, I don't know much about VC so I don't know how it handles those defines like that.
The only thing I can come up with that could possible help is to tell you this.
Open up winuser.h
Search for SetLayeredWindowAttributes
If you find it, find out what #ifdef s are preventing it from being defined
If you don't find it, add it in. The declaration should look like this
WINUSERAPI BOOL WINAPI SetLayeredWindowAttributes(HWND,COLORREF,BYTE,DWOR D);
And the same thing for WS_EX_LAYERED\
if you can't find it -- add it in
#define WS_EX_LAYERED 0x80000
Hope this helps
|
Thanks for help.i followed what u said,like i searched for setLayeredWindowAttributes in winuser.h that function was not their.
just i added the code in winuser.h like this
typedef BOOL (CALLBACK* SetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWO RD);
and executed my program.then i got the error like this error C2564: 'int (__stdcall *)(struct HWND__ *,unsigned long,unsigned char,unsigned long)' : function-style conversion to builtin type takes only one argument
Error executing cl.exe.
i think it is the problem with the declaration of the function in winuser.h.
can you please tell me how to come out of this error.
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
All times are GMT -5. The time now is 01:56 AM.
|