Page 2 of 4

Posted: Fri May 07, 2004 1:38 am
by localmotion34
would an example be like:

Code: Select all


ProcedureDLL properties(MDIGadget)
  *MDI/Width=GadgetWidth(MDIGadget)
  *MDI/Height=GadgetHeight(MDIGadget)
  *MDI/x=GadgetX(MDIGadget)
  *MDI/y=GadgetY(MDIGadget)
EndProcedure


Posted: Fri May 07, 2004 1:41 am
by Dare2
Thanks, El_Choni.

Posted: Fri May 07, 2004 4:42 am
by localmotion34
code in library:

Code: Select all

Structure mdiproperties 
  Width.l 
  Height.l 
  x.l
  y.l
EndStructure 

ProcedureDLL defineproperties(MDIGadget,*pointer.mdiproperties)
  *pointer\Width=GadgetWidth(MDIGadget)
  *pointer\Height=GadgetHeight(MDIGadget)
  *pointer\x=GadgetX(MDIGadget)
  *pointer\y=GadgetY(MDIGadget)
EndProcedure 
code in EXE

Code: Select all

If CreateGadgetList(WindowID())
  MDIGadget(#GADGET_MDI, 110, 30, 690, 560, 0, 0 )
  CloseGadgetList()
EndIf


defineproperties(#GADGET_MDI,@????????)

;in event loop to get properties of MDI

         OpenConsole()
          PrintN(Str(MDIprop\Width))
          Input()
          CloseConsole()

this wont work. any ideas of modifications to allow me to get to the structure that is defined in the library. i need to be able to access the original properties of the MDI in order to dock/undock the dockwindow and have the MDI resize as needed +/- the dockwindow width.

Posted: Fri May 07, 2004 5:19 am
by deadmoap
THIS is why pointers were invented.

Code: Select all

ProcedureDLL MyFunc(*var1.LONG,*var2.LONG,*var3.LONG)
   *var1\l=1337
   *var2\l=7777
   *var3\l=666

   ProcedureReturn(1)
EndProcedure

Posted: Fri May 07, 2004 10:32 am
by blueznl
deadmoap, i prefer localmotion's approach, to be honest :-)

Posted: Fri May 07, 2004 2:41 pm
by localmotion34
huh?--i have question marks in my code because i dont know what to actually put there. can someone look at my code and show me how to do this. ? the task is to be able to call the defineproperties procedure, and have it return a structure with the MDI gadget width height ect.

Posted: Fri May 07, 2004 2:50 pm
by El_Choni
AFAIK, if the gadget is created in the exe, you can't use the gadget commands with it from the lib (maybe with #PB_Any?).

I would pass the MDIGadget window handle and use the API with it (GetClientRect_() for dimensions, GetWindowRect_()-->ScreenToClient_()-->ClientToScreen_() for position) to fill the structure.

Regards,

Posted: Fri May 07, 2004 5:05 pm
by localmotion34
ok, thanks for the advice, but without an example i have no idea where to start. i am not even sure about how correct the code i posted is in regards to the pointers and all. the structure created in the LIB is not recognized in the EXE at all.

Posted: Sun Jan 29, 2006 5:59 pm
by Intrigued
deadmoap wrote:THIS is why pointers were invented.

Code: Select all

ProcedureDLL MyFunc(*var1.LONG,*var2.LONG,*var3.LONG)
   *var1\l=1337
   *var2\l=7777
   *var3\l=666

   ProcedureReturn(1)
EndProcedure
Feeling foolish I will step out and ask, does this also work (gulp) for strings? Better yet, how can I get such to return a/some string(s)?

TIA

(maybe I should just go test :wink:)

Posted: Sun Jan 29, 2006 6:14 pm
by Intrigued
So far, from my lack-of-experience-testing... that this post will be the only one that can do alphanumeric:

viewtopic.php?p=56059#56059

Thanks for that offering :!:

Posted: Sun Jan 29, 2006 6:36 pm
by blueznl
intrigued, how do you mean? i mean, strings are just blocks of memory, so if a procedure / dll / function has to return a string, you just have to point it to a block of memory where it can dump it's string... i think i must be missing the point...

Posted: Sun Jan 29, 2006 6:58 pm
by Intrigued
blueznl wrote:intrigued, how do you mean? i mean, strings are just blocks of memory, so if a procedure / dll / function has to return a string, you just have to point it to a block of memory where it can dump it's string... i think i must be missing the point...
Nope I'm missing the point. D'oh! :cry:

What I need is for a ProcedureDLL function to return alphanumeric. Going off from what you said can you nudge my tricycle down the sidewalk a bit... via way of an example. I can't seem to get a string version of the LONG version shared early to work.

ProcedureDLL MyFunc(*var1.LONG,*var2.LONG,*var3.STRING)
*var1\l=1337
*var2\l=7777
*var3\s="666"

Debug *var3


ProcedureReturn(1)
EndProcedure


Try to not laugh to hard at my attempt! :wink:

Posted: Sun Jan 29, 2006 7:47 pm
by josku_x
Still praying? :D

Code: Select all

Structure MEMO
 Text.s
 Length.l
 MemoID.l
EndStructure

Procedure CreateMemo(*lpMemo.MEMO, Text$)
Global UniqueID
*lpMemo\Text = Text$
*lpMemo\Length = Len(Text$)
*lpMemo\MemoID = UniqueID+1
UniqueID+1
ProcedureReturn *lpMemo\MemoID
EndProcedure

CreateMemo(MyMemo.MEMO, "Little-Testing..")
CreateMemo(MyMemo2.MEMO, "2nd MEMO")
CreateMemo(MyMemo3.MEMO, "boring....")

Debug "CreateMemo returned text:"
Debug "MyMemo\Text: "+MyMemo\Text
Debug "MyMemo2\Text: "+MyMemo2\Text
Debug "MyMemo3\Text: "+MyMemo3\Text
Debug "-----"
Debug "CreateMemo returned numbers:"
Debug "MyMemo\Length: "+Str(MyMemo\Length)
Debug "MyMemo2\Length: "+Str(MyMemo2\Length)
Debug "MyMemo3\Length: "+Str(MyMemo3\Length)
Debug "-----"
Debug "MyMemo\MemoID: "+Str(MyMemo\MemoID)
Debug "MyMemo2\MemoID: "+Str(MyMemo2\MemoID)
Debug "MyMemo3\MemoID: "+Str(MyMemo3\MemoID)
That was a quick thing, but it should do what you want, return alphanumeric strings.

Posted: Sun Jan 29, 2006 8:00 pm
by Thorsten1867
I use a simple solution:

Code: Select all

Procedure.s test()
  child$ = "Susi"
  age = 9
  ProcedureReturn child$ + "|" + Str(age)
EndProcedure

result$ = test()

child$ = StringField(result$, 1, "|")
Debug child$

age = Val(StringField(result$, 2, "|"))
Debug age

Posted: Sun Jan 29, 2006 8:13 pm
by josku_x
That's also a good solution, but not for big data, as processing it would be slow.