hello everybody,i got trouble again

Post your coding questions such as 'how to' here.
Post Reply
lanslotfrog
Newcomer
Posts: 11
Joined: Wed Mar 12, 2014 8:43 am

hello everybody,i got trouble again

Post 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.
User avatar
CCE
Artist
Artist
Posts: 650
Joined: Mon Aug 27, 2007 9:53 pm

Re: hello everybody,i got trouble again

Post 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()
Latexi95
Guru
Posts: 1166
Joined: Sat Sep 20, 2008 5:10 pm
Location: Lempäälä

Re: hello everybody,i got trouble again

Post 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.
lanslotfrog
Newcomer
Posts: 11
Joined: Wed Mar 12, 2014 8:43 am

Re: hello everybody,i got trouble again

Post 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.......
Latexi95
Guru
Posts: 1166
Joined: Sat Sep 20, 2008 5:10 pm
Location: Lempäälä

Re: hello everybody,i got trouble again

Post 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
lanslotfrog
Newcomer
Posts: 11
Joined: Wed Mar 12, 2014 8:43 am

Re: hello everybody,i got trouble again

Post 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
lanslotfrog
Newcomer
Posts: 11
Joined: Wed Mar 12, 2014 8:43 am

Re: hello everybody,i got trouble again

Post 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
Post Reply