Author Topic: confusion  (Read 1494 times)

0 Members and 1 Guest are viewing this topic.

jcfuller

  • Guest
confusion
« 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
Code: [Select]
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:
Code: [Select]
  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
Code: [Select]
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

Arnold

  • Guest
Re: confusion
« Reply #1 on: February 26, 2018, 06:59:27 AM »
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

jcfuller

  • Guest
Re: confusion
« Reply #2 on: February 26, 2018, 08:14:21 AM »
Thanks Roland.
 I was missing the @
@InfoPtr = lParam
Now it is available from all the case situations.

James

Charles Pegge

  • Guest
Re: confusion
« Reply #3 on: February 26, 2018, 09:06:39 AM »
You can use @ or &. They both have the same meaning.

You can also create your own definitions, if it helps to clarify:

Code: [Select]
def varptr @ %1
def codeptr @ %1
def AddressOf @ %1
« Last Edit: February 26, 2018, 09:27:44 AM by Charles Pegge »

Arnold

  • Guest
Re: confusion
« Reply #4 on: February 27, 2018, 02:20:34 AM »
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.