How to solve class related code issues possible in VO but not in .Net?

This forum is meant for questions and discussions about the X# language and tools
HeikoP
Posts: 48
Joined: Mon May 30, 2016 4:19 pm
Location: Germany

How to solve class related code issues possible in VO but not in .Net?

Post by HeikoP »

Robert, Chris,

even if Chris way to solve it sounds easier and faster to me, Roberts way with subclassing and defining the type of class of the FormDialog in the subclass of the Datawindow seems more familiar and flexible.

But this is just my opinion. Both ways would fit my needs for now.

Heiko
User avatar
Chris
Posts: 4922
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

How to solve class related code issues possible in VO but not in .Net?

Post by Chris »

Maybe a hybrid solution can be used, to introduce a global that holds the default value for symFormDialog. This way this trick can be used even in existing code that does not use common window subclasses and without needing any additional code, other than defining the class and assigning this global to the name of that class.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
wriedmann
Posts: 3756
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

How to solve class related code issues possible in VO but not in .Net?

Post by wriedmann »

Hello Heiko,
the solution Robert has proposed was available also in later versions of VO, so you can apply that change also to your VO code. Unfortunately I cannot find any reference to it in the various 2.8 whatsnew documents, so maybe it was added somewhere in the 2.7 versions.
I suspect that it was Robert that has added it.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

How to solve class related code issues possible in VO but not in .Net?

Post by ic2 »

Hello Robert, Chris,

Sounds good.

I also have a library called AFHook27 included which uses this Dispatch. When I define a METHOD BeforeHook in a datawindow I can use code like this:

LOCAL lDone AS LOGIC
IF lCtrlPressed
IF wParam = 65
SELF:oDCLV1:SelectAllItems()
lDone := TRUE
ENDIF
ENDIF
RETURN lDone

This code sample ensures that Ctrl A selects all items n a ListView and I have other appliances of course, all to do with shortcut keys in controls, e.g. also there is an option to scroll through tabs of a tabwindow using a hotkey.

Could I do that easier in X#, without this library?

Dick
HeikoP
Posts: 48
Joined: Mon May 30, 2016 4:19 pm
Location: Germany

How to solve class related code issues possible in VO but not in .Net?

Post by HeikoP »

Wolfgang, Robert,

great! I didn´t knew that, that was easy to change.

Thank you!

Heiko
User avatar
Chris
Posts: 4922
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

How to solve class related code issues possible in VO but not in .Net?

Post by Chris »

Hi Dick,
ic2 wrote:Hello Robert, Chris,

Sounds good.

I also have a library called AFHook27 included which uses this Dispatch. When I define a METHOD BeforeHook in a datawindow I can use code like this:

LOCAL lDone AS LOGIC
IF lCtrlPressed
IF wParam = 65
SELF:oDCLV1:SelectAllItems()
lDone := TRUE
ENDIF
ENDIF
RETURN lDone

This code sample ensures that Ctrl A selects all items n a ListView and I have other appliances of course, all to do with shortcut keys in controls, e.g. also there is an option to scroll through tabs of a tabwindow using a hotkey.

Could I do that easier in X#, without this library?

Dick
You can definitely do it by subclassing the control. Not sure how this library works to tell if there's an easier way to do it, can you post the complete source code?
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

How to solve class related code issues possible in VO but not in .Net?

Post by ic2 »

Hello Chris,

The library AEFHook27 is written by Lutz.Eckert, who also wrote WildSeek and contains 55 entities so I don't think you want to see all code ;) .
I just wondered if assigning shortcut keys to control in X# could be achieved easier, without this DLL.

If not, I will, in later attempts, try to convert this library and see if it works as it does in VO. If not, I will ask later. What I will do is mail you the DLL, just in case you want to check it out.

Dick
User avatar
Chris
Posts: 4922
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

How to solve class related code issues possible in VO but not in .Net?

Post by Chris »

Hi Dick,

In order to see how this library achieves this and tell if there's an easier way to do it (apart from simply subclassing the control), we need to see at least all the relevant code. So yes, please send the library .aef (not the dll) to have a look. Although I suppose this is a free library and the author wouldn't mind if you just posted it here, for other peoples benefit as well. Or I might be wrong about this :)

Edit: Ah OK, I see you have already sent the aef!
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

How to solve class related code issues possible in VO but not in .Net?

Post by Karl-Heinz »

Hi Dick,

I don't remember the AFHook27, but are there hits if you search the sources for those words:

AfterDispatch
BeforeDispatch
RegisterHotKey
SetWindowsHook

As the name 'Hook' suggests, i´m pretty sure that at least SetWindowsHook or SetWindowsHookEx are found ;-)


regards
Karl-Heinz
ic2
Posts: 1858
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

How to solve class related code issues possible in VO but not in .Net?

Post by ic2 »

Hello Karl-Heinz,

Chris had a look at the library and although it is capable of quite some functions, in some cases it may not even be needed. For example, I subclassed the ListView and assigning a (select all) shortcut key in that case can also be done directly in the Dispatch of the window with that ListView on it.

My suggestion was that should I still need this library and it wouldn't work in some point in the future (that is: when I continue to convert VO->X# and probably with a later X# version) I can better report then what doesn't work than that Chris spends time on checking if the planned modifications would or would not work with a library that may not be used widely and/or can be omitted with a bit of work.

Dick
Post Reply