Page 1 of 1
CJSHORTCUTBAR
Posted: Sun Mar 08, 2015 9:23 am
by unixkd
Hi Roger/ALL
How can I load bitmap from resource linked to EXE intead of using CJshortcutbarLoadBitMap command:
CJshortcutbarLoadBitMap '..\..\..\bitmaps\design.bmp' ID BITMAP_DESIGN_M STATE xtpImageNormal PARENT oShortCutBar
CJshortcutbarLoadBitMap '..\..\..\bitmaps\calc.bmp' ID BITMAP_CALCULATOR_M STATE xtpImageNormal PARENT oShortCutBar
CJshortcutbarLoadBitMap '..\..\..\bitmaps\calendar.bmp' ID BITMAP_CALENDAR_M STATE xtpImageNormal PARENT oShortCutBar
CJshortcutbarLoadBitMap '..\..\..\bitmaps\bug.bmp' ID BITMAP_BUG_M STATE xtpImageNormal PARENT oShortCutBar
CJshortcutbarLoadBitMap '..\..\..\bitmaps\exit_m.bmp' ID BITMAP_EXIT_M STATE xtpImageNormal PARENT oShortCutBar
CJshortcutbarLoadBitMap '..\..\..\bitmaps\hex.bmp' ID BITMAP_HEX_M STATE xtpImageNormal PARENT oShortCutBar
CJshortcutbarLoadBitMap '..\..\..\bitmaps\help.bmp' ID BITMAP_HELP_M STATE xtpImageNormal PARENT oShortCutBar
Thanks
Joe
Re: CJSHORTCUTBAR
Posted: Sun Mar 08, 2015 11:52 am
by rdonnay
Use the command CjLoadBitMapFromResource.
#command CJLoadBitMapFromResource <bitmap> [HANDLE <handle>] [ID <id>] ;
[STATE <state>] [PARENT <parent>] [TO <status>] => ;
[<status> := ] <parent>:LoadBitMapFromResource( <handle>, <bitmap>, <id>, <state> )
Re: CJSHORTCUTBAR
Posted: Sun Mar 08, 2015 2:29 pm
by unixkd
Thanks Roger,
1. I Think the command should include :icon: as shown below:
#command CJLoadBitMapFromResource <bitmap> [HANDLE <handle>] [ID <id>] ;
[STATE <state>] [PARENT <parent>] [TO <status>] => ;
[<status> := ] <parent>:icons:LoadBitMapFromResource( <handle>, <bitmap>, <id>, <state> )
2. From the codejock documentation, it appears that the handle of the EXE that contains the bitmap resources is mandatory.
3. From Codejock doc, I have
Syntax
Public Sub LoadBitmapFromResource( _
ByVal Module As Long, _
ByVal Resource As Long, _
ByVal Commands As Variant, _
ByVal imageState As XTPImageState _
)
Parameters
Module
hModule - Handle to an instance of the module that contains the image to be loaded.
Resource
Specifies the image to load in the resources of the module.
Commands
The id that will be used to identify the icon in the collection of icons. This can be any positive (non-zero) number.
imageState
Value Description
xtpImageNormal Specifies a normal icon. This is the image displayed when the item is displayed normally.
xtpImageDisabled Specifies a disabled icon. This is the image displayed when the item is in disabled.
xtpImageHot Specifies a hot icon. This is the image displayed when the mouse pointer is positioned over the item.
xtpImageChecked Specifies a "checked"\selected icon. This is the image displayed when the item is in a selected state.
xtpImagePressed Specifies a "pressed"\pushed icon. This is the image displayed when the item is in currently pressed my the mouse cursor.
The state of the image.
Remarks
The "Commands" parameter can be any positive integer and is used to identify the icon in the collection of icons. When you want to use an icon, you need to specify this value. To use the icon, you would assign the "Commands" value to the Icon property of the objects.
The sample application below crashed when I try the command changes.
///////////////////////////////////////////////////////////////////////////////
//
// Shortcutbar with Xbase++ and eXPress++
// Creation date: 15/12/2008
// Chris Andries - ABO service bvba - Belgium
//
///////////////////////////////////////////////////////////////////////////////
#include "Gra.ch"
#include "Xbp.ch"
#include "Appevent.ch"
#include "Font.ch"
#INCLUDE "dcdialog.CH"
#INCLUDE "dcbitmap.CH"
#INCLUDE "shortcutbar.CH"
#define shortcutbarCLSID 'Codejock.ShortcutBar.13.2.1'
#command CJShortCutBarLoadBitMap <bitmap> [ID <id>] [STATE <state>] [PARENT <shortcut>] => ;
<shortcut>:icons:LoadBitMap( <bitmap>, <id>, <state> )
#command CJLoadBitMapFromResource <bitmap> [HANDLE <handle>] [ID <id>] ;
[STATE <state>] [PARENT <parent>] [TO <status>] => ;
[<status> := ] <parent>:icons:LoadBitMapFromResource( <handle>, <bitmap>, <id>, <state> )
#PRAGMA LIBRARY( "ASCOM10.LIB" )
PROC appsys ; RETURN
function Main()
LOCAL getlist := {} , getoptions := {}
LOCAL oshortcutbar , oGet , lVisible := .T.
@ 1,1 DCACTIVEXCONTROL oshortcutbar SIZE 30 , 30 ;
CLSID shortcutbarCLSID ;
EVAL {|o| o:VisualTheme := 2 , o:selectedchanged := {|a|_ActionEval(oShortcutbar)} , shortcutgroups(o,.T.) }
@ 2,40 dccheckbox lVisible prompt 'ClientPaneVisible' action {|| oShortCutbar:ClientPaneVisible := lvisible }
dcread gui fit addbuttons
RETURN nil
Function Shortcutgroups(oShortCutBar,lVisible)
*****************************
Local oItem
CJLoadBitMapFromResource BITMAP_DESIGN_M ID BITMAP_DESIGN_M STATE xtpImageNormal PARENT oShortCutBar
CJLoadBitMapFromResource BITMAP_CALCULATOR_M ID BITMAP_CALCULATOR_M STATE xtpImageNormal PARENT oShortCutBar
CJLoadBitMapFromResource BITMAP_CALENDAR_M ID BITMAP_CALENDAR_M STATE xtpImageNormal PARENT oShortCutBar
CJLoadBitMapFromResource BITMAP_BUG_M ID BITMAP_BUG_M STATE xtpImageNormal PARENT oShortCutBar
CJLoadBitMapFromResource BITMAP_EXIT_M ID BITMAP_EXIT_M STATE xtpImageNormal PARENT oShortCutBar
CJLoadBitMapFromResource BITMAP_HEX_M ID BITMAP_HEX_M STATE xtpImageNormal PARENT oShortCutBar
CJLoadBitMapFromResource BITMAP_HELP_M ID BITMAP_HELP_M STATE xtpImageNormal PARENT oShortCutBar
/*
CJshortcutbarLoadBitMap '..\..\..\bitmaps\design.bmp' ID BITMAP_DESIGN_M STATE xtpImageNormal PARENT oShortCutBar
CJshortcutbarLoadBitMap '..\..\..\bitmaps\calc.bmp' ID BITMAP_CALCULATOR_M STATE xtpImageNormal PARENT oShortCutBar
CJshortcutbarLoadBitMap '..\..\..\bitmaps\calendar.bmp' ID BITMAP_CALENDAR_M STATE xtpImageNormal PARENT oShortCutBar
CJshortcutbarLoadBitMap '..\..\..\bitmaps\bug.bmp' ID BITMAP_BUG_M STATE xtpImageNormal PARENT oShortCutBar
CJshortcutbarLoadBitMap '..\..\..\bitmaps\exit_m.bmp' ID BITMAP_EXIT_M STATE xtpImageNormal PARENT oShortCutBar
CJshortcutbarLoadBitMap '..\..\..\bitmaps\hex.bmp' ID BITMAP_HEX_M STATE xtpImageNormal PARENT oShortCutBar
CJshortcutbarLoadBitMap '..\..\..\bitmaps\help.bmp' ID BITMAP_HELP_M STATE xtpImageNormal PARENT oShortCutBar
*/
oItem := oShortCutBar:AddItem(BITMAP_DESIGN_M, "Mail", 1)
oItem:id := 1
oItem := oShortCutBar:AddItem(BITMAP_CALENDAR_M, "Calendar", 2)
oItem:id := 2
oItem:tooltip := 'This is the calendar tooltip'
// oItem:selected := .T. // this item is preselected and the event o:selectedchanged is fired.
oItem := oShortCutBar:AddItem(BITMAP_CALCULATOR_M, "Calculator", 0 )
oItem := oShortCutBar:AddItem( BITMAP_EXIT_M, "My SQL",0)
oItem := oShortCutBar:AddItem(BITMAP_HELP_M, "SQL Server 2005", 0)
oItem := oShortCutBar:AddItem(BITMAP_HEX_M, "Item 6", 0)
oShortCutbar:ExpandedLinesCount := 7
oShortCutbar:ClientPaneVisible := lVisible
return nil
function _ActionEval(oShortCutbar)
***********************************
Local oItem:= oShortCutBar:selected()
msgbox(oItem:caption)
return nil
Re: CJSHORTCUTBAR
Posted: Sun Mar 08, 2015 3:25 pm
by rdonnay
Look at \exp19\xcodejock\samples\commandbars\menubar.prg
nHandle1 := DllLoad('..\..\..\BIN19\DCRES.DLL') // some bitmaps are in DLL
nHandle2 := GetModuleHandleA(0) // some bitmaps are in EXE
DC_BitmapResourceFile( { nHandle1, nHandle2} )