莫名其妙的问题,大家快来看一下,拜托阿!
我在一个dlg资源(中插入了一个TreeCtrl,并且关联到了一个CMyTreeCtrl类型的成员变量m_TreeCtrl上。(CMyTreeCtrl从CTreeCtrl继承),CMyTreeCtrl的申明如下:
class CMyTreeCtrl : public CTreeCtrl
{
public:
CMyTreeCtrl();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyTreeCtrl)
//}}AFX_VIRTUAL
public:
CImageList m_imageList;
virtual ~CMyTreeCtrl();
void InitTree();
protected:
//{{AFX_MSG(CMyTreeCtrl)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
}
实现部分为:
/////////////////////////////////////////////////////////////////////////
// CMyTreeCtrl
CMyTreeCtrl::CMyTreeCtrl()
{
}
CMyTreeCtrl::~CMyTreeCtrl()
{
}
BEGIN_MESSAGE_MAP(CMyTreeCtrl, CTreeCtrl)
//{{AFX_MSG_MAP(CMyTreeCtrl)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////
// CMyTreeCtrl message handlers
//问题就出在这!(所有的图标均为16位真彩)
void CMyTreeCtrl::InitTree()
{
m_imageList.Create(16,16,ILC_COLOR16,4,8);
HICON hicon[4];
hicon[0]=AfxGetApp()->LoadIcon(IDI_GROUP1);
hicon[1]=AfxGetApp()->LoadIcon(IDI_GROUP2);
hicon[3]=AfxGetApp()->LoadIcon(IDI_OPENF);
hicon[4]=AfxGetApp()->LoadIcon(IDI_CLOSEF);
for(int i=0;i<4;i++)
{
//在这里调试报错!
m_imageList.Add(hicon[i]);
}
//Release must ReadCofig
#ifdef _DEBUG
#endif
}
dlg的OnInitDialog()实现为:
BOOL CTestListCtrlDlg::OnInitDialog()
{
CDialog::OnInitDialog();
::SetWindowPos((HWND__*)0x00090792,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
m_TreeCtrl.InitTree();
return TRUE; // return TRUE unless you set the focus to a control
}
我都快被这个问题搞疯了,为什么阿~~~~~~~~~~~~~~~~~~~~~~~~~~~~