Function is used to Show/Hide the TaskBar

// CoolUtils.h

#ifndef __COOLUTILS_H
#define __COOLUTILS_H
#include "stdafx.h"

void gShowHideTaskBar(/*in*/BOOL bHide = FALSE);

HMENU gHideMenu(/*in*/CWnd* pWnd);

BOOL gShowMenuBack(/*in*/HMENU hMenu, /*in*/CWnd* pWnd);

#endif

// CoolUtils.cpp

#include "stdafx.h"
#include "CoolUtils.h"

/****************************************************************************
 * Function Name : gShowHideTaskBar()         *
 * Parameters  : BOOL bHide (flag to toggle Show/Hide of Taskbar)  *
 * Return type  : void             *
 * Purpose   : Function is used to Show/Hide the TaskBar    *
 * Author   : Ashutosh R. Bhatikar (ARB)       *
 * Date written : 20th December 2000         *
 * Modification History :             *
 * Date of modification     Reason       *
 *  25th December 2000    Added methods to Show/Hide menu   *
 ****************************************************************************/

void gShowHideTaskBar(BOOL bHide /*=FALSE*/)
{
 CRect rectWorkArea = CRect(0,0,0,0);
 CRect rectTaskBar = CRect(0,0,0,0);
 
 CWnd* pWnd = CWnd::FindWindow("Shell_TrayWnd", "");

 if( bHide )
 {
  // Code to Hide the System Task Bar
  SystemParametersInfo(SPI_GETWORKAREA,
        0,
        (LPVOID)&rectWorkArea,
        0);
  
  if( pWnd )
  {
   pWnd->GetWindowRect(rectTaskBar);
   rectWorkArea.bottom += rectTaskBar.Height();
   SystemParametersInfo(SPI_SETWORKAREA,
         0,
         (LPVOID)&rectWorkArea,
         0);

   pWnd->ShowWindow(SW_HIDE);
  }
 }
 else
 {
  // Code to Show the System Task Bar
  SystemParametersInfo(SPI_GETWORKAREA,
        0,
        (LPVOID)&rectWorkArea,
        0);
  if( pWnd )
  {
   pWnd->GetWindowRect(rectTaskBar);
   rectWorkArea.bottom -= rectTaskBar.Height();
   SystemParametersInfo(SPI_SETWORKAREA,
         0,
         (LPVOID)&rectWorkArea,
         0);

   pWnd->ShowWindow(SW_SHOW);
  }
 }
}

/****************************************************************************
 * Function Name : gHideMenu()           *
 * Parameters  : CWnd* pWnd (Window associated with the menu)   *
 * Return type  : HMENU             *
 * Purpose   : Function hides the menu associated with pWnd   *
 * Author   : Ashutosh R. Bhatikar (ARB)       *
 * Date written : 25nd December 2000         *
 * Modification History :             *
 * Date of modification     Reason       *
 ****************************************************************************/

HMENU gHideMenu(/*in*/CWnd* pWnd)
{
  HMENU hMenu = ::GetMenu(pWnd->GetSafeHwnd());
  if (hMenu != NULL)
  {
    // Invalidate before SetMenu since we are going to replace
    //  the frame's client area anyway
    pWnd->Invalidate();
    pWnd->SetMenu(NULL);
    if( pWnd->IsKindOf(RUNTIME_CLASS(CFrameWnd)) )
    {
       CFrameWnd* pFrameWnd = (CFrameWnd*)pWnd;
       // avoid any idle menu processing
       pFrameWnd->m_nIdleFlags &= ~CFrameWnd::idleMenu;
    }
    return hMenu;
  }
  return NULL;
}

/****************************************************************************
 * Function Name : gShowMenuBack()          *
 * Parameters  : HMENU hMenu (Handle of the menu which was hidden)  *
 *       CWnd* pWnd (Window associated with the menu)   *
 * Return type  : BOOL             *
 * Purpose   : Function shows back the menu associated with pWnd  *
 * Author   : Ashutosh R. Bhatikar (ARB)       *
 * Date written : 25nd December 2000         *
 * Modification History :             *
 * Date of modification     Reason       *
 ****************************************************************************/

BOOL gShowMenuBack(/*in*/HMENU hMenu, /*in*/CWnd* pWnd)
{
 // put the menu back in place if it was removed before
  if (hMenu != NULL)
  {
    // Invalidate before SetMenu since we are going to replace
    //  the frame's client area anyway
    pWnd->Invalidate();
    ::SetMenu(pWnd->GetSafeHwnd(), hMenu);
    return TRUE;
  }
  return FALSE;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值