Open Form

Discussions related to Visual Prolog
User avatar
Richard Clarke
Posts: 23
Joined: 15 Mar 2012 15:55

Open Form

Unread post by Richard Clarke » 19 Apr 2012 15:20

By experiment
(a) From a window (i.e. Task.win) I can open a form (eg Test.frm, or Test1.frm)
(b) From a form (say Test.frm) I can open a dialog (e.g. dlgTest.dlg)
BUT
(c) From a form (say Test.frm) I CANNOT open another from (e.g. Test1.frm). (eg by on Test.frm have pushbuttion name:"Open Test1", then :-

Code: Select all

onPushButtonClick(Source) = button::defaultAction:-         _Test1=test1::display(Source).
Attempting to do say generates runtime error 6001 (see below).

Is it intended that a form cannot open another form and if so where is this documented , or if not is it a bug?
Exception: unknown (com/visual-prolog/exception/common_exception)

An unknown exception has been trapped and continued

Predicate name = show
userMessage =
Title = Test1
Parent = 000B0A76
Rect = rct(80,64,464,256)

continued() 2012/04/19 14:59:18
ThreadId=4736
ClassInfo: com/visual-prolog/pfc/gui/documentWindow $JustDate: 2010-03-22 $$Revision: 23 $



----------------------------------------
Exception: vpi_WinBadType (com/visual-prolog/vpi/vpi)

Invalid window type

ExtraInfo = win_Create: Unsupported window type
error code = 6001
RSC

User avatar
Tonton Luc
VIP Member
Posts: 502
Joined: 16 Oct 2001 23:01

Unread post by Tonton Luc » 19 Apr 2012 15:35

Hi,

Have you test this :

Code: Select all

onPushButtonClick(Source) = button::defaultAction:-         Test1=test1::new(This),         Test1:show().

User avatar
Richard Clarke
Posts: 23
Joined: 15 Mar 2012 15:55

Unread post by Richard Clarke » 19 Apr 2012 15:42

An explanation previously given was
Source is the button and a button cannot be the parent of a form. You can use This (which is the first form) instead, or you can use the application window (i.e. applicationWindow::get()), or the screen (i.e. window::getScreenWindow()).
By experiment I have found that you get the same error if you try to open the second form via menu:-

Code: Select all

predicates     onMenuItem : window::menuItemListener. clauses     onMenuItem(Source, _MenuTAG):-        _Test1= test1::display(Source).
In this case Source is not the button (since we clicked a menu item not a button) so Source is ???
And why is Source OK when opening a dialog (via button or menu) rather than another form?

I have just tried using This instead of source but get the same error.

Code: Select all

predicates     onMenuItem : window::menuItemListener. clauses     onMenuItem(_Source, _MenuTAG):-        %_Test1= test1::display(Source). %runtime error 6001         _Test1= test1::display(This).   %still runtime error 6001   predicates     onPushButtonClick : button::clickResponder. clauses     onPushButtonClick(_Source) = button::defaultAction:-        % _Test1=test1::display(Source). %runtime error 6001         _Test1=test1::display(This). %still runtime error 6001
RSC

User avatar
Richard Clarke
Posts: 23
Joined: 15 Mar 2012 15:55

Unread post by Richard Clarke » 19 Apr 2012 17:32

The following works, but why is the situation different if opening a dialog? Or opening a form from a window (i.e Task.win)?

Code: Select all

predicates     onMenuItem : window::menuItemListener. clauses     onMenuItem(_Source, _MenuTAG):-        %_Test1= test1::display(Source). %runtime error 6001         %_Test1= test1::display(This).   %still runtime error 6001         _Test1=test1::display(applicationWindow::get()). %works OK   predicates     onPushButtonClick : button::clickResponder. clauses     onPushButtonClick(_Source) = button::defaultAction:-        % _Test1=test1::display(Source). %runtime error 6001         %_Test1=test1::display(This). %still runtime error 6001         %applicationWindow::get()).          _Test1=test1::display(applicationWindow::get()). %works OK
RSC

ahmednadi
VIP Member
Posts: 84
Joined: 15 Sep 2009 14:06

Unread post by ahmednadi » 14 Jul 2012 11:44

thanks

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

Unread post by Thomas Linder Puls » 14 Jul 2012 14:17

The argument you supply to display is the parent of the window. The parent will also be the "owner" of the created window. A window cannot live without an owner, so the owner of a window must live longer than the window itself.

So naturally forms and modeless dialogs are owned by the application window (or the screen).

(Controls are owned (directly or indirectly) by the form/dialog on which they reside).

Modal dialogs are used to "ask a question" they suspend the other input and therefore they can be owned by the window that ask the question. A button may trigger the question, but it is not the button that ask the question, it is the form/dialog on which the button resides that ask the question.

So the owner/parent of a modal dialog can be (the screen,) the application window, a form, or a dialog.
Regards Thomas Linder Puls
PDC

Post Reply