Discussions related to Visual Prolog
Michel
Posts: 23
Joined: 8 Nov 2025 17:17

Help and some exemple with TabControlDemo

Post by Michel »

Hello,

As shown with the screen capture, I am working on my new expert system. Everything works fine and the result is quite beautiful and usable...

Today, the remedies DBA contains more than 600 remedies and each one need between 10 or 20 "modalitues" so it's quite impossible to do this by hand. I develloped an other soft to do this visibly and and start with an adaptation from TabControlDemo with 9 tabs : améliorations, aggravations.... and so on.

How can I retrieve and modify dynamicaly each corresponding listBox_ctl:addList(["Aaa", "Bbb", "Ccc"]) to show those for each remedies ? I tryed many adaptations without success. I succeed to change the text of each tab, fine (!!), but I don't access, with a compiler error, when I try to realize a clearList or, more important, an addList["modality1","modality2", ..... ].

Where is my mistake and what is the solution ?

Regards, Michel
You do not have the required permissions to view the files attached to this post.
User avatar
Thomas Linder Puls
VIP Member
Posts: 1513
Joined: 28 Feb 2000 0:01

Re: Help and some exemple with TabControlDemo

Post by Thomas Linder Puls »

I think you give us to little to work with.
We don't know any of your code and we don't even know what compilation errors you receive.

My guess is that you are trying to access the list box from a context where you don't have access to it.
Regards Thomas Linder Puls
PDC
Michel
Posts: 23
Joined: 8 Nov 2025 17:17

Re: Help and some exemple with TabControlDemo

Post by Michel »

Exactly.

I think it is the case. I take the basis of tabControlDemo right out of the box. Everything is fine but, how can I access to the listBox, as coded in the exemple ? I tryed to create as "facts" to maintain and retrieve the created elements... no success ! I asked even ChatGPT and the answer(s) dont't give success... I am locked with something probably "simple" but the more simple it is, the most difficult to find is present.

Code: Select all

implement tabControlForm inherits formWindow     open vpiDomains, stdio   facts %%imageCheckMark : integer [constant]. %%imageWarning : integer [constant]. %%imageCriticalWarning : integer [constant].   facts     tab1_ctl : firstTab.     tab2_ctl : secondTab.   clauses     new(Parent) :-         formWindow::new(Parent),         generatedInitialize(),         % Prepare tab images         /*         ImageSize = 24,         ImageList = imageList::new(ImageSize, ImageSize),         imageCheckmark := ImageList:addIcon(icon::createFromBinary(#bininclude(@"tabControlForm\checkMark.ico")):getHIcon(ImageSize, ImageSize)),         imageWarning := ImageList:addIcon(icon::createFromBinary(#bininclude(@"tabControlForm\warning.ico")):getHIcon(ImageSize, ImageSize)),         imageCriticalWarning :=             ImageList:addIcon(icon::createFromBinary(#bininclude(@"tabControlForm\warningCritical.ico")):getHIcon(ImageSize, ImageSize)),         tabControl_ctl:imageListOpt := core::some(ImageList),         */         % Construct and add pages         %%%%         Page1 = tabPage::new(),         tab1_ctl := firstTab::new(Page1:getContainerControl()),         Page1:setText(tab1_ctl:getText()),         tabControl_ctl:addPage(Page1),         %%%         Page2 = tabPage::new(),         tab2_ctl := secondTab::new(Page2:getContainerControl()),         Page2:setText(tab2_ctl:getText()),         tabControl_ctl:addPage(Page2),         %%%         %%%         tabControl_ctl:addPageChangedListener(onPageChanged),         tabControl_ctl:setPageChangeResponder(onPageChangeResponder),         succeed.   class predicates     onPageChangeResponder : tabControl::pageChangeResponder. clauses     onPageChangeResponder(_, Page) = tabControl::acceptPageChange() :-         %tabControl::forbidPageChange() :-         writef("TabControl page is going to be changed: %\n", Page:getText()).   class predicates     onPageChanged : tabControl::pageChangedListener. clauses     onPageChanged(_Source, Page) :-         %%Page::         writef("TabControl page changed: %\n", Page:getText()).   class predicates     onShow : window::showListener. clauses     onShow(_, _CreationData).   class predicates     onDestroy : window::destroyListener. clauses     onDestroy(_).   predicates     onSizeChanged : window::sizeListener. clauses     onSizeChanged(_) :-         vpiToolbar::resize(getVPIWindow()).   predicates     onChangeIconCtlClick : button::clickResponder. clauses     onChangeIconCtlClick(_Source) = button::defaultAction :-         TabPage = tabControl_ctl:getCurrentPage(),         tab1_ctl:setModalities(["ggggg", "oooooo"]), <--------- generate error c229 !         stdio::write("TabPage ", TabPage).         /*         AltList = [-1, imageCheckmark, imageWarning, imageCriticalWarning],         NextImageIdx =             if Idx = list::tryGetIndex(TabPage:imageIdx, AltList) then list::nth((Idx + 1) mod list::length(AltList), AltList) else -1 end if,         TabPage:imageIdx := NextImageIdx.         */   % This code is maintained automatically, do not update it manually.%  22:10:51-16.10.2020 facts     ok_ctl : button.     cancel_ctl : button.     tabControl_ctl : tabControl.     changeIconCtl : button.   predicates     generatedInitialize : (). clauses     generatedInitialize() :-         setFont(vpi::fontCreateByName("Tahoma", 8)),         setText("Tab Control Example"),         setRect(rct(50, 40, 430, 183)),         setDecoration(titlebar([closeButton, minimizeButton])),         setBorder(sizeBorder()),         setState([wsf_ClipSiblings, wsf_ClipChildren]),         menuSet(noMenu),         addShowListener(onShow),         addDestroyListener(onDestroy),         addSizeListener(onSizeChanged),         ok_ctl := button::newOk(This),         ok_ctl:setText("&OK"),         ok_ctl:setPosition(248, 116),         ok_ctl:setSize(56, 16),         ok_ctl:defaultHeight := false,         ok_ctl:setAnchors([control::right, control::bottom]),         cancel_ctl := button::newCancel(This),         cancel_ctl:setText("Cancel"),         cancel_ctl:setPosition(312, 116),         cancel_ctl:setSize(56, 16),         cancel_ctl:defaultHeight := false,         cancel_ctl:setAnchors([control::right, control::bottom]),         tabControl_ctl := tabControl::new(This),         tabControl_ctl:setPosition(12, 12),         tabControl_ctl:setSize(356, 100),         tabControl_ctl:setAnchors([control::left, control::top, control::right, control::bottom]),         changeIconCtl := button::new(This),         changeIconCtl:setText("New Icon"),         changeIconCtl:setPosition(184, 116),         changeIconCtl:setSize(56, 16),         changeIconCtl:defaultHeight := false,         changeIconCtl:setAnchors([control::right, control::bottom]),         changeIconCtl:setClickResponder(onChangeIconCtlClick),         ThisFormDemonstratesHowTabcontrolCanBeUsed_ctl = textControl::new(This),         ThisFormDemonstratesHowTabcontrolCanBeUsed_ctl:setText("This form demonstrates how tabControl can be used"),         ThisFormDemonstratesHowTabcontrolCanBeUsed_ctl:setPosition(12, 120),         ThisFormDemonstratesHowTabcontrolCanBeUsed_ctl:setSize(168, 10),         ThisFormDemonstratesHowTabcontrolCanBeUsed_ctl:setAnchors([control::left, control::bottom]).     % end of automatic code   end implement tabControlForm
and

Code: Select all

implement firstTab inherits userControlSupport   clauses     new(Parent) :-         new(),         setContainer(Parent).   constructors     new : (). clauses     new() :-         userControlSupport::new(),         generatedInitialize(),         listBox_ctl:addList(["Aaa", "Bbb", "Ccc"]),         listBox_ctl:selectAt(1, true),         checkBox1_ctl:setCheckedState(checkButton::checked).   clauses     setModalities(List) :-         stdio::write("List : ", List). % This code is maintained automatically, do not update it manually. 16:31:15-27.1.2006   facts     checkBox1_ctl : checkButton.     checkBox2_ctl : checkButton.     edit_ctl : editControl.     listBox_ctl : listBox.   predicates     generatedInitialize : (). clauses     generatedInitialize() :-         setText("firstTab"),         This:setSize(132, 80),         checkBox1_ctl := checkButton::new(This),         checkBox1_ctl:setText("Check Box1"),         checkBox1_ctl:setPosition(60, 22),         checkBox1_ctl:setWidth(56),         checkBox2_ctl := checkButton::new(This),         checkBox2_ctl:setText("Check Box2"),         checkBox2_ctl:setPosition(60, 34),         checkBox2_ctl:setWidth(56),         edit_ctl := editControl::new(This),         edit_ctl:setText(""),         edit_ctl:setPosition(60, 54),         edit_ctl:setWidth(56),         listBox_ctl := listBox::new(This),         listBox_ctl:setPosition(4, 18),         ThisIsTheFirstTabPage_ctl = textControl::new(This),         ThisIsTheFirstTabPage_ctl:setText("This is the first tab page"),         ThisIsTheFirstTabPage_ctl:setPosition(4, 2),         ThisIsTheFirstTabPage_ctl:setSize(78, 10).     % end of automatic code   end implement firstTab
Michel
Posts: 23
Joined: 8 Nov 2025 17:17

Re: Help and some exemple with TabControlDemo

Post by Michel »

...
I don't have problem to get, retrieve, change the text of the selected "tab" but I can't access to the contained elements aka the listBox. Is there some trick to get it ?
Michel
Posts: 23
Joined: 8 Nov 2025 17:17

Re: Help and some exemple with TabControlDemo

Post by Michel »

At last... I succeed to retrieve the listBox...
User avatar
Thomas Linder Puls
VIP Member
Posts: 1513
Joined: 28 Feb 2000 0:01

Re: Help and some exemple with TabControlDemo

Post by Thomas Linder Puls »

I'm so sorry that I forgot you here in the summer vacation period. So I am very glad that you managed to solve the problem yourself. Maybe you even got an "aha" experience while solving it. Perhaps you want to share what you did.

By the way, remember to put [code]...[/code] tags around code sections.
Regards Thomas Linder Puls
PDC