How do I make form windows repaint themselves when another form window passes over them?
Consider two scenarios:
1. Open form FormF then open dialog DlgD.
If I move DlgD around on top of FormF then FormF repaints as expected.
2. Open two forms, FormA and FormB.
If I move FormA around on top of FormB then FormB is "marked up" with edges of FrmA's outer rectangle.
Is there a tidy way of making Windows take care of repainting forms touched by other forms?
One could keep track of the various forms in a separate database and invalidate() them to force a repaint as each top level form was moved, but it seems that should not be necessary for such a common scenario.
- Thomas Linder Puls
- VIP Member
- Posts: 1401
- Joined: 28 Feb 2000 0:01
Re: Dialog vs Form interactions
That behavior is not normal, which version are you using?
Regards Thomas Linder Puls
PDC
PDC
-
- VIP Member
- Posts: 443
- Joined: 5 Nov 2000 0:01
Re: Dialog vs Form interactions
VIP Version 7.502
I've tested it several different ways, using vipCommonDialogs type dialogs and my own small dialogs and forms.
I've tested it several different ways, using vipCommonDialogs type dialogs and my own small dialogs and forms.
- Thomas Linder Puls
- VIP Member
- Posts: 1401
- Joined: 28 Feb 2000 0:01
Re: Dialog vs Form interactions
I cannot reproduce it.
Can you attach a project with the problem (delete the exe, obj and deb directories before zipping the project).
Can you attach a project with the problem (delete the exe, obj and deb directories before zipping the project).
Regards Thomas Linder Puls
PDC
PDC
-
- VIP Member
- Posts: 443
- Joined: 5 Nov 2000 0:01
Re: Dialog vs Form interactions
OK, here it is as a VP 8.02 project.
The problem is how I am handling GDIP in the onPaint/3 event in graphDisplayForm.pro (Line 44). Other "empty" forms behave normally.
My idea is that the rugPainter object stores the graphics information on creation and Rug:paint() uses that information to draw the rug and clean up the graphics when done. I wanted to abstract out the painting of various graphs (e.g., scatter plots, histograms, etc.) to simplify putting various graph styles into other applications. This is just a prototype.
The problem is how I am handling GDIP in the onPaint/3 event in graphDisplayForm.pro (Line 44). Other "empty" forms behave normally.
My idea is that the rugPainter object stores the graphics information on creation and Rug:paint() uses that information to draw the rug and clean up the graphics when done. I wanted to abstract out the painting of various graphs (e.g., scatter plots, histograms, etc.) to simplify putting various graph styles into other applications. This is just a prototype.
- Attachments
-
- StatGraphDev.zip
- (99.32 KiB) Downloaded 368 times
- Thomas Linder Puls
- VIP Member
- Posts: 1401
- Joined: 28 Feb 2000 0:01
Re: Dialog vs Form interactions
OK, I think the problem is rather different than what you described
.
Anyways, I have examined in depth what you are doing, but it looked like a typical problem of drawing in a wrong place/size.
If I give rugPainter a rectangle corresponding to the entire client area you are drawing in then every thing works fine.
I suspect you think the Rectangle in a printResponder is something different than what it is. This is what it is: The part of the client rectangle that needs to be repainted.
When you move one window on top of another then fragments of the lower window will be revealed. The rectangle in the paint responder is a rectangle that contains these fragments, but it is not the entire window/client area.
You can easily see the exatct problem, if you first move the upper window, so that it only covers some of the lower window, and then very quickly remove it completely: As you can see your entire drawing is drawn in the small fragment that was revealed.
Actually, all the other vertical lines is your drawing drawn within a very narrow rectangle.
The Rectangle variable can be used to optimize performance by only drawing things that intersect with the rectangle. If for example the drawing is a grid you only need to draw those cells that intersect with the rectangle.
![Smile :-)](./images/smilies/icon_smile.gif)
Anyways, I have examined in depth what you are doing, but it looked like a typical problem of drawing in a wrong place/size.
If I give rugPainter a rectangle corresponding to the entire client area you are drawing in then every thing works fine.
Code: Select all
predicates
onPaint : window::paintResponder.
clauses
onPaint(Source, Rectangle, GDI) :-
%-- set up GDIP, store 'isReleaseNeeded' in painter property for use by Rug:paint
getClientSize(H, W),
Rug = rugPainter::new(Source, rct(0, 0, H, W), GDI, dataMonger),
% Here you can optionally modify Rug properties to change display (e.g., data format, data range, etc.)
% Alternatively, Rug properties may be altered before passing Rug object to this form.
%-- paint the Rug and clean up GDIP
Rug:paint(), % <== without this predicate call the form behaves normally.
succeed.
When you move one window on top of another then fragments of the lower window will be revealed. The rectangle in the paint responder is a rectangle that contains these fragments, but it is not the entire window/client area.
You can easily see the exatct problem, if you first move the upper window, so that it only covers some of the lower window, and then very quickly remove it completely: As you can see your entire drawing is drawn in the small fragment that was revealed.
Actually, all the other vertical lines is your drawing drawn within a very narrow rectangle.
The Rectangle variable can be used to optimize performance by only drawing things that intersect with the rectangle. If for example the drawing is a grid you only need to draw those cells that intersect with the rectangle.
Regards Thomas Linder Puls
PDC
PDC
-
- VIP Member
- Posts: 443
- Joined: 5 Nov 2000 0:01
Re: Dialog vs Form interactions
"I suspect you think the Rectangle in a printResponder is something different than what it is. This is what it is: The part of the client rectangle that needs to be repainted."
Ahhh ... thank you very much! You are right, I erroneously assumed that the Rectangle in the paintResponder was the client rectangle.
Ahhh ... thank you very much! You are right, I erroneously assumed that the Rectangle in the paintResponder was the client rectangle.