i create a treeview in a wnd derived from CWindowImpl ( i use atl), and i create a imglistctrl for the treeview,
everything seems ok of the imagelist, and i assign a image index for every node of the trewview, but no icon shows, and a small empty rect keeps at the left of every node's, anyone can help me?
class CJMainForm : public CWindowImpl<CJMainForm>
{
public:
DECLARE_WND_CLASS("JMainFrameClass")
CJMainForm(void);
~CJMainForm(void);
BOOL ShowForm(BOOL bShow = TRUE);
BEGIN_MSG_MAP( CJMainForm )
MESSAGE_HANDLER( WM_PAINT, OnPaint)
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
MESSAGE_HANDLER(WM_QUERYENDSESSION, OnQueryEndSession)
END_MSG_MAP()
public:
CXAnalogClock m_wndClock;
CCalenderWnd m_wndCalender;
CWindow m_wndPrjTree;
HBRUSH m_brBackGround;
SIZE m_szbrBackGround;
protected:
LRESULT OnPaint( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
LRESULT OnLButtonDown( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled );
LRESULT OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnEraseBkgnd(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnQueryEndSession(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
HICON m_icoExit;
HICON m_icoPrevYear;
HICON m_icoNextYear;
HICON m_icoPrevMonth;
HICON m_icoNextMonth;
HICON m_icoToday;
HFONT m_icoTextFont;
int m_CurrentRegion, m_nOldRegion;
HICON m_icoNodeClosed;
HICON m_cioNodeOpen;
HICON m_icoAttrib;
enum EnToolBtnState
{
tbs_normal = 0,
tbs_hover,
tbs_prress_down,
}m_nToolBtnState[6];
RECT m_rcToolBtn[6];
HBRUSH m_brToolBtnHover;
int m_nLastToolBtnHit;
enum SKIN
{
cpbob = 0,
cpnobob,
darkblue,
silver,
gold,
black,
lightblue,
green,
red,
rose,
aqua,
neonblue,
bluestreak,
crystalgreen,
crystalblack,
crystalblue,
crystalred,
crystalyellow,
silverring,
minimal,
white,
};
void SetSkin();
struct SKIN_MENU_DATA
{
UINT nID;
UINT nClockFaceBitmapId;
UINT nDateBitmapId;
TCHAR *pszName;
};
static SKIN_MENU_DATA m_Skins[];
static int m_nSkins;
SKIN m_eSkin;
ATL::CString m_strSkin;
SKIN GetSkinFromName(LPCTSTR lpszSkinName);
private:
void ParseNode(IDispatch* pNode,HTREEITEM hParent);
HTREEITEM CJMainForm::InsertTreeItem(HTREEITEM hItem, LPCTSTR lpszItem, int nImage,
int nSelectedImage, HTREEITEM hParent, HTREEITEM hInsertAfter = TVI_LAST);
BOOL SetTreeItem(HTREEITEM hItem, UINT nMask, LPCTSTR lpszItem, int nImage,
int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam);
CXmlDocumentWrapper m_xmlDoc;
HIMAGELIST m_imageListTreeView;
};
extern CJMainForm* g_pMainForm;
BOOL CJMainForm::ShowForm(BOOL bShow)
{
if (!m_hWnd || !IsWindow())
Create(::GetDesktopWindow(), 0, 0, (WS_POPUP | WS_VISIBLE | WS_CLIPCHILDREN) & (~WS_CAPTION), WS_EX_CONTROLPARENT | WS_EX_TOOLWINDOW);
DWORD dw = GetLastError();
if (m_hWnd && bShow && IsWindow())
{
RECT rectWorkArea;
SystemParametersInfo(SPI_GETWORKAREA, 0, (LPVOID)&rectWorkArea, 0);
MoveWindow(&rectWorkArea);
SetWindowPos(HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
}
if (!m_wndCalender.m_hWnd)
{
RECT rc = {0};
rc.left = 64;
rc.right = rc.left + 64 * 7 + 1;
rc.top = 12;
rc.bottom = rc.top + 64 * 6 + 24 + 1;
rc.bottom += 24;
m_wndCalender.Create(m_hWnd, &rc,"", WS_CHILD | WS_VISIBLE);
}
if (!m_wndClock.m_hWnd)
{
RECT rc = {0};
rc.left = 64 + 12;
rc.right = rc.left + 100;
rc.top = 12;
rc.bottom = rc.top + 64 * 6 + 24 + 24 + 1;
rc.top = rc.bottom + 12;
rc.bottom = rc.top + 100;
m_wndClock.Create(m_hWnd, &rc,"", WS_CHILD | WS_VISIBLE);
m_wndClock.SetHourAdjust(0);
if (!m_strSkin.IsEmpty())
{
m_eSkin = GetSkinFromName(m_strSkin);
SetSkin();
}
m_wndClock.Run();
}
if (!m_wndPrjTree.m_hWnd)
{
if (!m_imageListTreeView)
{
m_imageListTreeView = ::ImageList_Create(16, 16,ILC_COLOR24|ILC_MASK,3,1);
m_icoNodeClosed = (HICON)::LoadImage(g_hInstance , MAKEINTRESOURCE(IDI_NODECLOSED), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
m_cioNodeOpen = (HICON)::LoadImage(g_hInstance , MAKEINTRESOURCE(IDI_NODEOPEN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
m_icoAttrib = (HICON)::LoadImage(g_hInstance , MAKEINTRESOURCE(IDI_ATTRIB), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
ImageList_AddIcon(m_imageListTreeView,m_icoNodeClosed);
ImageList_AddIcon(m_imageListTreeView, m_cioNodeOpen);
ImageList_AddIcon(m_imageListTreeView, m_icoAttrib);
}
RECT rc = {0};
rc.left = 64 * 8 + 12;
rc.right = rc.left + 64 * 4;
rc.top = 12;
rc.bottom = rc.top + 64 * 6 + 24 + 1;
rc.bottom += 24;
m_wndPrjTree.Create(WC_TREEVIEWA,m_hWnd, &rc,"prjview", WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP
| TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_INFOTIP |TVS_TRACKSELECT|TVS_SINGLEEXPAND| TVS_DISABLEDRAGDROP);
::SendMessage(m_wndPrjTree.m_hWnd, TVM_SETIMAGELIST, (WPARAM)TVSIL_NORMAL, (LPARAM)m_imageListTreeView);
::SendMessage(m_wndPrjTree.m_hWnd, TVM_SETBKCOLOR, 0, (LPARAM)RGB(224, 255, 224));
m_xmlDoc.Load("F:\\XmlView\\UpgradeLog.XML");
ParseNode(m_xmlDoc.AsNode(),TVI_ROOT);
}
if (m_hWnd && !bShow && IsWindow())
ShowWindow(SW_HIDE);
return (m_hWnd != NULL);
}
|