| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| Managed C++ and C++/CLI Discuss Managed C++ and .NET-specific questions related to C++. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
opacity effect
Hi guys,
Is there anyway on start up of the progarm to make the progarm opacity 0% then merge in to 100% hence creating the effect of it comming form no where?? I know i will need a timer and on start up set the timere to regulate it but i dont know how to do it in code. Pls someone help Mark ALSO PLEASE COULD YOU LOOK AT MY OTHER THREADS I NEED HELP BAD!! |
|
#2
|
|||
|
|||
|
Re: opacity effect
Declare a global BYTE nAlpha = 0 then
On window initialization: Code:
SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED); SetLayeredWindowAttributes(hWnd, 0, nAlpha, LWA_ALPHA); SetTimer(hWnd, 1, 10, NULL); Code:
//...
case WM_TIMER:
nAlpha++;
SetLayeredWindowAttributes(hWnd, 0, nAlpha, LWA_ALPHA);
if(nAlpha == 255)
{
SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) & ~WS_EX_LAYERED);
KillTimer(hWnd, 1);
}
break;
__________________
Please don't forget to rate users who helped you! Last edited by philkr; July 18th, 2005 at 10:43 AM. |
|
#3
|
|||
|
|||
|
Re: opacity effect
hi,
Thanks for that but i cant get it to work pls could you have a look at this i think i have put things in the wornge place but because im new i dont knwo what. ************************************************************************************************************************ } private: System::Void tabControl1_SelectedIndexChanged(System::Object * sender, System::EventArgs * e) { } private: System::Void openFileDialog1_FileOk(System::Object * sender, System::ComponentModel::CancelEventArgs * e) { } // load button to load jpg into checkboxs private: System::Void button1_Click(System::Object * sender, System::EventArgs * e) { } private: System::Void Form1_Load(System::Object * sender, System::EventArgs * e) {BYTE nAlpha = 0; SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED); SetLayeredWindowAttributes(hWnd, 0, nAlpha, LWA_ALPHA); SetTimer(hWnd, 1, 10, NULL); } private: System::Void timer1_Tick(System::Object * sender, System::EventArgs * e) {case WM_TIMER: nAlpha++; SetLayeredWindowAttributes(hWnd, 0, nAlpha, LWA_ALPHA); if(nAlpha == 255) { SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) & ~WS_EX_LAYERED); KillTimer(hWnd, 1); } break; } }; } 888888888888888888888888888888888888888888888888 Also please could you explain how your code works thanks. |
|
#4
|
|||
|
|||
|
Re: opacity effect
You could consider using AnimateWindow() with the AW_BLEND flag set.
Regards. |
|
#5
|
|||
|
|||
|
Re: opacity effect
I think the part in Form_Load is in the right place. The problem is that I don't know how to setup a timer in .NET. Well I think timer1_Tick would be the timer function. Then first remove the case and break line. Left are three things you have to find because my solution is not for .NET. You have to find the .NET equivalent for SetTimer(), KillTimer() and HWND.
How my code should work: The first part: 1) Give the window the transparency ability 2) Set opacity to 0 (invisible) 3) Setup a timer The second part goes in the timer handler: 1) Forget the case WM_TIMER: You don't need that if you have a special timer function instead of window procedure. 2) Raise opacity a bit. 3) Apply new opacity. if-statement) Check if opacity 100%, if so we're done, disable transparency ability and kill timer break) the same like 1)
__________________
Please don't forget to rate users who helped you! |
![]() |
| Bookmarks |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|