Posted: Mon Jul 09, 2007 2:12 pm
Small question : how are managed protoypes with tailbite ?
http://www.purebasic.com
https://www.purebasic.fr/english/
ABBKlaus wrote:@Maxus,
Please supply a snippet for what is not working![]()
This is from the TailBite manual and should work :You can make your function accept variable arguments. To do so, you must include two or more ProcedureDLL's with the same name and an index number:
Code: Select all
ProcedureDLL.l MsgTest3(Line.s,Title.s,Icon.l)
MessageRequester(Title,Line,Icon)
EndProcedure
ProcedureDLL.l MsgTest2(Line.s,Title.s)
MsgTest3(Line,Title,#MB_ICONINFORMATION)
EndProcedure
ProcedureDLL.l MsgTest(Line.s)
MsgTest3(Line,"Hello",#MB_ICONINFORMATION)
EndProcedure
Code: Select all
ProcedureDLL DEbuger_Init()
Global ST=1
EndProcedure
ProcedureDLL.l MSGBOX(String.s, FColor.l)
If Not IsWindow(0)
ExamineDesktops()
LoadFont(0,"Sans Serif",8,#PB_Font_Bold)
OpenWindow(0,0,0,DesktopWidth(0),400,"Debug"):CreateGadgetList(WindowID(0))
ListIconGadget(0,5,5,DesktopWidth(0)-10,390,"Message",DesktopWidth(0)-31,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
SetGadgetFont(0,FontID(0))
EndIf
AddGadgetItem(0,-1,String$)
If Fcolor=-1:Fcolor=0:EndIf
SetGadgetItemColor(0,CountGadgetItems(0)-1,#PB_Gadget_FrontColor,FColor)
If ST=0
SetGadgetItemColor(0,CountGadgetItems(0)-1,#PB_Gadget_BackColor,$EEEEEE):ST=1
Else
SetGadgetItemColor(0,CountGadgetItems(0)-1,#PB_Gadget_BackColor,$FFFFFF):ST=0
EndIf
EndProcedure
ProcedureDLL.l MSGBOX2(String$)
MSGBOX(String$,-1)
EndProcedure
ProcedureDLL DECL()
ClearGadgetItemList(0)
EndProcedure
ProcedureDLL DEbuger_End()
If IsWindow(0)
Repeat
Until WindowEvent()=#PB_Event_CloseWindow
EndIf
EndProcedure
Code: Select all
Declare.l MsgTest3(Line.s,Title.s,Icon.l)
ProcedureDLL.l MsgTest(Line.s)
MsgTest3(Line,"Hello",#MB_ICONINFORMATION)
EndProcedure
ProcedureDLL.l MsgTest2(Line.s,Title.s)
MsgTest3(Line,Title,#MB_ICONINFORMATION)
EndProcedure
ProcedureDLL.l MsgTest3(Line.s,Title.s,Icon.l)
MessageRequester(Title,Line,Icon)
EndProcedure
Code: Select all
ProcedureDLL DEbuger_Init()
Global ST=1
Global Window_MSGBox
Global Font_SansSerif
Global ListIcon_MSGBox
EndProcedure
Procedure.l ipf_MSGBOX(String.s, FColor.l=-1)
If Not IsWindow(Window_MSGBox)
ExamineDesktops()
Font_SansSerif=LoadFont(#PB_Any,"Sans Serif",8,#PB_Font_Bold)
Window_MSGBox=OpenWindow(#PB_Any,0,0,DesktopWidth(0),400,"Debug"):CreateGadgetList(WindowID(Window_MSGBox))
ListIcon_MSGBox=ListIconGadget(#PB_Any,5,5,DesktopWidth(0)-10,390,"Message",DesktopWidth(0)-31,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
SetGadgetFont(ListIcon_MSGBox,FontID(Font_SansSerif))
EndIf
AddGadgetItem(ListIcon_MSGBox,-1,String)
If Fcolor=-1:Fcolor=0:EndIf
SetGadgetItemColor(ListIcon_MSGBox,CountGadgetItems(ListIcon_MSGBox)-1,#PB_Gadget_FrontColor,FColor)
If ST=0
SetGadgetItemColor(ListIcon_MSGBox,CountGadgetItems(ListIcon_MSGBox)-1,#PB_Gadget_BackColor,$EEEEEE):ST=1
Else
SetGadgetItemColor(ListIcon_MSGBox,CountGadgetItems(ListIcon_MSGBox)-1,#PB_Gadget_BackColor,$FFFFFF):ST=0
EndIf
EndProcedure
ProcedureDLL.l MSGBOX(String.s)
ipf_MSGBOX(String)
EndProcedure
ProcedureDLL.l MSGBOX2(String.s,FColor.l)
ipf_MSGBOX(String,FColor)
EndProcedure
ProcedureDLL DECL()
ClearGadgetItemList(ListIcon_MSGBox)
EndProcedure
ProcedureDLL DEbuger_End()
If IsWindow(Window_MSGBox)
Repeat
Until WindowEvent()=#PB_Event_CloseWindow
EndIf
EndProcedure
Code: Select all
ProcedureDLL SomeFunction(Param1)
EndProcedure
ProcedureDLL SomeFunction2(Param1,Param2)
EndProcedure
ProcedureDLL SomeFunction3(Param1,Param2,Param3)
EndProcedure
Excuse me but if I declare a prototype like this, MsgBox doesn't become a function...ABBKlaus wrote:same restrictions as ProcedureDLL, no optional parameters.
Code: Select all
ProcedureDLL Lib_Init()
OpenLibrary(0, "User32.dll")
Endprocedure
Prototype.l ProtoMessageBox(Fenetre.l, Corps$, Titre$, Options.l = 0)
Global MsgBox.ProtoMessageBox = GetFunction(0, "MessageBoxA")
Code: Select all
Prototype.l ProtoMessageBox(Fenetre.l, Corps$, Titre$, Options.l)
ProcedureDLL Lib_Init()
OpenLibrary(0, "User32.dll")
Global MsgBox_.ProtoMessageBox = GetFunction(0, "MessageBoxA")
EndProcedure
Procedure MsgBox(Fenetre.l, Corps$, Titre$)
ProcedureReturn MsgBox_(tre.l, Corps$, Titre$, 0)
EndProcedure
Procedure MsgBox2(Fenetre.l, Corps$, Titre$, Options.l)
ProcedureReturn MsgBox_(tre.l, Corps$, Titre$, Options)
EndProcedure
Code: Select all
Prototype.l ProtoMessageBox(Fenetre.l, Corps$, Titre$, Options.l=0)
ProcedureDLL Lib_Init()
Global User32
Global MsgBox_.ProtoMessageBox
User32=OpenLibrary(#PB_Any, "User32.dll")
If User32
MsgBox_ = GetFunction(User32, "MessageBoxA")
EndIf
EndProcedure
ProcedureDLL Lib_End()
If IsLibrary(User32)
CloseLibrary(User32)
EndIf
EndProcedure
ProcedureDLL MsgBox(Fenetre.l, Corps$, Titre$)
If MsgBox_
ProcedureReturn MsgBox_(tre.l, Corps$, Titre$)
EndIf
EndProcedure
ProcedureDLL MsgBox2(Fenetre.l, Corps$, Titre$, Options.l)
If MsgBox_
ProcedureReturn MsgBox_(tre.l, Corps$, Titre$, Options)
EndIf
EndProcedure
Code: Select all
OpenLibrary(0, "User32.dll")
good point ts-softts-soft wrote:And in a lib you should use the dynamic IDs: #PB_Any ! (for all, not only for DLLs)Code: Select all
OpenLibrary(0, "User32.dll")