Miscellaneous questions about converting VO code to X#
Re: Miscellaneous questions about converting VO code to X#
Hi Kees,
OK, great, glad it works now!
OK, great, glad it works now!
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Re: Miscellaneous questions about converting VO code to X#
Hi all,
This may be a silly question, but I can't find any way to get a single control from a dialogwindow in X#. I know of the method GetAllChildren(), but I just want a single child, not all of them. I could supply a ControlID, a HyperLabel or the Name of the control. Something like oControl := oWindow:GetControl(Name). Traversing the array you get from GetAllChildren() every time and until you find the right one is too slow and a lot of code. Does anyone have a solution for this?
Kees.
This may be a silly question, but I can't find any way to get a single control from a dialogwindow in X#. I know of the method GetAllChildren(), but I just want a single child, not all of them. I could supply a ControlID, a HyperLabel or the Name of the control. Something like oControl := oWindow:GetControl(Name). Traversing the array you get from GetAllChildren() every time and until you find the right one is too slow and a lot of code. Does anyone have a solution for this?
Kees.
Re: Miscellaneous questions about converting VO code to X#
Hi Kees,
I would do a subclass for this window, add a protected Dictionary<string,Control>, and use code like this:
Wolfgang
I would do a subclass for this window, add a protected Dictionary<string,Control>, and use code like this:
Code: Select all
method GetControl( cName as string ) as control
local oReturn as Control
if _oControls == null .or. _oControls:Count == 0
_oControls := Dictionary<string,Control>{}
local aControls as array
local nLen as dword
local nI as dword
aControls := self:GetControls()
nLen := ALen( aControls )
for nI := 1 upto nLen
_oControls:Add( aControls[nI]:Name:ToLower, aControls[nI] )
next
endif
if _oControls:ContainsKey( cName:ToLower() )
oReturn := _oControls[cName:ToLower()]
else
oReturn := null
endif
return oReturn
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Re: Miscellaneous questions about converting VO code to X#
Wolfgang,
Thank you for this workaround, it looks very nice.
Kees.
Thank you for this workaround, it looks very nice.
Kees.
Re: Miscellaneous questions about converting VO code to X#
Hi All,
The function GetThemeAppProperties() from VOGUIClasses "Retrieves the property flags that control how visual styles are applied in the current application", see https://learn.microsoft.com/en-us/windo ... properties.
This function returns 7 in VO. It also returns 7 in my X# VO MDI test application. However, in my X# Winforms application it returns 0.
Also, the function SetThemeAppProperties(STAP_ALLOW_CONTROLS) does not make GetThemeAppProperties() return 2 in X# Winforms as it does in VO and X# VO MDI.
I noticed that in the Winforms application are these (generated) lines in FUNCTION Start():
But removing one of these or both or setting the argument to TRUE does not make any difference.
Question 1: How can I make GetThemeAppProperties() and SetThemeAppProperties() work in a X# Winforms application?
Question 2: Almost all code and windows in the X# Winforms application are actually VO Forms. Is there a way to remove the Winforms code and effectively change the application to a X# VO MDI application?
Kees.
The function GetThemeAppProperties() from VOGUIClasses "Retrieves the property flags that control how visual styles are applied in the current application", see https://learn.microsoft.com/en-us/windo ... properties.
This function returns 7 in VO. It also returns 7 in my X# VO MDI test application. However, in my X# Winforms application it returns 0.
Also, the function SetThemeAppProperties(STAP_ALLOW_CONTROLS) does not make GetThemeAppProperties() return 2 in X# Winforms as it does in VO and X# VO MDI.
I noticed that in the Winforms application are these (generated) lines in FUNCTION Start():
Code: Select all
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(FALSE)
Question 1: How can I make GetThemeAppProperties() and SetThemeAppProperties() work in a X# Winforms application?
Question 2: Almost all code and windows in the X# Winforms application are actually VO Forms. Is there a way to remove the Winforms code and effectively change the application to a X# VO MDI application?
Kees.
Re: Miscellaneous questions about converting VO code to X#
Another small question, there are a few places in my code where a DWORD or LONGINT is somehow converted into a structure like in this code (I have left out the irrelevant lines):
On the line with the _CAST I get "Error XS0266 Cannot implicitly convert type 'ptr' to 'VO._winNMHDR*'. An explicit conversion exists (are you missing a cast?)"
I have read the chapter on casting in the X# book on https://docs.xsharp.it/doku.php?id=casting, at the bottom there is a link to a forum thread which does not work anymore. I must confess that I still do not understand how this is supposed to work, how can a number (a DWORD in this case) become a structure? Yet the code above worked in VO. What would be the safest way to make it work in X#?
Kees.
Code: Select all
METHOD Dispatch(oEvt, hDlg)
LOCAL pNMHDR AS _winNMHDR
LOCAL lParam AS DWORD
lParam := oEvt:lParam
pNMHDR := PTR(_CAST, lParam)
RETURN SUPER:Dispatch(oEvt)
I have read the chapter on casting in the X# book on https://docs.xsharp.it/doku.php?id=casting, at the bottom there is a link to a forum thread which does not work anymore. I must confess that I still do not understand how this is supposed to work, how can a number (a DWORD in this case) become a structure? Yet the code above worked in VO. What would be the safest way to make it work in X#?
Kees.
Re: Miscellaneous questions about converting VO code to X#
Hi Kees,
In that particular case the event object (I assume you have left out some code that checks which event is intercepted exactly) contains a pointer to the structure in the lParam numeric variable. Numerics can be converted to a pointer in a 32 bit application, since they both have the same length (4 bytes). The way to do it in X# is
pNMHDR := (_winNMHDR PTR) lParam
where "(_winNMHDR PTR)" is the "explicit conversion" (cast) that the error message mentions.
Sorry we did not get back to you yet about your previous question about themes, will look into it and will get back to you.
In that particular case the event object (I assume you have left out some code that checks which event is intercepted exactly) contains a pointer to the structure in the lParam numeric variable. Numerics can be converted to a pointer in a 32 bit application, since they both have the same length (4 bytes). The way to do it in X# is
pNMHDR := (_winNMHDR PTR) lParam
where "(_winNMHDR PTR)" is the "explicit conversion" (cast) that the error message mentions.
Sorry we did not get back to you yet about your previous question about themes, will look into it and will get back to you.
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
Re: Miscellaneous questions about converting VO code to X#
Kees,
Many Windows API functions pass a pointer in the LPARAM (LONG) or WPARAM (DWORD) fields of an event.
This fits perfectly.
That is also the reason why you cannot simply recompile the VO GUI classes in x64 bit mode, because pointers in 64 bits app occupy not 32 bits but 64 bits.
Robert
A structure in VO (when declared with AS) is a pointer to a memory location. In a 32 bits application, a pointer occupies 32 bits.
Many Windows API functions pass a pointer in the LPARAM (LONG) or WPARAM (DWORD) fields of an event.
This fits perfectly.
That is also the reason why you cannot simply recompile the VO GUI classes in x64 bit mode, because pointers in 64 bits app occupy not 32 bits but 64 bits.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
Re: Miscellaneous questions about converting VO code to X#
Chris and Robert,
Thank you very much for your answers! It works now.
(And yes, I am still interested in a solution for the Themes functions.)
Kees.
Thank you very much for your answers! It works now.
(And yes, I am still interested in a solution for the Themes functions.)
Kees.
Re: Miscellaneous questions about converting VO code to X#
In the VO version of the app I am working on, I encountered a strange expression that is used a few times. It is the left side of this line:
SELF inherits from DataDialog and nAUT is an integer. PKey is an (Exported) array and #AUTNO is just a symbol, other symbols are also used in the same expression.
This line does work in the VO version. The VOXPorter translates it into this:
But that gives the compiler error XS9059 "Cannot convert Array Index from 'symbol' to 'int'".
So I am curious what the VO version exactly means, if it is "valid" code (never seen it before) and how I can achieve the same in X#.
Kees.
Code: Select all
SELF:[PKey, #AUTNO] := nAUT
This line does work in the VO version. The VOXPorter translates it into this:
Code: Select all
SELF:PKey[#AUTNO] := nAUT
So I am curious what the VO version exactly means, if it is "valid" code (never seen it before) and how I can achieve the same in X#.
Kees.