Flat toolbars with explorer style buttons

new topic     » topic index » view thread      » older message » newer message

Okay, in an endless pursuit to come up with a nice looking flat toolbar that
works with Win32Lib I would like to submit the following:

global constant nCreateToolbarEx    = registerw32Function( comctl32,
"CreateToolbarEx",
{C_LONG,C_LONG,C_LONG,C_LONG,C_LONG,C_LONG,C_POINTER,C_LONG,C_LONG,C_LONG,C_LONG,C_LONG,C_LONG},
C_LONG )

-- Create the toolbar and subclass as a flat toolbar
global constant
MainTB__ = w32Func( nCreateToolbarEx, 
                    {getHandle(MainWin),
or_all({WS_CHILD,WS_VISIBLE,TBSTYLE_FLAT,CCS_NODIVIDER,TBSTYLE_TOOLTIPS}),
                    10000,0,0,0,0,0,16,16,16,16,16} ),
MainTB = subClassControl( {FlatToolBar,MainWin}, MainTB__ )

-- Load images for the toolbar
   atom dib, String, Void, hBtn

   -- Create the image lists
hnList = w32Func(
    ImageList_Create,{16,16,or_all({ILC_COLOR16,ILC_MASK}),1,1} )
    String = allocate_string( "e16x16LongNormal.bmp" )
    dib = w32Func( xLoadImage,{0,String,IMAGE_BITMAP,0,0,LR_LOADFROMFILE} )
    free( String )
    Void = w32Func( ImageList_AddMasked,{hnList,dib,#000000} )
    Void = sendMessage( MainTB, TB_SETIMAGELIST, 0, hnList )

hhList = w32Func(
    ImageList_Create,{16,16,or_all({ILC_COLOR16,ILC_MASK}),1,1} )
    String = allocate_string( "e16x16LongOver.bmp" )    
    dib = w32Func( xLoadImage,{0,String,IMAGE_BITMAP,0,0,LR_LOADFROMFILE} )
    free( String )
    Void = w32Func( ImageList_AddMasked,{hhList,dib,#000000} )
    Void = sendMessage( MainTB, TB_SETHOTIMAGELIST, 0, hhList )

-- Create buttons
global constant NewPB = createEx( PictureButton, "New", MainTB, 12, 0, 16, 16,
0, 0 )
global constant OpenPB = createEx( PictureButton, "Open", MainTB, 13, 0, 16, 16,
0, 0 )
global constant SavePB = createEx( PictureButton, "Save", MainTB, 14, 0, 16, 16,
0, 0 )
global constant SaveAsPB = createEx( PictureButton, "Save As", MainTB, 14, 0,
16, 16, 0, 0 )
global constant SB1 = createEx( SepButton, "", MainTB, 0, 0, 0, 0, 0, 0 )
global constant CutPB = createEx( PictureButton, "Cut", MainTB, 6, 0, 16, 16, 0,
0 )
global constant CopyPB = createEx( PictureButton, "Copy", MainTB, 7, 0, 16, 16,
0, 0 )
global constant PastePB = createEx( PictureButton, "Paste", MainTB, 8, 0, 16,
16, 0, 0 )
global constant UndoPB = createEx( PictureButton, "Undo", MainTB, 9, 0, 16, 16,
0, 0 )
global constant SB2 = createEx( SepButton, "", MainTB, 0, 0, 0, 0, 0, 0 )
global constant CreatePB = createEx( PictureButton, "Create", MainTB, 35, 0, 16,
16, 0, 0 )
global constant ExecutePB = createEx( PictureButton, "Run", MainTB, 2, 0, 16,
16, 0, 0 )
global constant ClearHistPB = createEx( PictureButton, "Clear History", MainTB,
60, 0, 16, 16, 0, 0 )
global constant SB3 = createEx( SepButton, "", MainTB, 0, 0, 0, 0, 0, 0 )
global constant RefreshPB = createEx( PictureButton, "Refresh", MainTB, 51, 0,
16, 16, 0, 0 )
global constant SB4 = createEx( SepButton, "", MainTB, 0, 0, 0, 0, 0, 0 )
global constant PrefsPB = createEx( PictureButton, "Preferences", MainTB, 58, 0,
16, 16, 0, 0 )


Now with the above code the menu bar will look something like:

http://66.140.221.68/frog.jpg

You can download the bitmaps referenced in the code above from
http://66.140.221.68/e16x16LongNormal.bmp
http://66.140.221.68/e16x16LongOver.bmp

Although I admit it may not be perfect, the tooltips don't display sometimes for
the buttons.


Jonas Temple
http://www.yhti.net/~jktemple

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu