Guidance
指路人
g.yi.org
Guidance Forums / Reginald Rexx / Tab Control activating a label

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Tab Control activating a label
#7653
Posted by: PeterJ 2005-12-09 19:14:26
I have a minor problem with activating a label in tab-control. This code lets the user add or remove new tabs via clicking on Add/Remove buttons.

When the user removes the currently active label, I want to re-activate another label. I use:
SAY guisetctlvalue('MyTab', newhandle)
where newhandle is the label which should become active. But no label becomes activated -- they all remain "unselected". By clicking on it, it works fine.

Any idea, what is wrong?

/*
GUIBEGIN
WINDOW , 1, 56, 525, 275, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX, , MPSF HTTP
	FONT 8, 400, MS Shell Dlg
	TAB 4, 17, 516, 248, SINGLELINE|RIGHTJUSTIFY, , MyTab
	PUSH 6, 9, 27, 9, TABSTOP, , NewTab, , +Tab
	PUSH 34, 9, 27, 9, TABSTOP, , RemoveTab, , -Tab
DEND
GUIEND
*/

LIBRARY rexxgui
guierr = "SYNTAX"
guiheading = 1

guicreatewindow()
tabname.0 = 0
addnewtab()
guisetctlplacement(,,,,,,'NORMAL')

again:
DO FOREVER
   guigetmsg()
   CATCH SYNTAX
      CONDITION('M')
      SIGNAL again
   CATCH HALT
   FINALLY
      guidestroywindow()
END
RETURN

/*  User requested change of tab control */
wm_selchange_mytab:
   RETURN

/* Add new TAB */
addnewtab:
   tabi = tabname.0+1
   tabvalue = tab || tabi
   tabname.0 = tabi
   tabname.tabi = tabvalue
   guiaddctltext('MyTab', tabvalue, tabi)
   RETURN

/* Remove TAB Control */    
removetab:
   IF tabname.0 <= 1 THEN RETURN 
   mytab = "TAB"newhandle
   guigetctlvalue('MyTab')
   /* it seems GUIGETCTLValue sets the original rexx variable Table */
   newhandle = tabname.0
   DO i=1 TO tabname.0
      IF mytable = tabname.i THEN DO
         tabname.i = ''
         LEAVE
      END
      ELSE newhandle=i
  END

  guiremovectltext('myTab','')  
  guisetctlvalue('MyTab',newhandle) tabname.newhandle 'should be active now'
  RETURN

/*  User requested new tab */
wm_click_newtab:
   addnewtab()
   RETURN

/* User requested remove of tab */
wm_click_removetab:
   removetab()
   RETURN
Message2. Re: Tab Control activating a label
#7671
Posted by: Jeff Glatt 2005-12-13 19:53:16
You can send a "SETCURSEL" message. The third arg is the tab number to select, where 0 is the first tab.
Message3. Re
#7673
Posted by: JanP 2005-12-14 03:25:24
There is something strange that I don't understand. The first GuiSetCtlValue does not work (no error , but nothing happens). I don't know what's wrong.
I have just added the following statements before "again:" label, after addnewtab():
addnewtab()
mytab = "TAB1"
ERROR = guisetctlvalue('MyTab')
again:
Do you remember in my clipbook rexx that I had to use variable "FirstDBClick" to execute "GuiRemoveCtl" 2 times? Same symptoms here I think. But I don't know why.

Here is an example that works.
/*
GUIBEGIN
WINDOW , 1, 56, 525, 275, POPUP|CAPTION|SYSMENU|MINBOX|MAXBOX, , MPSF HTTP
    FONT 8, 400, MS Shell Dlg
    TAB 4, 17, 516, 248, SINGLELINE|RIGHTJUSTIFY, , MyTab
    PUSH 6, 9, 27, 9, TABSTOP, , NewTab, , +Tab
    PUSH 34, 9, 27, 9, TABSTOP, , RemoveTab, , -Tab
DEND
GUIEND
*/

LIBRARY rexxgui
guierr = "SYNTAX"
guiheading = 1

guicreatewindow()

tabname.0 = 0
addnewtab()
mytab = "TAB1"
guisetctlvalue('MyTab')

guisetctlplacement(,,,,,,'NORMAL')

again:
DO FOREVER
   guigetmsg()
   CATCH SYNTAX
      CONDITION('M')
      SIGNAL again
   CATCH HALT
   FINALLY
      guidestroywindow()
END
RETURN

/* User changed the selected tab */
wm_selchange_tab:
   RETURN

/* Add new TAB */
addnewtab:
   tabi = tabname.0 + 1
   tabvalue = tab || tabi
   tabname.0 = tabi
   tabname.tabi = tabvalue
   guiaddctltext("MyTab", tabvalue, tabi)
   RETURN

/* Remove TAB */    
removetab:
   IF tabname.0 <= 1 THEN RETURN 
   guigetctlvalue('MyTab')
   newhandle = tabname.0
   DO i = 1 TO tabname.0
      IF mytab = tabname.i THEN DO
         tabname.i = ''
         LEAVE
      END
      ELSE IF tabname.i \= '' THEN newhandle = i
   END
   guiremovectltext('myTab','')  
   mytab = "TAB"newhandle
   guisetctlvalue('MyTab')
   RETURN

/* User wants newly added tab */
wm_click_newtab:
   addnewtab()
   RETURN

/* User wants removal of tab */
wm_click_removetab:
   removetab()
   RETURN
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
¥317.00 ·
 
 
¥1,480.00 ·
 
 
¥880.00 ·
 
 
¥470.00 ·
 
 
¥1,380.00 ·
 
 
© Tue 2024-11-5  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0