Hi
I'm having some difficulty with toolbars in X#2.8. In VO and X# 2.7 I was able to manually create a toolbar and assign it to the window. With this approach I could define a custom toolbar without the need for a visible menu meaning if I had a window where I just required a few toolbar buttons I could produce a visually cleaner looking UI.
The approach worked as follows
1) Create a menu and assign it to the window oMenu in the window Postinit. This allowed me to access the menu defined method calls.
SELF:oMenu := CustomerEditMenu
2) Manually create a toolbar using the constants from the menu to attach to the desired methods
oTB := Toolbar{}
oTB:ButtonStyle := TB_TEXTANDICON
//oTB:Bitmap := HDStandardRibbon{}
oTB:ButtonSize := Dimension{32, 32}
oTB:Flat := TRUE
oTB:EnableBands(FALSE)
oTB:SetImageList(HDStandardRibbon24Normal{},#IMAGELIST)
oTB:SetImageList(HDStandardRibbon24Disabled{},#DISABLEDIMAGELIST)
oTB:AppendItem(01, IDM_CustomerEditMenu_Close_ID , , , "Close")
oTB:AddTipText(01, IDM_CustomerEditMenu_Close_ID , "Save changes and close")
oTB:AppendItem(02, IDM_CustomerEditMenu_Save_ID , , , "Save")
oTB:AddTipText(02, IDM_CustomerEditMenu_Save_ID , "Save changes and continue")
3) Assign this to the window
SELF:ToolBar := oTB
This approach works in VO and in X# 2.7 but not now in X# 2.8. It appears that I cannot assign an instance of a toolbar to the SELF:Toolbar of the DataWindow in question. In fact while in debug in Visual Studio 2019 a watch variable on SELF:Toolbar returns
error CS1061: 'CustEditWindow' does not contain a definition for 'Toolbar' and no accessible extension method 'Toolbar' accepting a first argument of type 'CustEditWindow' could be found (are you missing a using directive or an assembly reference?)
If I try to simply initialise the toolbar as below
SELF:Toolbar := Toolbar{}
It's value stays at NIL
Has something changed? Can the toolbar now only be created/assigned through the menu?
I have quite a few windows in this app and a larger one I'm hoping to migrate from VO later this year that use the same approach.
Thanks
Karl
Toolbar Issues in X#2.8
Toolbar Issues in X#2.8
Karl,
As far as I know we did not change anything in this area.
Maybe the problem lies in the fact that the code of the toolbar class does not call the super constructor:
This is a highly unusual thing and may have side effects.
Robert
As far as I know we did not change anything in this area.
Maybe the problem lies in the fact that the code of the toolbar class does not call the super constructor:
Code: Select all
IF IsNil(oOwner)
// ToolBar is being created without a parent; don't call super:Init()
RegisterAxit(SELF) // TODO: Conditional call to RegisterAxit() should be replaced with call to GC.SuppressFinalize() for opposite condition
oOrigin := Point{oPoint:X, oPoint:Y}
oSize := Dimension{oDimension:Width, oDimension:Height}
SELF:__ClassName := TOOLBARCLASSNAME
ELSE
// ToolBar is being created with a parent, calling super:Init() is safe
SUPER(oOwner, xID, oPoint, oDimension, TOOLBARCLASSNAME)
ENDIF
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
Toolbar Issues in X#2.8
Hi Karl,
Is the error message indeed "CS1061"? This name suggests that the error is coming from c#, not X#. Maybe you have a c# test app in the solution and the error comes when trying to build this test app and not the X# app?
Is the error message indeed "CS1061"? This name suggests that the error is coming from c#, not X#. Maybe you have a c# test app in the solution and the error comes when trying to build this test app and not the X# app?
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Toolbar Issues in X#2.8
Hi Robert
Supplying the owner doesn't seem to make any difference. I supplied the owner and then reduced the toolbar items to a single button and the result was the same.
If i reduce everything to the most simple form
SELF:ToolBar := Toolbar{SELF}
the window toolbar still has a value of NIL, I've attached a screen shot of the watch area of Visual Studio. It just doesn't seem like I can manually initialise SELF:Toolbar for the window
Thanks
Karl
Supplying the owner doesn't seem to make any difference. I supplied the owner and then reduced the toolbar items to a single button and the result was the same.
If i reduce everything to the most simple form
SELF:ToolBar := Toolbar{SELF}
the window toolbar still has a value of NIL, I've attached a screen shot of the watch area of Visual Studio. It just doesn't seem like I can manually initialise SELF:Toolbar for the window
Thanks
Karl
Toolbar Issues in X#2.8
Morning Chris
The 'CS1061' isn't received at compile time, it's the result I see in the Visual Studio watch list if I set a watch item for SELF:Toolbar.
What is strange is that if I set a watch on SELF and then expand the result this does show a result, however it never changes from NIL whatever I do.
The attached screen grab may illustrate what I mean more clearly. I don't know if any of this is relevant to the real issue of not being able to set the toolbar but it looked odd so I mentioned it.
Thanks
Karl
The 'CS1061' isn't received at compile time, it's the result I see in the Visual Studio watch list if I set a watch item for SELF:Toolbar.
What is strange is that if I set a watch on SELF and then expand the result this does show a result, however it never changes from NIL whatever I do.
The attached screen grab may illustrate what I mean more clearly. I don't know if any of this is relevant to the real issue of not being able to set the toolbar but it looked odd so I mentioned it.
Thanks
Karl
Toolbar Issues in X#2.8
Hi Karl,
Ah, OK, thanks for explaining, I understand now! Can you please create and post a sample reproducing the problem, so we can look closely into this and fix it? I think the best way is to start with the standard MDI sample in VO, add the same code that you have in your real app regarding toolbars etc, then port it to X# and see if the problem still happens in 2.8. If it does, please just post the VO .aef file, it will be enough for us to make the same tests.
Ah, OK, thanks for explaining, I understand now! Can you please create and post a sample reproducing the problem, so we can look closely into this and fix it? I think the best way is to start with the standard MDI sample in VO, add the same code that you have in your real app regarding toolbars etc, then port it to X# and see if the problem still happens in 2.8. If it does, please just post the VO .aef file, it will be enough for us to make the same tests.
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Toolbar Issues in X#2.8
Karl,
The error message for the Watch window happens because the name of the property is ToolBar (with a capital B ) and we are using the C# Watch window support here. That is also why you see the CS1061 error number here.
Robert
The error message for the Watch window happens because the name of the property is ToolBar (with a capital B ) and we are using the C# Watch window support here. That is also why you see the CS1061 error number here.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
Toolbar Issues in X#2.8
Hi Robert
Doh! Of course it is, now you've pointed that out it's obvious
Thanks
Karl
Doh! Of course it is, now you've pointed that out it's obvious
Thanks
Karl
Toolbar Issues in X#2.8
Well it looks like it's something solely in one window.
I produced a sample in VO but yes you've guessed it when I imported it to X# 2.8 it worked as intended.
I then went on to add the same test menu/window that I'd created for the sample direct into the app code and again it worked as intended.
Due to a previous issue I was dealing with I'd disabled a large portion of my code, well I went back to that so that I could look at other windows which use the same mechanism. Again the approach works as intended.
This leaves me with it being something specific to just that one window. At the moment I still have no idea what but I'll attempt re-creating the window from scratch and see what that does.
Thanks for the assistance, it's nudged me in the right direction and hopefully I'll have some sort of fix before too long.
Karl
I produced a sample in VO but yes you've guessed it when I imported it to X# 2.8 it worked as intended.
I then went on to add the same test menu/window that I'd created for the sample direct into the app code and again it worked as intended.
Due to a previous issue I was dealing with I'd disabled a large portion of my code, well I went back to that so that I could look at other windows which use the same mechanism. Again the approach works as intended.
This leaves me with it being something specific to just that one window. At the moment I still have no idea what but I'll attempt re-creating the window from scratch and see what that does.
Thanks for the assistance, it's nudged me in the right direction and hopefully I'll have some sort of fix before too long.
Karl