Page 2 of 2

Re: Dialog library and vertical block expansion

Posted: Tue Aug 27, 2024 9:09 am
by boddhi
Hello,

We're digressing a bit from the main purpose of this thread, namely why in some cases using the multibox 'gadget' seems to disrupt the intended expansion behavior. :D :wink:

Again, at no point, I'm claiming that my approach is the best way to proceed.
But let's consider the following enumeration:

Code: Select all

EnableExplicit
Enumeration
  #StrinGadget1 ; Note here only one 'g' in the name
EndEnumeration
and now:

Code: Select all

"<string id='#StringGadget1' name='StringGadget1'/>  ; Note two 'g' here"
With this line, an error (unspecified) will be signalled when the code is executed.
 

Code: Select all

"<string id='"+Str(#StringGadget1)+"' name='StringGadget1'/>"
Whereas with this line, an error will be signalled at compile time with a clear message: “Variables must be explicitly declared”.

Here's "MY appreciated" advantage: I avoid a possible source of error before code execution and, if there is one of this type, PB will return a precise message: “Variables must be explicitly declared”. No need to spend time to search through the parsed XML string...
Admittedly, this requires a little more typing on my part, but this inconvenience is counterbalanced by the time it would take me to find potential errors.
This is my approach, and far be it from me to try to convince anyone. :wink:

Re: Dialog library and vertical block expansion

Posted: Tue Aug 27, 2024 12:53 pm
by jacdelad
The problem is not converting the constant into a value, it's the missing "Runtime" for your enumeration! You can either give a value as id or the constant (if declared with "Runtime"). But using the constant is more readable.

To refer back to the original code:

Code: Select all

EnableExplicit
;
Runtime Enumeration Fenetres  ;{
  #FEN_PRINCIPALE
EndEnumeration ;}
Runtime Enumeration Gadgets   ;{ Gadgets généraux
  #GAD_FP_LIB_RECHERCHE
  #GAD_FP_LS_PARAMRECHERCHE
  #GAD_FP_LS_HISTORECHERCHE
  #GAD_FP_BT_RECHERCHER
  #GAD_FP_BT_EPINGLER
  #GAD_FP_LS_CATEGORIES
  #GAD_FP_CT_LISTETOUT
  #GAD_FP_CT_LISTEBDD
  #GAD_FP_CT_LISTECOMPAT
  #GAD_FP_CT_LISTECUBE
  #GAD_FP_CT_LISTEDATE
  #GAD_FP_CT_LISTEFIN
  #GAD_FP_CT_LISTEINFO
  #GAD_FP_CT_LISTEINGE
  #GAD_FP_CT_LISTEINTERNET
  #GAD_FP_CT_LISTELOGIQUE
  #GAD_FP_CT_LISTEMATHS
  #GAD_FP_CT_LISTERECHREF
  #GAD_FP_CT_LISTESTATS
  #GAD_FP_CT_LISTETEXTE
  #GAD_FP_CT_LISTEUTIL
  #GAD_FP_CT_LISTERECHERCHE
  #GAD_FP_LS_LISTETOUT
  #GAD_FP_LS_LISTEBDD
  #GAD_FP_LS_LISTECOMPAT
  #GAD_FP_LS_LISTECUBE
  #GAD_FP_LS_LISTEDATE
  #GAD_FP_LS_LISTEFIN
  #GAD_FP_LS_LISTEINFO
  #GAD_FP_LS_LISTEINGE
  #GAD_FP_LS_LISTEINTERNET
  #GAD_FP_LS_LISTELOGIQUE
  #GAD_FP_LS_LISTEMATHS
  #GAD_FP_LS_LISTERECHREF
  #GAD_FP_LS_LISTESTATS
  #GAD_FP_LS_LISTETEXTE
  #GAD_FP_LS_LISTEUTIL
  #GAD_FP_LS_LISTERECHERCHE
  #GAD_FP_CP_FONCTION
  #GAD_FP_BT_COPIERFONCTION
  #GAD_FP_ED_DESCRIPTION
  #GAD_FP_LH_AIDE
EndEnumeration ;}
;
Define.i NoDialogue
Define.s ChaineXML
ChaineXML="<?xml version='1.0' encoding='UTF-16'?>"+Chr(10)+ ;{
          "<dialogs>"+Chr(10)+
          "  <window id='#FEN_PRINCIPALE' name='FEN_PRINCIPALE' text='Fonctions EXCEL' xpos='21' ypos='2' width='600' height='390' minwidth='380' minheight='198' flags='#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_SizeGadget|#PB_Window_Invisible|#PB_Window_ScreenCentered'>"+Chr(10)+
          "    <vbox expand='item:3' spacing='4'>"+Chr(10)+         ;{  Note : Here, expansion is only allowed to subitem 3
          "      <hbox expand='item:3' spacing='2'>"+Chr(10)+       ;{    Subitem 1
          "        <vbox expand='no' align='center' spacing='0'>"+Chr(10)+
          "          <text id='#GAD_FP_LIB_RECHERCHE' name='GAD_FP_LIB_RECHERCHE' text='Rechercher dans '/>"+Chr(10)+
          "        </vbox>"+Chr(10)+
          "        <combobox id='#GAD_FP_LS_PARAMRECHERCHE' name='GAD_FP_LS_PARAMRECHERCHE' width='88'/>"+Chr(10)+
          "        <combobox id='#GAD_FP_LS_HISTORECHERCHE' name='GAD_FP_LS_HISTORECHERCHE' flags='#PB_ComboBox_Editable'/>"+Chr(10)+
          "        <buttonimage id='#GAD_FP_BT_RECHERCHER' name='GAD_FP_BT_RECHERCHER'/>"+Chr(10)+
          "        <buttonimage id='#GAD_FP_BT_EPINGLER' name='GAD_FP_BT_EPINGLER'/>"+Chr(10)+
          "      </hbox>"+Chr(10)+ ;}
          "      <vbox expand='no' align=''>"+Chr(10)+              ;{    Subitem 2
          "        <combobox id='#GAD_FP_LS_CATEGORIES' name='GAD_FP_LS_CATEGORIES'/>"+Chr(10)+
          "      </vbox>"+Chr(10)+ ;}
          "      <multibox>"+Chr(10)+                               ;{    Subitem 3
          "        <listicon id='#GAD_FP_LS_LISTETOUT' name='GAD_FP_LS_LISTETOUT' flags='#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection'/>"+Chr(10)+
          "        <listicon id='#GAD_FP_LS_LISTEBDD' name='GAD_FP_LS_LISTEBDD' flags='#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection'/>"+Chr(10)+
          "        <listicon id='#GAD_FP_LS_LISTECOMPAT' name='GAD_FP_LS_LISTECOMPAT' flags='#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection'/>"+Chr(10)+
          "        <listicon id='#GAD_FP_LS_LISTECUBE' name='GAD_FP_LS_LISTECUBE' flags='#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection'/>"+Chr(10)+
          "        <listicon id='#GAD_FP_LS_LISTEDATE' name='GAD_FP_LS_LISTEDATE' flags='#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection'/>"+Chr(10)+
          "        <listicon id='#GAD_FP_LS_LISTEFIN' name='GAD_FP_LS_LISTEFIN' flags='#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection'/>"+Chr(10)+
          "        <listicon id='#GAD_FP_LS_LISTEINFO' name='GAD_FP_LS_LISTEINFO' flags='#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection'/>"+Chr(10)+
          "        <listicon id='#GAD_FP_LS_LISTEINGE' name='GAD_FP_LS_LISTEINGE' flags='#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection'/>"+Chr(10)+
          "        <listicon id='#GAD_FP_LS_LISTEINTERNET' name='GAD_FP_LS_LISTEINTERNET' flags='#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection'/>"+Chr(10)+
          "        <listicon id='#GAD_FP_LS_LISTELOGIQUE' name='GAD_FP_LS_LISTELOGIQUE' flags='#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection'/>"+Chr(10)+
          "        <listicon id='#GAD_FP_LS_LISTEMATHS' name='GAD_FP_LS_LISTEMATHS' flags='#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection'/>"+Chr(10)+
          "        <listicon id='#GAD_FP_LS_LISTERECHREF' name='GAD_FP_LS_LISTERECHREF' flags='#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection'/>"+Chr(10)+
          "        <listicon id='#GAD_FP_LS_LISTESTATS' name='GAD_FP_LS_LISTESTATS' flags='#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection'/>"+Chr(10)+
          "        <listicon id='#GAD_FP_LS_LISTETEXTE' name='GAD_FP_LS_LISTETEXTE' flags='#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection'/>"+Chr(10)+
          "        <listicon id='#GAD_FP_LS_LISTEUTIL' name='GAD_FP_LS_LISTEUTIL' flags='#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection'/>"+Chr(10)+
          "        <listicon id='#GAD_FP_LS_LISTERECHERCHE' name='GAD_FP_LS_LISTERECHERCHE' flags='#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection'/>"+Chr(10)+
          "      </multibox>"+Chr(10)+ ;}
          "      <hbox expand='item:1' spacing='0'>"+Chr(10)+
          "        <string id='#GAD_FP_CP_FONCTION' name='GAD_FP_CP_FONCTION' flags='#PB_String_ReadOnly|#PB_String_BorderLess'/>"+Chr(10)+
          "        <buttonimage id='#GAD_FP_BT_COPIERFONCTION' name='GAD_FP_BT_COPIERFONCTION'/>"+Chr(10)+
          "      </hbox>"+Chr(10)+
          "      <editor id='#GAD_FP_ED_DESCRIPTION' name='GAD_FP_ED_DESCRIPTION' height='52' flags='#PB_Editor_ReadOnly|#PB_Editor_WordWrap'/>"+Chr(10)+
          "      <hyperlink id='#GAD_FP_LH_AIDE' name='GAD_FP_LH_AIDE' text='Hyperlink' flags='#PB_Hyperlink_Underline'/>"+Chr(10)+
          "    </vbox>"+Chr(10)+ ;}
          "  </window>"+Chr(10)+
          "</dialogs>" ;}
;
If ParseXML(0,ChaineXML)
  If XMLStatus(0)=#PB_XML_Success
    If CreateDialog(0)
      NoDialogue=OpenXMLDialog(0,0,"FEN_PRINCIPALE",0,0,0,0)
      If NoDialogue
        HideWindow(#FEN_PRINCIPALE,#False)
        Repeat
        Until WaitWindowEvent()=#PB_Event_CloseWindow
      EndIf
    EndIf
  EndIf
EndIf
If NoDialogue
  FreeXML(0)
  FreeDialog(0)
EndIf

Re: Dialog library and vertical block expansion

Posted: Tue Aug 27, 2024 8:22 pm
by boddhi
Hi Jac,
jacdelad wrote: The problem is not converting the constant into a value, it's the missing "Runtime" for your enumeration!
You're absolutely right! MEA CULPA EST, MEA MAXIMA CULPA EST !
Indeed, in my example, I typed a bit quickly on the fly. and missed the 'Runtime' instruction, which is present in my first code above.

Re: Dialog library and vertical block expansion

Posted: Tue Aug 27, 2024 9:19 pm
by jacdelad
No problem. After all the bad advices I give it's good to sometimes be right. :mrgreen: