CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Managed C++ and C++/CLI
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Managed C++ and C++/CLI Discuss Managed C++ and .NET-specific questions related to C++.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old July 18th, 2005, 10:23 AM
    djing1985 djing1985 is offline
    Member
     
    Join Date: Nov 2004
    Posts: 37
    djing1985 is an unknown quantity at this point (<10)
    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!!
    Reply With Quote
      #2    
    Old July 18th, 2005, 10:34 AM
    philkr philkr is offline
    Senior Member
     
    Join Date: Jul 2005
    Location: Germany
    Posts: 1,194
    philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)
    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);
    In your window procedure WM_TIMER handler:
    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.
    Reply With Quote
      #3    
    Old July 18th, 2005, 01:41 PM
    djing1985 djing1985 is offline
    Member
     
    Join Date: Nov 2004
    Posts: 37
    djing1985 is an unknown quantity at this point (<10)
    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.
    Reply With Quote
      #4    
    Old July 18th, 2005, 07:54 PM
    SouthernCodeMonkey SouthernCodeMonkey is offline
    Member
     
    Join Date: Feb 2005
    Posts: 106
    SouthernCodeMonkey is on a distinguished road (40+)
    Re: opacity effect

    You could consider using AnimateWindow() with the AW_BLEND flag set.

    Regards.
    Reply With Quote
      #5    
    Old July 19th, 2005, 04:17 AM
    philkr philkr is offline
    Senior Member
     
    Join Date: Jul 2005
    Location: Germany
    Posts: 1,194
    philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)philkr is a splendid one to behold (750+)
    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!
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Managed C++ and C++/CLI


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    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
    Forum Jump


    All times are GMT -5. The time now is 11:49 PM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009