I am writing a Settings Class, which can store various settings to a file.
I know, this has been done before. And there are many different ways of doing it.
The class stores the settings in a dictionary (the new framework style). It saves the data on disk in the JSON format.
The different value types I can read and write are Integer, Text, String (the classic one), Folderitem (classic & new framework), Color, Boolean and Date. More are coming soon.
Two value types I am working on now are WindowPos and WindowSize. The method I am calling is:
Sub WindowPosSet(fieldname as text, WindowRef as window)
Dim Top as Integer = WindowRef.top
Dim Left as Integer = WindowRef.left
dim txt as Text = Left.ToTextr + "," + Top.ToText
// code to store the value in the dictionary
End Sub
My problem is that when I call this method, an error is raised.
Parameter "WindowRef" expects type Window, but this is class Window1.Window1
I call this method when Window1 is moved. I refer to this window with Self
In another method I use the same parameters, and use the reference WindowRef to set the Left and Top values.
Same error there.
The problem is that when I use this method, I use self. And the class I am passing it on to is expecting a Window type. Now it somehow sees it as some kind of subclass, I think. But shouldn’t it be seen as a window?
[quote=210942:@Edwin van den Akker]Yes, this is all the code.
The problem is that when I use this method, I use self. And the class I am passing it on to is expecting a Window type. Now it somehow sees it as some kind of subclass, I think. But shouldn’t it be seen as a window?[/quote]
If you call your method the same way I do, I see no reason whatsoever for the error you report.
I told you my RubberViews class does that intensively with no error of any kind, as well a test project I created from your posted code, and the problem does not exist. There must be something else in your project.
In full despair, you may try to cast your window, but I frankly do not see why you should have to :