CFanatic

Go Back   CFanatic > Programming > Win32 Programming

Join CFanatic Forum Now

how to make window transparent topic posted under Win32 Programming which is a part of Programming category in CFanatic Forum
Reply
 
Thread Tools Display Modes
  #1  
Old 06-04-2007, 04:12 AM
Member
 
Join Date: May 2007
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
vidhya is on a distinguished road
| More
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.
Reply With Quote
  #2  
Old 06-04-2007, 04:48 AM
shabbir's Avatar
Administrator
 
Join Date: Sep 2006
Posts: 1,163
Thanks: 57
Thanked 63 Times in 44 Posts
shabbir has a spectacular aura aboutshabbir has a spectacular aura about
| More
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.
Reply With Quote
  #3  
Old 06-04-2007, 04:49 AM
coderzone's Avatar
Senior Member
 
Join Date: May 2007
Posts: 273
Thanks: 16
Thanked 12 Times in 12 Posts
coderzone is on a distinguished road
| More
Re: how to make window transparent

You can have the Dialog as OWNER_DRAW and handle the OnDraw.
Reply With Quote
  #4  
Old 06-04-2007, 04:50 AM
coderzone's Avatar
Senior Member
 
Join Date: May 2007
Posts: 273
Thanks: 16
Thanked 12 Times in 12 Posts
coderzone is on a distinguished road
| More
Re: how to make window transparent

Quote:
Originally Posted by shabbir View Post
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.
Reply With Quote
  #5  
Old 06-04-2007, 10:21 PM
Member
 
Join Date: May 2007
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
vidhya is on a distinguished road
| More
Re: how to make window transparent

Quote:
Originally Posted by shabbir View Post
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.
Reply With Quote
  #6  
Old 06-04-2007, 10:56 PM
coderzone's Avatar
Senior Member
 
Join Date: May 2007
Posts: 273
Thanks: 16
Thanked 12 Times in 12 Posts
coderzone is on a distinguished road
| More
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
Reply With Quote
  #7  
Old 06-05-2007, 09:14 PM
Junior Member
 
Join Date: Jun 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
tiger12506 is on a distinguished road
| More
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);
Reply With Quote
  #8  
Old 06-05-2007, 11:47 PM
Member
 
Join Date: May 2007
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
vidhya is on a distinguished road
| More
Re: how to make window transparent

Quote:
Originally Posted by tiger12506 View Post
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.
Reply With Quote
  #9  
Old 06-06-2007, 12:01 PM
Junior Member
 
Join Date: Jun 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
tiger12506 is on a distinguished road
| More
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
Reply With Quote
  #10  
Old 06-08-2007, 12:36 AM
Member
 
Join Date: May 2007
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
vidhya is on a distinguished road
| More
Re: how to make window transparent

Quote:
Originally Posted by tiger12506 View Post
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.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
transparent MFC activeX control praxisist MFC Programming 1 05-07-2008 03:15 AM
How to make colored output jan1024188 C Programming 2 09-12-2007 11:38 PM
how to make window to not appear on taskbar vidhya Win32 Programming 4 06-06-2007 01:21 PM
how to make a window to always on top of all the other window vidhya Win32 Programming 11 06-05-2007 09:25 PM
how to destroy or close the window and create the new window vidhya Win32 Programming 3 05-24-2007 11:40 PM

 

Advertisement

CFanatic Search
Custom Search

Advertisement

All times are GMT -5. The time now is 01:56 AM.



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Cfanatic.com is a premier member of the IDG TechNetwork. For advertising opportunities contact here
Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board