Window Animation
Site Map Feedback

Download:

Up Controls Files Moving Data

Animate the Title Bar as your Application is Minimized (like Windows Explorer)

Most of this class is code to find the System Tray Location - the rest is easy. Normally when you Minimize, Maximize, or Restore a Window you see the Window's Title Bar animate across the screen but when you use Window Messages such as ShowWindow(SW_RESTORE); the system doesn't animate the Title Bar any more. This class add the Window's Title Bar Animation. It was designed to be used with the CTrayIcon class which Minimizes an Application's Main Window to the System Tray in the Task Bar. Since the Minimize and Restore is then being done by SC_MINIMIZE and SC_RESTORE commands the animation is no longer shown for these operations.

To allow your application to animate its title bar when you Minimize and Restore (like Windows Explorer does) Create an instance of CWndAnimator in your main window's header: CWndAnimator WndAnimator(); Then if you are creating a Dialog Application, in OnInitDialog() WndAnimator.SetWnd(this); and call each animation function appropriately (this example is for a Dialog Application):

void CMyDlg::OnCancel() {WndAnimator.Close();  CDialog::OnCancel();}
void CMyDlg::OnShow  () {WndAnimator.Restore();}
void CMyDlg::OnSysCommand(UINT nID, LPARAM lParam) {
  switch(nID & 0xFFF0) {
    case IDM_ABOUTBOX: CAboutDlg().DoModal (); return;
    case SC_MINIMIZE:  WndAnimator.Minimize(); return;
    case SC_RESTORE:   if(!IsZoomed()) {WndAnimator.Restore(); return;} // Only use our animation for restoring from the TaskBar
    default: CDialog::OnSysCommand(nID, lParam); return;
} }

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.