1. RE: Explorer-style menu and tool bars
> -----Original Message-----
> From: Jonas Temple [mailto:jktemple at yhti.net]
> Is it possible with Win32lib to create IE style tool bars?
> Specifically, IE has a menu in a rebar which doesn't seem to
> be valid in
> win32lib. Also, is it possible to have a rebar band with
> button styles
> like IE (flat buttons that have a border when the mouse
> hovers, edit and
> drop-down boxes and such)?
Explorer actually just uses a flattoolbar with buttons with text and popup
menus.
Matt Lewis
2. RE: Explorer-style menu and tool bars
Don,
Got Nexus the day you changed to INI files. Love it! Especially like
the Goto Subroutine function.
Yes, your toolbar is EXACTLY what I'm looking for. I glanced at your
code but can't quite put it all together. I'd be very grateful for any
explanation. I really think that this type of toolbar should be
standard in win32lib.
Jonas
Don Phillips wrote:
> Check out Nexus some time and see if my toolbar is
> what you are looking for. If so, I can quickly weed
> out the code you would be interested in and make a
> "demo" type program showing you how to build one (when
> time permits).
3. RE: Explorer-style menu and tool bars
> Don,
>
> Got Nexus the day you changed to INI files. Love it! Especially like
> the Goto Subroutine function.
Thanks =) Glad you like it...
> Yes, your toolbar is EXACTLY what I'm looking for. I glanced at your
> code but can't quite put it all together. I'd be very grateful for any
> explanation. I really think that this type of toolbar should be
> standard in win32lib.
>
> Jonas
Try this very much smaller, sparsely commented, very much easier to read
version. Its a good point to start and experiment with. The only thing
it doesnt show in the code is capturing the TBN_DROPDOWN notification
and creating a pop-up menu for it...
Don
====================
-- NOTE: Requires Win32Lib version 57.9 *AND*
-- Files: ToolB1N.bmp, ToolB1H.bmp, ToolB1D.bmp (or place in Nexus
directory)
include Win32Lib.ew
without warning
-- Extra Win32 imports
constant
CreateToolbarEx = registerw32Function( comctl32, "CreateToolbarEx",
LONG,C_LONG,C_LONG,C_POINTER,C_LONG,C_LONG,C_LONG,C_LONG,C_LONG,C_LONG},
C_LONG )
-- Define some constants
constant
ID_TOOLBAR = 10000, -- Toolbar ID (used to identify the
toolbar)
BUTTONWIDTH = 16, -- Size of the buttons (width) added
to the toolbar
BUTTONHEIGHT = 16, -- Size of the buttons (height)
added to the toolbar
SIZEOF_TBBUTTON = 16, -- Size of a TBBUTTON structure
UGLY_MAROON = #424284, -- Mask color I choose for the
toolbar images
BTNS_WHOLEDROPDOWN = #00000080, -- Windows constant for a pull down
button type 1
BUTTONID_NEW = ID_TOOLBAR +1,
BUTTONID_OPEN = ID_TOOLBAR +2,
BUTTONID_SAVE = ID_TOOLBAR +3,
BUTTONID_CUT = ID_TOOLBAR +4,
BUTTONID_SEP = 0
-- Create the controls
constant
MainWin = create( Window, "Toolbar Test", NULL, 0.25, 0.25, 0.5,
0.5, 0 ),
Rebar = create( ReBar, "", MainWin, 0, 0, 0, 0, 0 ),
Rebarband = create( ReBarBand, "", Rebar, 0, 0, 0, 0, 0 ),
Canvas = create( Window, "", Rebar, 0, 0, 0, 22,
{WS_CHILD,WS_VISIBLE,WS_CLIPCHILDREN,WS_CLIPSIBLINGS} ),
-- Create a toolbar directly with API.
hToolbar = w32Func( CreateToolbarEx,
DER}),ID_TOOLBAR,0,0,0,0,0,BUTTONWIDTH,BUTTONHEIGHT,0,0,SIZEOF_TBBUTTON}
),
-- Subclass the new toolbar so we can use standard Win32Lib routines on
it.
Toolbar = subClassControl( {ToolBar,Canvas}, hToolbar )
-- A Toolbar maintains three distinct image lists. One for normal
buttons, one for hot
-- buttons, and one for disabled buttons. Only one (normal) is
required. The Toolbar
-- will also automatically set the image transparency. Just pass in the
color you want masked out
procedure AddToList( sequence File, atom ColorMask, atom ListType )
atom NewList
atom String
atom hBitmap
atom Void
NewList = w32Func( ImageList_Create,
{BUTTONWIDTH,BUTTONHEIGHT,or_all({ILC_COLOR16,ILC_MASK}),1,1} )
String = allocate_string( File )
hBitmap = w32Func(
xLoadImage,{0,String,IMAGE_BITMAP,0,0,LR_LOADFROMFILE} )
free( String )
Void = w32Func( ImageList_AddMasked,{NewList,hBitmap,ColorMask} )
Void = w32Func( xDeleteObject,{hBitmap} )
Void = w32Func( xSendMessage,{hToolbar,ListType,0,NewList} )
end procedure
-- Adds a button to the toolbar
procedure AddButton( integer ButtonID, integer ImageIndex, atom
ButtonState, atom ButtonStyle )
atom TBBUTTON
atom Void
TBBUTTON = allocate( 16 )
poke4( TBBUTTON, {ImageIndex,ButtonID,0,0} )
poke ( TBBUTTON+8, ButtonState )
poke ( TBBUTTON+9, ButtonStyle )
Void = w32Func( xSendMessage, {hToolbar,TB_ADDBUTTONS,1,TBBUTTON} )
free( TBBUTTON )
end procedure
-- Canvas_Handler
procedure Canvas_Handler( integer CntlID, integer Event, sequence Params
)
integer ButtonNum
atom Void
if Params[1] = WM_COMMAND then
if Params[3] = hToolbar then
ButtonNum = lo_word( Params[2] )
if ButtonNum = BUTTONID_NEW then
Void = message_box( "Button New Pressed...", "Toolbar",
MB_OK )
elsif ButtonNum = BUTTONID_SAVE then
Void = message_box( "Button Save Pressed...", "Toolbar",
MB_OK )
elsif ButtonNum = BUTTONID_CUT then
Void = message_box( "Button Save Pressed...", "Toolbar",
MB_OK )
end if
end if
end if
end procedure
setHandler( Canvas, w32HEvent, routine_id("Canvas_Handler") )
-- MainWin_Handler
procedure MainWin_Handler( integer CntlID, integer Event, sequence
Params )
atom Void
if Event = w32HOpen then
-- Make the Canvas window a child of the Rebarband
addToBand( Canvas, Rebarband )
-- Initialize the toolbar bitmap lists
AddToList( "ToolB1N.bmp", UGLY_MAROON, TB_SETIMAGELIST )
-- Normal dark grey buttons
AddToList( "ToolB1H.bmp", UGLY_MAROON, TB_SETHOTIMAGELIST )
-- Colored buttons
AddToList( "ToolB1D.bmp", UGLY_MAROON, TB_SETDISABLEDIMAGELIST )
-- Disabled buttons
-- Add some buttons to it
AddButton( BUTTONID_NEW, 0, TBSTATE_ENABLED, TBSTYLE_BUTTON )
AddButton( BUTTONID_OPEN, 1, TBSTATE_ENABLED,
BTNS_WHOLEDROPDOWN )
AddButton( BUTTONID_SEP, -1, TBSTATE_ENABLED, TBSTYLE_SEP )
AddButton( BUTTONID_SAVE, 2, TBSTATE_ENABLED, TBSTYLE_BUTTON )
AddButton( BUTTONID_CUT, 3, 0, TBSTYLE_BUTTON )
elsif Params[1] = WM_SIZE then
Void = sendMessage( Rebar, WM_SIZE, 0, 0 )
Void = sendMessage( Toolbar, TB_AUTOSIZE, 0, 0 )
end if
end procedure
setHandler( MainWin, {w32HOpen,w32HEvent}, routine_id("MainWin_Handler")
)
-- Start Win32Libs event handler
WinMain( MainWin, Normal )
====================
4. RE: Explorer-style menu and tool bars
Don,
Thanks for the example! I had to fill in some blanks as it seems some
of the code got truncated.
No matter, though, I got it to work and I'm gonna study!
Jonas
Don Phillips wrote:
> Try this very much smaller, sparsely commented, very much easier to read
>
> version. Its a good point to start and experiment with. The only thing
>
> it doesnt show in the code is capturing the TBN_DROPDOWN notification
> and creating a pop-up menu for it...
>
> Don