Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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;
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.
C++
   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);


Step 6: Double click on button control to go to the double click function. To add some rows in the list control.
C++
	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

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..
Posted

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
 
Share this answer
 
Put the following code at the end of your function when you want to force an update.
C++
Invalidate(FALSE);
 
Share this answer
 
v2
Comments
kaushik4study 28-Dec-11 0:27am    
Thank you buddy for replying. But it is not solving my problem. The problem is still same.Can you be more specific.
Thank you
JackDingler 28-Dec-11 10:34am    
Not really. I can't. All I have to work with is the information you gave me.

That function call tells windows, that the current window needs to be repainted.

You've got something else going on that is causing your problem.

When I encounter problems like this, I sometimes generate a test app and try to piece by piece implement the same kind of code until it breaks.

Alternatively you can disable sections of code until it works again. The last thing you disabled should give you a clue as to what is wrong.
kaushik4study 29-Dec-11 2:16am    
Well thank you jack. i have solve the issue. Thankyou again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900