forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


solution for changing tab captions

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
attreus
Valued Newbie


Joined: 30 Jul 2002
Posts: 46
Location: Berlin/Germany

PostPosted: Mon Feb 16, 2009 12:37 am    Post subject: solution for changing tab captions Reply with quote

hi there,

working on an app with a tab-element i stumbled across the the problem with different labels for tabs when their names change.

here is a working solution for that. maybe it looks somewhat complicated, but this is for the multi-dialog. in fact it's very easy.

i hope it's useful to someone.

greetz. attreus

Code:



#  ***************************************************************************************
#  *                                                                                     *
#  *    Tab-Event-Handling-Example with multiple dialogs in different Languages          *
#  *    -----------------------------------------------------------------------          *
#  *                                                                                     *
#  *        (c)2009 by Attreus                                                           *
#  *                                                                                     *
#  *    This example demonstrates an extension of the normal @event()-function to solve  *
#  *    the problems that occur when captions of a Tab-element change - like usually in  *
#  *    multilanguage applications.                                                      *
#  *    As you can see in the example, this also works with multiple dialogs.            *
#  *                                                                                     *
#  ***************************************************************************************
#                                                                                         

  Title Tab-Event-Handling Example by Attreus

  #    This function handles all events
  #DEFINE FUNCTION,eEvent

  option decimalsep,.
  %%Language = english
  gosub SetLanguage


  DIALOG CREATE,Attreus' Tab-Event-Handling Example,-1,0,360,240,SMALLCAP,Class ExampleMain
  #    Create the tab-element with captions of your choice followed by @eEvent() and a   
  #    name that is used for the label. Call the label ":nameClick". The function inserts
  #    two linefeed-characters followed by an unprintable character (ascii 2), which is   
  #    used for parsing.                                                                 
  DIALOG ADD,TAB,ExampleTab,10,16,340,168,@fill(34,%%Tab1,C)@eEvent()Tab1|@fill(34,%%Tab2,C)@eEvent()Tab2
  DIALOG ADD,BUTTON,OpenChild,202,92,130,24,Open Child Window
  DIALOG ADD,BUTTON,Exit,202,282,64,24,Exit
  DIALOG SHOW

:EvLoop
  wait Event
  #    This is only nessesary for multiple dialogs
  if %%Child
    parse "%E;%D",@eEvent(D)
    dialog select,%D
    goto %E
  end
  #    Use this one instead of the normal "@event()" function
  goto @eEvent()

:OpenChildButton
  dialog disable,openchild
  %%Child = 1
  DIALOG CREATE,Child Dialog,@sum(@winpos(#ExampleMain,T),10),@sum(@winpos(#ExampleMain,L),370),360,240,SMALLCAP
  DIALOG ADD,TAB,ChildTab,10,16,340,168,@fill(34,%%Tab3,C)@eEvent()Tab3|@fill(34,%%Tab4,C)@eEvent()Tab4
  DIALOG ADD,BUTTON,CloseChild,202,168,140,24,Close Child Window
  DIALOG ADD,BUTTON,English,202,14,64,24,English
  DIALOG ADD,BUTTON,Deutsch,202,90,64,24,Deutsch
  dialog disable,%%Language
  DIALOG SHOW
  goto EvLoop

  #    The labels for the different tabs on the tab-element
:Tab1Click
  info Tab 1 %%clicked@tab()
  goto EvLoop

:Tab2Click
  info Tab 2 %%clicked@tab()
  goto EvLoop

:Tab3Click
  info Tab 3 %%clicked@tab()
  goto EvLoop

:Tab4Click
  info Tab 4 %%clicked@tab()
  goto EvLoop

:EnglishButton
  dialog select,0
  dialog set,OpenChild,Open Child Window
  dialog set,Exit,Exit
  dialog select,1
  dialog set,CloseChild,Close Child Window
  dialog disable,English
  dialog enable,Deutsch
  %%Language = English
  gosub SetLanguage
  dialog remove,ChildTab
  DIALOG ADD,TAB,ChildTab,10,16,340,168,@fill(34,%%Tab3,C)@eEvent()Tab3|@fill(34,%%Tab4,C)@eEvent()Tab4
  dialog select,0
  dialog remove,ExampleTab
  DIALOG ADD,TAB,ExampleTab,10,16,340,168,@fill(34,%%Tab1,C)@eEvent()Tab1|@fill(34,%%Tab2,C)@eEvent()Tab2
  goto evloop

:DeutschButton
  dialog select,0
  dialog set,OpenChild,Child Window öffnen
  dialog set,Exit,Beenden
  dialog select,1
  dialog set,CloseChild,Child Window schließen
  dialog disable,Deutsch
  dialog enable,English
  %%Language = Deutsch
  gosub SetLanguage
  dialog remove,ChildTab
  DIALOG ADD,TAB,ChildTab,10,16,340,168,@fill(30,%%Tab3,C)@eEvent()Tab3|@fill(30,%%Tab4,C)@eEvent()Tab4
  dialog select,0
  dialog remove,ExampleTab
  DIALOG ADD,TAB,ExampleTab,10,16,340,168,@fill(30,%%Tab1,C)@eEvent()Tab1|@fill(30,%%Tab2,C)@eEvent()Tab2
  goto evloop

:CloseChildButton
  %%Child =
  dialog close
  while @event()
  wend
  dialog select,0
  window activate,#ExampleMain
  dialog enable,OpenChild
  goto EvLoop

:Close
  if @greater(%D,0)
    goto CloseChildButton
  end
:ExitButton
  exit

:SetLanguage
  if @equal(%%Language,english)
    %%Tab1 = First Tab in english
    %%Tab2 = Second Tab in english
    %%Tab3 = Third Tab in english
    %%Tab4 = Fourth Tab in english
    %%Clicked = was clicked
  end
  if @equal(%%Language,Deutsch)
    %%Tab1 = Erster Tab auf Deutsch
    %%Tab2 = Zweiter Tab auf Deutsch
    %%Tab3 = Dritter Tab auf Deutsch
    %%Tab4 = Vierter Tab auf Deutsch
    %%Clicked = wurde geklickt
  end
  exit

#    The function that handles all events now                                             

:eEvent
  #    Catch the event   
  parse "%E;%D",@Event(D)
  #    Set the delimiter
  if @not(%E)
    exit @chr(10)@chr(10)@chr(2)
  end
  if @equal(%1,D)
    #    If another event occurs
    if @zero(@pos(@chr(2),%E))
      exit %E@fsep()%D
     else
      #    If a tab-event occurs
      %F = @fsep()
      option fieldsep,@chr(2)
      parse "%x;%R",%E
      option fieldsep,%F
      exit @trim(%R)@fsep()%D
    end
   else
    #    The same with single dialog
    if @zero(@pos(@chr(2),%E))
      exit %E
     else
      %F = @fsep()
      option fieldsep,@chr(2)
      parse "%x;%R",%E
      option fieldsep,%F
      exit @trim(%R)
    end
  end




Last edited by attreus on Thu Feb 19, 2009 8:10 pm; edited 1 time in total
Back to top
View user's profile Send private message
uvedese
Contributor
Contributor


Joined: 21 Jan 2006
Posts: 169
Location: Spain

PostPosted: Mon Feb 16, 2009 7:35 am    Post subject: Reply with quote

Hi attreus:

I've worked on a script that lets you simulate tabs elements to change the names of tabs.

You can download the script from my web:

http://vds.uvedese.es/index.php?option=com_content&task=view&id=45&Itemid=27

Good luck
___________

uVeDeSe
____________
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group