kostenlose counter
Seit 01.12.2006
 
 
Welcome > Access - Ribbons > User Defined Icons / Pictures In Ribbon Controls
 
 

User Defined Icons / Pictures In Ribbon Controls

You can use your own icons an pictures in Ribbon Controls. Instead of the callback imageMSO="xxx" you require "getImage" in Ribbon XML.




The Sample DB contains the function "getAppPath()" which is used to return the database folder and name, where also the icons and pictures are stored. File name including extension has been stored in attribute "tag" in the XML file.

Ribbon XML Synax:

<button id="MyButton" label="My Button" size="large" 
  getImage
="getImages" tag="ga.ico"
 
onAction
="MyButtonCallbackOnAction" />



There are two options for callback "getImages" to load user-defined pictures:

Either with build-in Access functions (no transparency) :


Public Sub getImages(control As IRibbonControl, _
                     ByRef image)

' Loads a picture without transparency into the ribbon
' Only valid picture formats must be used (see OH).

   

    Set Image = LoadPicture(getAppPath & control.Tag)
   
'Or a ImageMso 

    image = "HappyFace" 


End Sub


oder with GDI+ (the module "basGDI" is required. Transparency and multiple picture formats supported).


Public Sub getImages(control As IRibbonControl, _
                     ByRef image)


' Loads a picture with transparency into the ribbon
' The modul basGDI is required.

 
    Set image = LoadPictureGDIP(getAppPath & control.Tag)

'Or a ImageMso 

    image = "HappyFace" 

End Sub

Required Functions:


 Additional function to be copied to a standard module:

Public Function getAppPath() As String
' Returns the current database folder

    getAppPath = Left(CurrentDb.Name, Len(CurrentDb.Name) _
    - Len(Dir(CurrentDb.Name)))
End Function

 Module basGDI required for second example:

You can find this module in Sample DB 3

The module originates from: Sascha Trowitzsch (German) .You can also load it from there. Otherwise you can adjust the sample project from ActiveVB.



 

 
 
 
 
 
 
 
 

©2000-2010 Gunter Avenius

Powered By CMSimple.dk | Design By Dotcomwebdesign.com