Previously I have used (like most) the standard or a custom ribbon bitmap for use in VO toolbars. Apart from are some limitations (colours etc), the main pain in using the bitmaps is creating the ribbon in the first place if you which to use other images for the toolbar. I also use the great little SEMenu which already uses icons so why set up another set of images, so I thought there must be an easier way.
Because the toolbar can use an imagelist, then it is a simple matter of switching to icons instead of the ribbon. To do this, dont use the bitmap selector in the menu editor, instead in the postinit of your menu just put in a call to a modified toolbar.
I hope this is of use to someone.
Duncan McIntosh
Method PostInit Class MyMeu
self:Toolbar := MyToolbar{}
----------------------------------------------------
Probably best to create your own MyToolbar class and
also inherited classes for each type of toolbar if your have many.
----------------------------------------------------
CLASS MyToolbar INHERIT Toolbar
DECLARE METHOD Append
EXPORT ImageList AS ImageList
EXPORT IconCounter AS DWORD
METHOD Append(symIcon AS SYMBOL, cCaption AS STRING, dwMenuID AS
DWORD) AS LOGIC PASCAL CLASS MyToolbar
//p Add a toolbar icon
SELF:IconCounter := SELF:IconCounter + 1
SELF:ImageList:Add(MyIcon(symIcon)) // See note below - using icons
SELF:AppendItem(SELF:IconCounter, dwMenuID, NIL, NIL, NIL,
SELF:IconCounter)
SELF:AddTipText(SELF:IconCounter, dwMenuID, cCaption)
RETURN TRUE
METHOD AppendGap() CLASS MyToolbar
SELF:AppendItem(IDT_SEPARATOR)
RETURN SELF
METHOD Init(oOwner, xID, oPoint, oDimension, lEnableBands) CLASS MyToolbar
SUPER:Init(oOwner, xID, oPoint, oDimension, lEnableBands)
IF MyColourCount() <= 256
SELF:ImageList := ImageList{0, Dimension{16, 16}, NIL,ILC_COLOR4+ILC_MASK}
ELSE
SELF:ImageList := ImageList{0, Dimension{16, 16}, NIL,ILC_COLOR24+ILC_MASK}
ENDIF
SELF:SetImageList(SELF:ImageList)
// Insert your own toolbar in here, or delete these and subclass
SELF:Append(#New, "New", IDM_BasicMenu_File_New_ID)
SELF:Append(#Open, "Open", IDM_BasicMenu_File_Open_ID)
SELF:AppendGap()
SELF:Append(#Save, "Save", IDM_BasicMenu_File_Save_ID)
SELF:AppendGap()
RETURN SELF
----------------------------------------------------
You can use icons from the icon editor, however I prefer to
just use a resource and use commercial quality icons that can
any number of colours or sizes.
----------------------------------------------------
RESOURCE Icon_New Icon c:\temp\new.ico
RESOURCE Icon_Open Icon c:\temp\Open.ico
RESOURCE Icon_Save Icon c:\temp\Save.ico
FUNCTION MyColourCount() AS FLOAT PASCAL
//p Extract the number of colours the system is currently configured
for
LOCAL ptrWindow AS PTR
LOCAL fNumberColours AS FLOAT
LOCAL fBits AS FLOAT
ptrWindow := GetDC(GetDesktopWindow())
IF ptrWindow <> NULL_PTR
fBits := FLOAT(GetDeviceCaps(ptrWindow, BITSPIXEL)) *
FLOAT(GetDeviceCaps(ptrWindow, PLANES))
fNumberColours := 2.0 ^ fBits
ENDIF
RETURN fNumberColours
FUNCTION MyIcon(symName AS SYMBOL) AS Icon PASCAL
//p Make an Icon from a resource VO DLL
LOCAL oIcon AS Icon
LOCAL oResourceID AS ResourceID
LOCAL ptrHandle AS PTR
LOCAL cWorkDir AS STRING
LOCAL cIcon AS STRING
// LOCAL cLibrary AS STRING
cWorkDir := WorkDir()
cIcon := "ICON_" + AsString(symName )
// Is using a DLL
// cLibrary := cWorkDir + "MyIcons.dll"
// LoadLibrary(PSZ(_CAST, cLibrary ))
// ptrHandle := GetModuleHandle(PSZ(_CAST, cLibrary ))
// Using the current EXE
ptrHandle := _GetInst()
oResourceID := ResourceID{ cIcon, ptrHandle }
oIcon := Icon{ oResourceID, NIL, 16, 16 } // Or whatever size you
like. Could change to pass as parameter
RETURN oIcon