We help IT Professionals succeed at work.

problem in showing child dialog with scrollbar

pigangel asked
  I need your help! because my colleague and myself have been struggling for quite long time but still can not solve this problem.
  my situation is:
  I has 3 dialogs In my MFC program,Dialog A, Dialog B with horizontal scrollbar, Dialog C with vertical scrollbar.Dialog A is the main dialog of my program and it has 1 Dialog B as it's child dialog, and dialog B can have max 20 different C dialogs as it's child dialogs. wehn Dialog B is showed up, it's child C dialogs also appear, scrolling the horizontal scrollbar of dialog B, you can see different child C dialog, on the other hand, scrolling the vertical scrollbar, you can see different part of dialog C ( Dialog C doesn't have any controls, only has some painted color rectangles when created initially ).
In Dialog A when user click button "change", the original child dialog B will be closed and another different child dialg B will be showed up ( because different B has different number of C Dialogs).

 and my problem is:
 I hold one pointer of Dialog B, and use this pointer to create or destroy dialog B, but sometime when the dialog B is showed up, the color rectangles of dialog C don't appear unless user click it's vertical scrollbar.

 I hope I described my problem clearly, please kindly give me any hints you think about. I would like to give out all my points. Please give me e-amil address, I can post my testing code (5 classes ) if you think you need to see my problem better.

 thank you very much in advance.

-- pigangel with big headache.
Watch Question

You can mail your code to jacpost@post6.tele.dk and I'll see if I get a minute to look at it...

Can you show your code for dialogs creations?
or send me your project too.
(my Email is: migel.geo@yahoo.com)
Vinayak KumbarSr Program Manager


I can check ur prob, send the project in zip file format to k_bbb100@hotmail.com

mmmm, so strange code
1. You have to many asserts!
to resolve this move all KillTimer from class destructor to the WM_DESTROY handler
2. You delete CPaintDC! it is so BAD!
remove this line in the
void CMachineIndicators::OnPaint()

//del@yes 030901
      //dc.DeleteDC(); <<---!!!!!!!!!!!!!!!!
      // Do not call CDialog::OnPaint() for painting messages

3. You have too many mem memory leaks!
 check your code for allocation!


 Thank you very much!
 About 1, I know it only happen when building debug version, not happen in release version. BUT I don't really know about asserts and how to use.
 About 2, I thought I had delete it because I see my comment is there.
 About 3, can you please tell me how you know this program has too many memory leak? if you know had the record, can you please kindly tell me ? This problem is very serious for me. and  why I ask you this question is because I posted question "problem when createing and ending modaless dialog", and one expert said my test program has memory leak with the usage of CObjArray and so on, and I think my colleague already fixed that problem in the test program( since we don't have memory check tool, we use NT task manager to check, already no memory increasing ).

-- pigangel

You must NOT delete PaintDC manually!!!!!
It is done by destructor. So you code is dangerous!


thank you very much! another thing is memory leak.  can you please give me some hints ?


I solved the problem. thanks for all advise! especially migel.I guess migel has spent quite some time to look into my code and tried to help me.


Explore More ContentExplore courses, solutions, and other research materials related to this topic.