xsharp.eu • Create a toolbar and and attach to a shell window
Page 1 of 2

Create a toolbar and and attach to a shell window

Posted: Sat Jan 23, 2021 1:45 pm
by Neale
Hello
I am porting my VO business app to XSharp, the app was written some years ago and I am now taking the advantage of using XSharp VO dialect and Visual Studio to start afresh.
I have created a XSharp MDI VO app and started to move code across from VOXPorter, my first problem is attaching a Tooolbar to the ShellWindow, below is the code I am using, the app runs showing the menu with a blank Toolbar ? In my VO app I used SEUIXP not sure if available for XSharp ?

///
/// ShellMenu
///
PARTIAL CLASS ShellMenu INHERIT Menu

CONSTRUCTOR( oOwner )

LOCAL oTB AS Toolbar

SELF:PreInit()
SUPER( ResourceID { "ShellMenu" , _GetInst( ) } )
// more menu code....
oTB := Toolbar{}
oTB:ButtonStyle := TB_ICONONLY
oTB:Flat := TRUE
oTB:EnableBands(FALSE)
oTB:Bitmap := ShellWindowRibbon{}

SELF:Toolbar := oTB

RETURN


/// <summary>
/// ShellWindowRibbon.
/// </summary>
CLASS ShellWindowRibbon INHERIT Bitmap

CONSTRUCTOR(kLoadoption, iWidth, iHeight)
SUPER(ResourceID{"ShellWindowRibbon", _GetInst()},kLoadoption, iWidth, iHeight)
RETURN SELF

END CLASS

/// Resource
ShellWindowRibbon Bitmap ResourcesSHELLWINDOWRIBBON.BMP

Create a toolbar and and attach to a shell window

Posted: Sat Jan 23, 2021 3:24 pm
by Chris
Hi Neale!

I don't see in the code where/if you are adding buttons to the toolbar, are you doing that? If not, please have a look in the original generated code in the Mdi sample for the menus, it looks like

Code: Select all

	oTB:AppendItem(IDT_CLOSE,IDM_StandardShellMenu_File_Close_ID)
	oTB:AddTipText(IDT_CLOSE,IDM_StandardShellMenu_File_Close_ID,"Close File")

	oTB:AppendItem(IDT_SEPARATOR)

	oTB:AppendItem(IDT_CUT,IDM_StandardShellMenu_Edit_Cut_ID)
	oTB:AddTipText(IDT_CUT,IDM_StandardShellMenu_Edit_Cut_ID,"Cut")
etc.

Regarding SEUIXP, it certainly can be ported to X#, I think I remember someone already did that in the past? If that's true, please step in... Otherwise, please try porting it as a normal library, do you get many errors when trying to compile it in X#?

Create a toolbar and and attach to a shell window

Posted: Sat Jan 23, 2021 3:51 pm
by wriedmann
Hi Neale, hi Chris,
SEUIXP was ported to Vulcan, and starting from this version I was able to move it also to X#.
Please contact Sven Ebert for the X# upgrade of the library.
Porting that library from the VO version may be a bit to difficult as it makes heavy use of the Windows API.
Wolfgang

Create a toolbar and and attach to a shell window

Posted: Sat Jan 23, 2021 5:30 pm
by Neale
Hello Wolfgang
Do you have Sven Ebert E mail or new website ? as www.ebertonline.de isn't working ?

Neale

Create a toolbar and and attach to a shell window

Posted: Sat Jan 23, 2021 5:35 pm
by wriedmann
Hi Neale,
please try ingenieurbuero at ebertonline dot de
The website has been deactivated, but the email works.
Wolfgang

Create a toolbar and and attach to a shell window

Posted: Mon Jan 25, 2021 6:16 pm
by Neale
Thank you for that.
Have E mailed and waiting for reply.

Neale

Create a toolbar and and attach to a shell window

Posted: Mon Jan 25, 2021 6:35 pm
by Neale
AppendItem works fine for the IDT_Close etc., but I cant seem to create a bitmap resource from my custom toolbar bitmap as
in the code below ?

/// <summary>
/// ShellWindowRibbon.
/// </summary>
CLASS ShellWindowRibbon INHERIT Bitmap

CONSTRUCTOR(kLoadoption, iWidth, iHeight)
SUPER(ResourceID{"ShellWindowRibbon", _GetInst()},kLoadoption, iWidth, iHeight)
RETURN SELF

END CLASS

/// Resource
ShellWindowRibbon Bitmap ResourcesSHELLWINDOWRIBBON.BMP

Create a toolbar and and attach to a shell window

Posted: Mon Jan 25, 2021 10:27 pm
by Chris
Hi Neale,

Can you please zip and post the solution, so we can have a look?

Create a toolbar and and attach to a shell window

Posted: Tue Jan 26, 2021 9:25 pm
by Neale
Hello Chris

Solution attached.

Create a toolbar and and attach to a shell window

Posted: Wed Jan 27, 2021 12:41 am
by Chris
Hi Neale,

Thanks for the file! The first problem is that the compiler thinks that by "Bitmap", you are referring to System.Drawing.Bitmap, a class defined in the system classes. In order to fix this, remove the command "USING System.Drawing" from the beginning of the prg and/or remove the entry "System.Drawing" from the project References.

Next problem is that the file ShellWindowRibbon.rc is saved in unicode format, and unfortunately the windows resource compiler does not like that. To fix this, open the file, select File->Save As, then click on the arrow next to the Save button and select "Save with encoding". Now select from the list "Western European 1252" or any other non-unicode codepage you prefer and it will be fine. Or you can change the text format with an external editor if you prefer.

Now the bitmap will be loaded from the resource. In order to assign one of the bitmaps to the toolbar buttons, you will need to use an appropriate index for oTB:AppendItem(), for example

oTB:AppendItem(1, IDM_ShellMenu_Help_About_ID)

Hope this helps!