Re: [WIN32Lib] programmatically select tab item?
Tone,
Looks like I spoke too soon, your example manifests the same problem I
encountered: child controls of the tabitems aren't properly "moved" to the
remaining tabitems when a tabitem is deleted. Look at the folder numbered
*four* in your example, you'll see that it has the group control for folder
# *THREE* in it.
I expected that deleting a tabItem from a folder would "carry" the
associated controls from all the succeeding tabitems with them, but instead
the original assignments appear to be "copied" to the new tabitems; so,
folders 1 & 2 have the proper (old) assignments of groups 1 & 2, but after
deleting folder "three", folder named "four", in *position* number 3, shows
group #3 in it.
So, does anyone know if there is some way to "re-assign" controls after
they've been created, so I could make the lists that are displayed with each
tabitem be correct?
I tried "destroy"ing the deleted tabitem, but it seems that may have
actually destroyed the entire tabCONTROL. Also, in my actual program, I did
delete the deleted folder handle from the handle variable, but that was just
so correct data would be written to a file afterward, I don't think that
could possibly have any effect on the association of control to parent.
Dan
Here's an example program I made to test what Tone showed me:
-- code begins:
-- code generated by Win32Lib IDE v0.10.4
include Win32Lib.ew
without warning
-- Window Window1
global constant Window1 = create( Window, "Window1", 0, Default, Default,
400, 300, 0 )
constant
aStatusBar = create( StatusBar, "", Window1, 0, 25, 20, 20, 0)
global constant aTabControl = create( TabControl, "TabControl", Window1, 48,
56, 292, 204, 0 )
for n = 1 to 5 do -- make 5 tab items:
Tabs &= create(TabItem,"TabItem" & sprint(n), aTabControl, 0, 0, 0, 0, 0 )
end for
for n = 1 to 5 do -- make 5 lists, one for each tab item:
Lists &= create( List, "List" & sprint(n), Tabs[n], 24, 36, 248, 140, 0 )
end for
global constant PushButtonDelTab = create( PushButton, "Delete Selected Tab
Item", Window1, 88, 8, 184, 32, 0 )
end for
procedure onClick_PushButtonDelTab()
object tabSelected
tabSelected = sendMessage(aTabControl,TCM_GETCURSEL, 0 ,0 )
setText(aStatusBar, sprint(tabSelected))
result = sendMessage(aTabControl,TCM_DELETEITEM,tabSelected, 0 )
if sendMessage(aTabControl,TCM_GETITEMCOUNT,0,0)= tabSelected then
--last tab removed, so gotta backup one:
result = sendMessage(aTabControl,TCM_SETCURSEL,tabSelected-1, 0 )
else
result = sendMessage(aTabControl,TCM_SETCURSEL,tabSelected, 0 )
end if
-- destroy(Lists[tabSelected+1])-- HANDLE ERROR, maybe destroys whole
tabcontrol??
end procedure
onClick[PushButtonDelTab] = routine_id("onClick_PushButtonDelTab")
WinMain( Window1, Normal )
-- code ends
----- Original Message -----
From: <tone.skoda at siol.net>
To: "EUforum" <EUforum at topica.com>
Sent: Saturday, March 23, 2002 3:19 AM
Subject: Re: [WIN32Lib] programmatically select tab item?
>
> Dan Moyer wrote:
> > how would I use
> > TCM_DELETEITEM & TCM_SETCURSEL
> > in a program using Win32Lib?
>
> It's pretty simple, below is example. There may be some issues with
Win32Lib
> because it's not expecting that you do this.
> To Derek: These actions should become possible to do this with Win32Lib's
> functions
> deleteItem () and selectItem () (this one doesn't exist yet)
>
> Syntax:
>
> Void = sendMessage (tabControl window, message (action), index of tab item
> to delete starting at 0, 0)
>
> -- select and delete tab items.exw
>
> without warning
> with trace
> include win32lib.ew
>
> integer win, tc, t1, t2, t3, t4
> integer te1, te2, te3, te4
> integer g1, g2, g3, g4
> object Void
>
> procedure main()
> win = createEx(Window, "Test Tabcontrol", 0, 0, 0, 640, 480, 0, 0)
> tc = createEx(TabControl, "", win, 5, 25, 600, 400, 0, 0)
> t1 = createEx(TabItem, "One", tc, 5, 25, 590, 390, 0, 0)
> t2 = createEx(TabItem, "Two", tc, 5, 25, 590, 390, 0, 0)
> t3 = createEx(TabItem, "Three", tc, 5, 25, 590, 390, 0, 0)
> t4 = createEx(TabItem, "Four", tc, 5, 25, 590, 390, 0, 0)
>
> g1 = createEx(Group, " group 1", t1, 5, 25, 400, 300, 0, 0)
> g2 = createEx(Group, " group 2", t2, 5, 25, 400, 300, 0, 0)
> g3 = createEx(Group, " group 3", t3, 5, 25, 400, 300, 0, 0)
> g4 = createEx(Group, " group 4", t4, 5, 25, 400, 300, 0, 0)
>
> te1 = createEx(Combo, "control1", g1, 5, 25, 200, 125, 0, 0)
> te2 = createEx(Combo, "control2", g2, 10, 27, 200, 125, 0, 0)
> te3 = createEx(Combo, "control3", g3, 15, 29, 200, 125, 0, 0)
> te4 = createEx(Combo, "control4", g4, 20, 31, 200, 125, 0, 0)
>
> -------------------- SELECT TAB ITEM --------------------
> -- select second item (number 1)
> Void = sendMessage (tc, TCM_SETCURSEL, 1, 0)
>
> -------------------- DELETE TAB ITEM --------------------
> -- delete third item (number 2)
> Void = sendMessage (tc, TCM_DELETEITEM, 2, 0)
>
> WinMain(win, Normal)
>
> end procedure
>
> main()
>
>
>
>
|
Not Categorized, Please Help
|
|