1. RE: win32lib: need serious help with Rebar

Dan Moyer wrote:

> I thought "setVisible" would work to switch bands on/off, so I altered a
> rebar demo that comes with Win32Lib to try it, but it only worked with
> controls on the bands, not the bands themselves, at least in under 
> v57.9.

   It might not work, but it did remind me of a quick and dirty
   trick I use sometimes in my "other" development: create a routine
   that builds the Rebar and bands based on user-settings and when
   I want to switch something off, I can destroy the Rebar control
   and rebuild it with whatever is left to show. Not sure if this
   will work, but I can try it smile

Hans Peter Willems

new topic     » topic index » view message » categorize

2. RE: win32lib: need serious help with Rebar

> From: Dan Moyer [mailto:DANIELMOYER at prodigy.net]

> Peter,
> 
> I thought "setVisible" would work to switch bands on/off, so 
> I altered a
> rebar demo that comes with Win32Lib to try it, but it only worked with
> controls on the bands, not the bands themselves, at least in 
> under v57.9.

No, it looks like you need to use RB_DELETEBAND and RB_INSERTBAND.  Here's a
reworked demo that mostly works, although the combobox doesn't get painted
properly until after it's been covered by another window or the rebar gets
resized (it won't really, because it's locked to the size of the window).
Also, the combo may lose its cy size, so you may want to play with that.  I
don't know what effect this will have on other controls, so you'll have to
experiment.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/pla
tform/commctls/rebar/messages/rb_deleteband.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/pla
tform/commctls/rebar/messages/rb_deleteband.asp

-- ReBar.exw
-- Matt Lewis
without warning
with trace
include win32lib.ew

constant                                            
    Win     = create( Window, "ReBar Demo", 0, 20, 20, 300, 300,0) ,
    RB      = create( ReBar, "", Win, 0, 0, 600, 300, 0 ),
    Band1   = create( ReBarBand, "Band 1", RB, 0, 0, 100, 100, RBBS_BREAK),
    CB      = create( Combo, "", RB, 0, 200, 90, 25 * 6, 0 )

integer Band2
    Band2   = create( ReBarBand, "Band 2", RB, 0, 0, 100, 100, RBBS_BREAK)

constant
    Tool    = create( ToolBar, "", RB, 0, 0, 300, 34, 0),
    One     = create( PushButton, "One", Tool, 0, 0, 50, 30, 0 ),
    Two     = create( PushButton, "Two", Tool, 50, 0, 50, 30, 0),
    Lbl1    = create( RText, "Edit1:", Win, 0, 10, 50, 25,0),
    Edit1   = create( SleText, "", Win, 50, 10, 200, 25, 0),
    Lbl2    = create( RText, "Edit2:", Win, 0, 50, 50, 25,  0),
    Edit2   = create( SleText, "", Win, 50, 50, 200, 25, 0),
    toggle  = create( PushButton, "Toggle", Win, 50, 150, 90, 25, 0 )
addToBand( CB,   Band1 )
addToBand( Tool, Band2 )

integer vis
vis = 1
procedure toggle_push( integer self, atom event, sequence params )
	integer void
	atom struct
	vis = 1 - vis

	if vis then
	        struct = struct_REBARBANDINFO(
            or_all( {   RBBIM_ID,       -- fMask
    	                RBBIM_SIZE,
    	                RBBIM_CHILD,
    	                RBBIM_STYLE } ),
            or_all( {   RBBS_CHILDEDGE, -- fStyle
    	        RBBS_GRIPPERALWAYS,
    	        0 }),
            0,          -- clrFore
            0,          -- clrBack
            0,    -- lpText
            0,          -- iImage
            getHandle(CB),          -- hwndChild
            0,          -- cxMinChild
            100,          -- cyMinChild
            100,         -- cx
            0,          -- hbmBack
            0,         -- wID
            0,          -- cyChild
            0,          -- cyMaxChild
            0,          -- cyIntegral
            0,          -- cxIdeal
            0,          -- lParam
            0 )         -- cxHeader
		void = sendMessage( RB, RB_INSERTBAND, 0, struct )
		Band2 = subClassControl( {ReBarBand, RB}, void )
		release_mem(struct)
		repaintWindow( CB )
		setCtlSize( RB, 0,0 )
	else
		void = sendMessage( RB, RB_DELETEBAND, 0, 0 )
	end if
	
end procedure
setHandler( toggle, w32HClick, routine_id("toggle_push"))

addItem( CB, {"One","Two","Etc..."} )

-- This routine ensures that all controls shift up/down if the rebar size
changes.
------------------------------------------------
procedure onResize_Screen(integer self, integer event, sequence parms)
------------------------------------------------ 
   setRect(Edit1, 50, 10, 200, 25, False)
   setRect(Edit2, 50, 50, 200, 25, False)
   setRect(Lbl1, 0, 10, 50, 25, False)
   setRect(Lbl2, 0, 50, 50, 25, False)
   
end procedure
setHandler(Screen, w32HResize, routine_id("onResize_Screen"))

WinMain( Win, Normal )

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu