Oxygen Basic
Programming => Problems & Solutions => Topic started by: jcfuller on February 26, 2018, 04:11:47 AM
-
Charles,
I need some clarification.
I am seeing windows function winmain and windows callback functions without byval in the param list.
What is the best practice method for porototypes or function parameters. Remember I am a verbose person and don't mind a lot of typing if it helps my old brain grasp functionality.
I am also a bit of a encapsulation freak where I shun globals as much as possible.
How do I assign to a static var a pointer passed to a callback function as in this:
I have a type
Type DlgInfoType
int Index
int IsRecModified
int IsFileModified
int StartRec
sys hInst
sys hParent
sys hStatus
char findtext[1024]
int MaxRecs
char dbfile[2048]
End Type
In Winmain:
Dim As DlgInfoType DlgInfo
DlgInfo.hInst = hInst
DlgInfo.dbfile = "CardFile50.bin"
hDlg = CreateDialogParam(hInst,IDD_DLG1,0,@DlgProc,@DlgInfo)
And in my callback I want to assign InfoPtr the address of DlgInfo from winmain
Function DlgProc(byval hDlg As sys,byval uMsg As uint,byval wParam As sys,byval lParam AS sys) As sys callback
static InfoPtr As DlgInfoType*
Select Case uMsg
Case WM_INITDIALOG
InfoPtr = lParam
Also one Folder I must have missed is the examples\Image where it appears all code is for rtl32 but they also fail to compile.
James
-
Hi James,
instinctively I would use:
DlgInfoType InfoPtr at lParam
or
DlgInfoType *InfoPtr
@InfoPtr = lParam
but I do not know what the effect of 'static' will be.
Charles must have applied another change with the newest release of Oxygen. Examples\Image\ImageWin1.o2bas and ImageWin2.o2bas worked with the Final Alpha release. With the latest release I now must use:
typedef sys pvoid
in order to run the programs.
Roland
-
Thanks Roland.
I was missing the @
@InfoPtr = lParam
Now it is available from all the case situations.
James
-
You can use @ or &. They both have the same meaning.
You can also create your own definitions, if it helps to clarify:
def varptr @ %1
def codeptr @ %1
def AddressOf @ %1
-
These definitions are excellent. I must confess when I started to learn Oxygenbasic it took some time until I understood that I only need to use @ or & to achieve the result of these functions / operator.