Windows/MFC

CMuLeftMenu

aucd29 2013. 10. 2. 18:20
//
// DATE    : June 25, 2007 21:7:45
// CODER : aucd29
// 
// -----------------------------------------------------------
// NOTE : July 16, 2007 21:7:46
// -----------------------------------------------------------
// * Location tracking이 시작되면 Menu 기능을 멈추어야 하
// 므로 ... 클래스를 생성한다.
//

#include "StdAfx.h"
#include "Main Unit Manager.h"
#include "MuLeftMenu.h"

CMuLeftMenu::CMuLeftMenu(void)
{

}

CMuLeftMenu::~CMuLeftMenu(void)
{
}

BEGIN_MESSAGE_MAP(CMuLeftMenu, CMenuCustomDraw)
    ON_WM_LBUTTONDOWN()
    ON_WM_LBUTTONUP()
    ON_WM_MOUSEMOVE()
    ON_MESSAGE(WM_MOUSELEAVE, OnMouseLeave)
END_MESSAGE_MAP()


void CMuLeftMenu::OnLButtonDown(UINT nFlags, CPoint point)
{
    if (!g_cfg.m_bEnableLocationTracking)
    {
        CMenuCustomDraw::OnLButtonDown(nFlags, point);
    }
}

void CMuLeftMenu::OnLButtonUp(UINT nFlags, CPoint point)
{
    if (!g_cfg.m_bEnableLocationTracking)
    {
        CMenuCustomDraw::OnLButtonUp(nFlags, point);
    }
}

void CMuLeftMenu::OnMouseMove(UINT nFlags, CPoint point)
{
    if (!g_cfg.m_bEnableLocationTracking)
    {
        CMenuCustomDraw::OnMouseMove(nFlags, point);
    }

    TRACKMOUSEEVENT tme;
    tme.cbSize = sizeof(TRACKMOUSEEVENT);
    tme.dwFlags = TME_LEAVE;
    tme.hwndTrack = this->m_hWnd;
    ::_TrackMouseEvent(&tme);
}

LRESULT CMuLeftMenu::OnMouseLeave(WPARAM wParam, LPARAM lParam)
{
    if (!g_cfg.m_bEnableLocationTracking)
    {
        CMenuCustomDraw::OnMouseLeave(wParam, lParam);
    }

    return TRUE;
}


BOOL CMuLeftMenu::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
    //
    // Location tracking 때 Mouse 모양이 화살표로 나타나게 하려고
    // 생성
    //
    if (!g_cfg.m_bEnableLocationTracking)
    {
        return CCustomControl::OnSetCursor(pWnd, nHitTest, message);
    }

    return TRUE;
}

/////////////////////////////////////////////////////////////////////////////

#pragma once
#include "menucustomdraw.h"

class CMuLeftMenu :
    public CMenuCustomDraw
{
public:
    CMuLeftMenu(void);
    ~CMuLeftMenu(void);

protected:
    DECLARE_MESSAGE_MAP()

protected:
    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
    afx_msg void OnMouseMove(UINT nFlags, CPoint point);
    afx_msg LRESULT OnMouseLeave(WPARAM wParam, LPARAM lParam);
    afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
};