Click here to Skip to main content
15,891,253 members
Articles / Desktop Programming / MFC

My Tree Control

Rate me:
Please Sign up or sign in to vote.
1.09/5 (11 votes)
10 Nov 20052 min read 66.7K   1.5K   21  
A tree control that is like a template and stores items.
///////////////////////////////////////////////////////////////////////////////
//
// Tools.h : header file
//
///////////////////////////////////////////////////////////////////////////////

#pragma once

///////////////////////////////////////////////////////////////////////////////
// Usefull macros
//
#define KEYDOWN(Key) ((GetKeyState(Key)&0x8000)!=0)
#define ON_WM_MOUSEOUT() \
    { WM_MOUSELEAVE, 0, 0, 0, AfxSig_vv, \
        (AFX_PMSG)(AFX_PMSGW)(void (AFX_MSG_CALL CWnd::*)(void))&OnMouseOut },

#ifndef lengthof
  #define lengthof(a) (sizeof(a)/sizeof(a[0]))
#endif

///////////////////////////////////////////////////////////////////////////////
// Check if the specified window is child of a docked toolbar
bool ChildOfDockedToolbar (CWnd* pWnd);

/////////////////////////////////////////////////////////////////////////////
// Constants for detecting OS-Type
enum WinVer
{
    wvUndefined,
    wvWin32s,
    wvWin95,
    wvWin98,
    wvWinME,
    wvWinNT3,
    wvWinNT4,
    wvWin2000,
    wvWinXP,
};

///////////////////////////////////////////////////////////////////////////////
// Return the current OS-Type
//
WinVer WINAPI GetWinVersion ();

///////////////////////////////////////////////////////////////////////////////
inline void WINAPI ScreenToClient (HWND hWnd, LPRECT pRect)
{
    ScreenToClient (hWnd, (LPPOINT)pRect);
    ScreenToClient (hWnd, ((LPPOINT)pRect)+1);
}

///////////////////////////////////////////////////////////////////////////////
inline void WINAPI ClientToScreen (HWND hWnd, LPRECT pRect)
{
    ClientToScreen (hWnd, (LPPOINT)pRect);
    ClientToScreen (hWnd, ((LPPOINT)pRect)+1);
}


///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
class CClientRect : public CRect
{
public:
    CClientRect (HWND hWnd)
    {
        ::GetClientRect (hWnd, this);
    };
    CClientRect (const CWnd* pWnd)
    {
        ::GetClientRect (pWnd->GetSafeHwnd(), this);
    };
};


///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#ifdef DLL_EXPORT
class __declspec(dllexport) CWindowRect : public CRect
#else
class __declspec(dllimport) CWindowRect : public CRect
#endif
{
public:
    CWindowRect (HWND hWnd)
    {
        ::GetWindowRect (hWnd, this);
    };
    CWindowRect (const CWnd* pWnd)
    {
        ::GetWindowRect (pWnd->GetSafeHwnd(), this);
    };
};


///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
class CWindowText : public CString
{
public:
    CWindowText (HWND hWnd)
    {
        CWnd::FromHandle (hWnd)->GetWindowText (*this);
    };
    CWindowText (const CWnd* pWnd)
    {
        pWnd->GetWindowText (*this);
    };
};


///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#define MMS_PAINT   0x0001
#define MMS_NCPAINT 0x0002

///////////////////
#ifdef DLL_EXPORT
class __declspec(dllexport) CMouseMgr
#else
class __declspec(dllimport) CMouseMgr
#endif
{
public:
    CMouseMgr ();

    void Init (HWND hWnd, WORD wFlags = MMS_PAINT);
    bool MouseOver () const;
    bool OnMouseMove (HWND hTrack = NULL);
    bool OnMouseOut (HWND hTrack = NULL);

protected:
    HWND m_hWnd;
    HWND m_hTrack;
    WORD m_wFlags;
    bool m_bOver;
};
#ifdef DLL_EXPORT
HANDLE __declspec(dllexport) GetXPToolsResouceHandle();
#else
HANDLE __declspec(dllimport) GetXPToolsResouceHandle();
#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Israel Israel
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions