Page 1 of 1

hello everybody,i got trouble again

Posted: Sat Sep 13, 2014 5:04 pm
by lanslotfrog
:oops:
i don't know how to use CallDll command
i wanna use winapi,just like messagebox
i don't know how to write argument
can someone tell me,and write a example?
please.

Re: hello everybody,i got trouble again

Posted: Sat Sep 13, 2014 6:05 pm
by CCE
The CoolBasic DLL support is really limited and you cannot call WinAPI DLLs as is.

There is a wrapper library called cbFUN that has some this functionality. To use it you need to download the SDK and then extract the files to the CoolBasic directory.

List of supported functions:

Code: Select all

ShowWindow() 
FlashWindow()
MoveWindow()
SetWindowAlpha()
SwitchWindow()
DestroyWindow()
CreateRoundWindow()
CreateRectRoundWindow()
HideMenu()
OpenCDTray()
ScreenW()
ScreenH()
Beep()
MsgBox()
HideWindowsTaskBar()
SetTaskBarAlpha()
SetCursorPos()
_PutPixel()
BlockInput()
HideDesktopIcons()
ShowCursor()
LockWorkStation()
TextOut()
MouseEvent()
_MouseX()
_MouseY()
SwapMouseButton()
SetLockLed()
GetAscKey()
TypeStr()
_GetPixel()
SetWindowText()
GetEnv()

Re: hello everybody,i got trouble again

Posted: Sat Sep 13, 2014 6:10 pm
by Latexi95
CBSDK also has functions (including MessageBox) which use WinAPI (these functions are in cbAPI.cb file). It also has functions for making other user interface stuff etc. Take a look at the examples.

Re: hello everybody,i got trouble again

Posted: Sat Sep 13, 2014 6:29 pm
by lanslotfrog
CCE wrote:The CoolBasic DLL support is really limited and you cannot call WinAPI DLLs as is.

There is a wrapper library called cbFUN that has some this functionality. To use it you need to download the SDK and then extract the files to the CoolBasic directory.

List of supported functions:

Code: Select all

ShowWindow() 
FlashWindow()
MoveWindow()
SetWindowAlpha()
SwitchWindow()
DestroyWindow()
CreateRoundWindow()
CreateRectRoundWindow()
HideMenu()
OpenCDTray()
ScreenW()
ScreenH()
Beep()
MsgBox()
HideWindowsTaskBar()
SetTaskBarAlpha()
SetCursorPos()
_PutPixel()
BlockInput()
HideDesktopIcons()
ShowCursor()
LockWorkStation()
TextOut()
MouseEvent()
_MouseX()
_MouseY()
SwapMouseButton()
SetLockLed()
GetAscKey()
TypeStr()
_GetPixel()
SetWindowText()
GetEnv()
I just wanna know how to use CallDll command.......

Re: hello everybody,i got trouble again

Posted: Sat Sep 13, 2014 8:04 pm
by Latexi95
lanslotfrog wrote: I just wanna know how to use CallDll command.......
You usually have to make your own dll for that because CB expects all dll functions to be declared as:
(C++ code)

Code: Select all

extern "C" __declspec( dllexport ) void myfunction(const int *memIn, int memInSize, int *memOut, int memOutSize) {
    // memIn contains pointer to input memblock data and memInSize is the memblock size.
    //same thing for memOut

    //You have to return values by writing them to output memblock
}
Then you could call the function with CallDll:

Code: Select all

CallDLL "mydll.dll", "myfunction", memIn, memOut

Re: hello everybody,i got trouble again

Posted: Sun Sep 14, 2014 8:36 am
by lanslotfrog
Latexi95 wrote:
lanslotfrog wrote: I just wanna know how to use CallDll command.......
You usually have to make your own dll for that because CB expects all dll functions to be declared as:
(C++ code)

Code: Select all

extern "C" __declspec( dllexport ) void myfunction(const int *memIn, int memInSize, int *memOut, int memOutSize) {
    // memIn contains pointer to input memblock data and memInSize is the memblock size.
    //same thing for memOut

    //You have to return values by writing them to output memblock
}
Then you could call the function with CallDll:

Code: Select all

CallDLL "mydll.dll", "myfunction", memIn, memOut
i mean that i don't know how to write argument use MakeMemBlock function
how to use string type?some questions like this

Re: hello everybody,i got trouble again

Posted: Sun Sep 14, 2014 10:14 am
by lanslotfrog
I tried this example

Code: Select all

Include "sdk/include/cbAPI.cb"
Const MID_NEWTEXT = 1
Const MID_NEWIMAGE = 2
Const MID_OPENFILE = 3
Const MID_SAVEFILE = 4
Const MID_EXIT = 5

subID = CreatePopupMenu()
AddPopupMenuItem(subID, MID_NEWTEXT, "Uusi tekstitiedosto")
AddPopupMenuItem(subID, MID_NEWIMAGE, "Uusi kuvatiedosto")

popupID = CreatePopupMenu()
AddPopupSubMenu(popupID, subID, "Uusi")
AddPopupMenuSeparator(popupID)
AddPopupMenuItem(popupID, MID_OPENFILE, "Avaa")
AddPopupMenuItem(popupID, MID_SAVEFILE, "Talleta")
AddPopupMenuSeparator(popupID)
AddPopupMenuItem(popupID, MID_EXIT, "Lopeta")

Repeat
    If MouseHit(2) Then
        cmd = ShowPopupMenu(popupID, MouseX(), MouseY())
        If cmd = MID_EXIT Then End
    EndIf
Forever
but there isn't any response