【VC开源代码栏目提醒】:网学会员为广大网友收集整理了,COPYOFAPBARDLG.CPP,希望对大家有所帮助!
// ApBarDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TaskBar.h"
#include "ApBarDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define MOREWORK 1
/////////////////////////////////////////////////////////////////////////////
// CAppBarDlg dialog
CAppBarDlg::CAppBarDlg(CWnd* pParent /*=NULL*/)
: CDialog(CAppBarDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CAppBarDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_bMoving = FALSE;
m_bAppRegistered = FALSE;
}
void CAppBarDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAppBarDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAppBarDlg, CDialog)
//{{AFX_MSG_MAP(CAppBarDlg)
ON_WM_CREATE()
ON_WM_DESTROY()
ON_WM_ACTIVATE()
ON_WM_WINDOWPOSCHANGED()
ON_WM_SIZE()
ON_WM_MOVE()
ON_WM_RBUTTONDOWN()
ON_WM_TIMER()
ON_WM_NCHITTEST()
ON_WM_LBUTTONDOWN()
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONUP()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAppBarDlg message handlers
int CAppBarDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
m_pAppBar = new CAppBar (m_hWnd);
ASSERT (m_pAppBar);
POPTIONS pOptions;
LOGFONT lf;
// Initialize the common control DLL
InitCommonControls();
// Allocate an OPTIONS struct and attach to the appbar
pOptions = (POPTIONS) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(OPTIONS));
if (pOptions)
{
SetWindowLong (m_hWnd, 0, (LONG) pOptions);
}
else
{
return FALSE;
}
pOptions->fAutoHide = FALSE;
pOptions->fOnTop = FALSE;
pOptions->uSide = ABE_TOP;
pOptions->cxWidth = CX_DEFWIDTH;
pOptions->cyHeight = CY_DEFHEIGHT;
// Register the appbar and attach it to the top by default
m_pAppBar->Register ();
m_pAppBar->SetSide (ABE_TOP);
// Create the fonts for drawing in the client area
ZeroMemory (&lf, sizeof(LOGFONT));
lf.lfHeight = 45;
lf.lfEscapement = 2700;
lf.lfOrientation = 0;
lstrcpy (lf.lfFaceName, DEFAULT_FONT);
m_hFontLeft = CreateFontIndirect(&lf);
lf.lfEscapement = 0;
m_hFontTop = CreateFontIndirect(&lf);
return TRUE;
}
void CAppBarDlg::OnDestroy()
{
ASSERT (m_pAppBar);
#ifdef MOREWORK
CDialog::OnDestroy();
#else
POPTIONS pOptions = m_pAppBar->GetAppbarData();
// Make sure the appbar is unregistered
if (m_bAppRegistered)
{
// MOREWORK
// SendMessage(WM_COMMAND, MAKEWPARAM(ID_APPBAR_UNREGISTER, 0), 0L);
}
// Free the OPTIONS struct associated with the appbar
HeapFree(GetProcessHeap(), 0, pOptions);
// Clean up the GDI objects we allocated
DeleteObject(m_hFontTop);
DeleteObject(m_hFontLeft);
// Indicate that the message loop should exit since the main window
// is being destroyed.
// MOREWORK
// PostQuitMessage(0);
#endif
if (m_pAppBar)
{
delete m_pAppBar;
m_pAppBar = NULL;
}
}
void CAppBarDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
ASSERT (m_pAppBar);
#ifdef MOREWORK
CWnd::OnActivate(nState, pWndOther, bMinimized);
#else
APPBARDATA abd;
// Always send the activate message to the system
abd.cbSize = sizeof(APPBARDATA);
abd.hWnd = m_hWnd;
abd.lParam = 0;
SHAppBarMessage(ABM_ACTIVATE, &abd);
// Now determine if we're getting or losing activation
switch (nState)
{
case WA_ACTIVE:
case WA_CLICKACTIVE:
// If we're gaining activation, make sure we're visible
m_pAppBar->UnHide();
KillTimer(IDT_AUTOHIDE);
break;
case WA_INACTIVE:
// If we're losing activation, check to see if we need to autohide.
m_pAppB