ListControl和图片控件重绘问题. [英] ListControl and picture control repaint issue.

查看:246
本文介绍了ListControl和图片控件重绘问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只需要一些帮助,我就没有在网页上找到任何正确的答案.它们是相同的,但不完全是我想要的.

所以这里是问题.请逐步定义.我正在使用基于对话框的示例应用程序,只是为了向您解释正确的问题.

模板设计部分
步骤1.我创建了一个对话框基础应用程序,在该应用程序上我已经从工具箱中以相同的顺序创建了两个控件,否则您将需要先编辑.rc文件,然后再创建图片控件 b>然后创建列表控件 按钮.
第2步.在图片控件属性页上,设置颜色=白色类型=矩形
第3步在列表控件属性页上的更改 view = Report


代码部分
第4步.创建与列表控件关联的变量.例如

I just need some help i have not find any proper answer on web pages.They are some what same but not exact what i am looking for.

So here is the problem.define in steps.I am using dialog based sample application and just to explain you the proper problem.

template design part
Steps 1. I have created a dialog base application on which i have created two control from tool box in the same order other wise u will need to edit .rc file first create Picture control then create List control button.
Step 2. On picture control property page set Color = White and type = rectangle
Step 3 On list control property page change view = Report


Code part
Step 4. Create variable associated to list control. for example

CListCtrl m_ctlListCtrl;

,并分别在构造函数和DoDataExchange(...)中进行更改.
第5步.现在转到函数

and do respective changes in constructor and DoDataExchange(...).
Step 5. Now go to function

Classname::OnInitDialog(..)

并编写以下代码以添加列和选择属性.

and write following code to add column and selection property.

   m_ctlListCtrl.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE,0,LVS_EX_FULLROWSELECT);
m_ctlListCtrl.InsertColumn(0, _T("Roll"), LVCFMT_CENTER , 110);
m_ctlListCtrl.InsertColumn(0, _T("Name"), LVCFMT_CENTER , 110);



第6步:双击按钮控件进入双击功能.在列表控件中添加一些行.



Step 6: Double click on button control to go to the double click function. To add some rows in the list control.

	CString strTemp;
	strTemp.Format(_T("ROLL_1"));
	m_ctlListCtrl.InsertItem(m_nRowcntr,strTemp);
	strTemp.Format(_T("NAME_1"));
	m_ctlListCtrl.SetItemText(m_nRowcntr,1,strTemp);
m_nRowcntr++;//member variable to represent rows


上面的代码只是简单地添加具有相同数据的多行.可以忽略行计数器,因为问题与此无关.

问题
第7步:执行该程序并通过单击按钮添加一些行.
第8步:现在选择单行按 ALT + TAB ,这将更改窗口.现在再次返回执行窗口并查看输出.我找不到解决办法.
好吧,我不是C ++的新手,但是我是MFC的新手,所以请给我建议或帮助..

预先谢谢您:)

帮助我..


the above code is just simply adding multiple rows with same data.row counter can be neglected because issue is not related to this.

Problem
Step 7: Execute the program and add some rows by clicking on the button.
Step 8: Select single row now Press ALT + TAB this will change the window. now again bring back the execution window and see the output. I cannot figure out solution.
Well i am not new in c++ but i am new to MFC so please advise or help me..

thank you in advance :)

Help me guys..

推荐答案

在您要强制进行更新时,将以下代码放在函数末尾.
Put the following code at the end of your function when you want to force an update.
Invalidate(FALSE);


好吧,我所做的事情很简单,但是很适合我的问题.我不知道该解决方案在哪里出现问题.

解决方案:,因为我的课程是从 CDialogEx 派生的.我只是在类中重写函数
Well what i did was simple but perfect for my problem. I don''t have any idea where will i get problem bu this solution.

Solution: as my class was derived from CDialogEx. I just override the function
CDialogEx::OnEraseBkgnd(CDC *pDC)

,即所谓的基类函数.如果我不调用基类函数的输出结果是完全相同的.但是我不知道在这里我会得到错误.如果有人可以告诉我,这种解决方案的弊端将是有益的和可观的.
谢谢

in my class the called base class function. Altough if i dont call the base class function output is same.But i don''t know here else i can get the error.If anybody can tell me, what can be the cons of this solution that will be helpful and appreciable.
Thank you


这篇关于ListControl和图片控件重绘问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆