莫名其妙的问题,大家快来看一下,拜托阿!

waterflier 2002-07-26 10:39:13
我在一个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
}

我都快被这个问题搞疯了,为什么阿~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...全文
60 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧