-
November 20th, 2003, 02:18 PM
#1
Pointing Hwnd to a top-level dialog
Hi...im trying to use a transparency code on my program...
Code:
// Set WS_EX_LAYERED on this window
SetWindowLong(hwnd, GWL_EXSTYLE,
GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
// Make this window 70% alpha
SetLayeredWindowAttributes(hwnd, 0, (255 * 70) / 100, LWA_ALPHA);
But it seens to me that i cant point hwnd to a top-level dialog...
Can someone help me please?!
P.S.: Newbie speaking...
Regards,
Alexei
-
November 20th, 2003, 02:34 PM
#2
How are you getting the hWnd, and where is this code?
-
November 20th, 2003, 02:37 PM
#3
Code is from MSDN library
hwnd was on that page... im not sure if im using it right...
I need the transparent dialog box..
My prog has only single dialog box... i want it to be transparent (The perfect solution will be making it transparent when its not active)...
Regards,
Alexei
-
November 20th, 2003, 02:41 PM
#4
the handle is a member variable of your dialog class.
Use m_hWnd instead.
Wakeup in the morning and kick the day in the teeth!! Or something like that.
"i don't want to write leak free code or most efficient code, like others traditional (so called expert) coders do."
-
November 20th, 2003, 02:47 PM
#5
Okej... but still... im not sure how to...
Can you please modify this code so it will make a window transparent when i click on a button?!
I wrote it like this but it doesnt really work
Code:
void CFavoritesDlg::OnButton1()
{
// Set WS_EX_LAYERED on this window
SetWindowLong(m_hWnd, GWL_EXSTYLE,
GetWindowLong(m_hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
// Make this window 70% alpha
SetLayeredWindowAttributes( 0, (255 * 70) / 100, LWA_ALPHA);
}
Regards,
Alexei
-
November 20th, 2003, 02:56 PM
#6
What exactly isn't working about it? I dropped that code in a test project and it works fine...
Are you sure you're using Windows 2000 or later?
-
November 20th, 2003, 02:59 PM
#7
Im using Win XP...
I just dont know how to use this thingy...
all i did is made a dialog base program...
then i put a button... creat a function for that button... in that buttons function i wrote
Code:
void CFavoritesDlg::OnButton1()
{
// Set WS_EX_LAYERED on this window
SetWindowLong(m_hWnd, GWL_EXSTYLE,
GetWindowLong(m_hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
// Make this window 70% alpha
SetLayeredWindowAttributes( 0, (255 * 70) / 100, LWA_ALPHA);
}
Nothing more...
And i get a linkin problem now... before i just had an error...
Regards,
Alexei
-
November 20th, 2003, 03:02 PM
#8
Add this line at the beginning of your OnButton1 function:
SetWindowText("Window should now be transparent.");
and see if the title of the window changes when you click the button.
Also, it'd help a LOT if you would say what errors you are getting.
-
November 20th, 2003, 03:06 PM
#9
Sure -- FATAL LINKING ERROR
P.S.: .NET studio starts piising me off..lol
Regards,
Alexei
-
November 20th, 2003, 03:07 PM
#10
Have you tried completely rebuilding the solution? (i.e. Clean Solution, Build Solution)
-
November 20th, 2003, 03:09 PM
#11
Working now!
Okej... thanx for help with this problem... its working... all i needed is a reboot...lol
But more advanced problem_! Making it transparent ONLY When its not active...
How shall i do that?!
I mean when isa active -- it will be 100% visible...
But when not... about 70% visible...
Plus Button1 only turns this on...
Possible to do that?!
Regards,
Alexei
-
November 20th, 2003, 03:41 PM
#12
Trap the WM_GETFOCUS and WM_KILLFOCUS messages; in WM_GETFOCUS, call your transparency code. In WM_KILLFOCUS, call SetWindowLong() and remove the WS_EX_LAYERED flag.
Or you can call UpdateLayeredWindow() and set the transparency to 0 when you get a WM_KILLFOCUS.
-
November 20th, 2003, 03:47 PM
#13
okej... thanx.. i will try to do that...
Bzway... How do i open a ClassWizard?? im on a .NET 2003 now... i had VS 6.0 before... cant find anything like that...
Regards,
Alexei
-
November 20th, 2003, 04:37 PM
#14
Still cant do that...Somehow i just dont get how to do that :S
Trap it... how?!
Where shall i put the code and WHAT code?!
Regards,
Alexei
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|