Dialog vs Form interactions

Discussions related to Visual Prolog
Harrison Pratt
VIP Member
Posts: 300
Joined: 5 Nov 2000 0:01

Dialog vs Form interactions

Unread post by Harrison Pratt » 4 Feb 2019 18:23

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.

User avatar
Thomas Linder Puls
VIP Member
Posts: 2430
Joined: 28 Feb 2000 0:01

Re: Dialog vs Form interactions

Unread post by Thomas Linder Puls » 4 Feb 2019 18:42

That behavior is not normal, which version are you using?
Regards Thomas Linder Puls
PDC

Harrison Pratt
VIP Member
Posts: 300
Joined: 5 Nov 2000 0:01

Re: Dialog vs Form interactions

Unread post by Harrison Pratt » 4 Feb 2019 20:21

VIP Version 7.502

I've tested it several different ways, using vipCommonDialogs type dialogs and my own small dialogs and forms.

User avatar
Thomas Linder Puls
VIP Member
Posts: 2430
Joined: 28 Feb 2000 0:01

Re: Dialog vs Form interactions

Unread post by Thomas Linder Puls » 5 Feb 2019 9:26

I cannot reproduce it.

Can you attach a project with the problem (delete the exe, obj and deb directories before zipping the project).
Regards Thomas Linder Puls
PDC

Harrison Pratt
VIP Member
Posts: 300
Joined: 5 Nov 2000 0:01

Re: Dialog vs Form interactions

Unread post by Harrison Pratt » 5 Feb 2019 14:33

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.
Attachments
StatGraphDev.zip
(99.32 KiB) Downloaded 31 times

User avatar
Thomas Linder Puls
VIP Member
Posts: 2430
Joined: 28 Feb 2000 0:01

Re: Dialog vs Form interactions

Unread post by Thomas Linder Puls » 5 Feb 2019 15:32

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.

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.
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:
RedrawProblem.png
Redraw Problem
RedrawProblem.png (5.73 KiB) Viewed 3860 times
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

Harrison Pratt
VIP Member
Posts: 300
Joined: 5 Nov 2000 0:01

Re: Dialog vs Form interactions

Unread post by Harrison Pratt » 5 Feb 2019 15:53

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

Post Reply