I like what you guy's are doing... Here's my contribution;
First up, here's some source I wrote a while back to get Buttons and List Boxes working in DBP with native calls.
Sync On : Sync Rate 0
Disable EscapeKey
#Constant NULL 0
#Constant BM_GETSTATE 0x00F2
#Constant BST_PUSHED 0x0004
#Constant GWL_HINSTANCE -6
#Constant GWL_STYLE -16
#Constant WS_EX_ACCEPTFILES 0x00000010
#Constant WS_EX_TOPMOST 0x00000008
#Constant WS_VISIBLE 0x10000000
#Constant WS_CHILD 0x40000000
#COnstant WS_CLIPCHILDREN 0x02000000
#Constant WS_CLIPSIBLINGS 0x04000000
#Constant WS_VSCROLL 0x00200000
#Constant WS_BORDER 0x00800000
#Constant WM_SETFONT 0x0030
#Constant WM_GETFONT 0x0031
#Constant SW_SHOW 5
#Constant SW_RESTORE 9
#Constant SWP_SHOWWINDOW 0x0040
#Constant SWP_DEFERERASE 0x2000
#Constant SWP_NOZORDER 0x0004
#Constant SWP_NOMOVE 0x0002
#Constant SWP_NOOWNERZORDER 0x0200
#Constant BCM_FIRST 0x1600
#Constant BCM_GETIDEALSIZE BCM_FIRST || 0x0001
`BUTTON STYLE Constants
#Constant BS_PUSHBUTTON 0x00000000
#Constant BS_DEFPUSHBUTTON 0x00000001
#Constant BS_CHECKBOX 0x00000002
#Constant BS_AUTOCHECKBOX 0x00000003
#Constant BS_RADIOBUTTON 0x00000004
#Constant BS_3STATE 0x00000005
#Constant BS_AUTO3STATE 0x00000006
#Constant BS_GROUPBOX 0x00000007
#Constant BS_USERBUTTON 0x00000008
#Constant BS_AUTORADIOBUTTON 0x00000009
#Constant BS_OWNERDRAW 0x0000000B
#Constant BS_LEFTTEXT 0x00000020
#Constant BS_TEXT 0x00000000
#Constant BS_ICON 0x00000040
#Constant BS_BITMAP 0x00000080
#Constant BS_LEFT 0x00000100
#Constant BS_RIGHT 0x00000200
#Constant BS_CENTER 0x00000300
#Constant BS_TOP 0x00000400
#Constant BS_BOTTOM 0x00000800
#Constant BS_VCENTER 0x00000C00
#Constant BS_PUSHLIKE 0x00001000
#Constant BS_MULTILINE 0x00002000
#Constant BS_NOTIFY 0x00004000
#Constant BS_FLAT 0x00008000
`LISTBOX STYLE Constants
#Constant LBS_NOTIFY 0x0001
#Constant LBS_SORT 0x0002
#Constant LBS_NOREDRAW 0x0004
#Constant LBS_MULTIPLESEL 0x0008
#Constant LBS_OWNERDRAWFIXED 0x0010
#Constant LBS_OWNERDRAWVARIABLE 0x0020
#Constant LBS_HASSTRINGS 0x0040
#Constant LBS_USETABSTOPS 0x0080
#Constant LBS_NOINTEGRALHEIGHT 0x0100
#Constant LBS_MULTICOLUMN 0x0200
#Constant LBS_WANTKEYBOARDINPUT 0x0400
#Constant LBS_EXTENDEDSEL 0x0800
#Constant LBS_DISABLENOSCROLL 0x1000
#Constant LBS_NODATA 0x2000
#Constant LBS_NOSEL 0x4000
#Constant LBS_STANDARD LBS_NOTIFY || LBS_SORT || WS_VSCROLL || WS_BORDER
`Listbox messages
#Constant LB_ADDSTRING 0x0180
#Constant LB_INSERTSTRING 0x0181
#Constant LB_DELETESTRING 0x0182
#Constant LB_SELITEMRANGEEX 0x0183
#Constant LB_RESETCONTENT 0x0184
#Constant LB_SETSEL 0x0185
#Constant LB_SETCURSEL 0x0186
#Constant LB_GETSEL 0x0187
#Constant LB_GETCURSEL 0x0188
#Constant LB_GETTEXT 0x0189
#Constant LB_GETTEXTLEN 0x018A
#Constant LB_GETCOUNT 0x018B
#Constant LB_SELECTSTRING 0x018C
#Constant LB_DIR 0x018D
#Constant LB_GETTOPINDEX 0x018E
#Constant LB_FINDSTRING 0x018F
#Constant LB_GETSELCOUNT 0x0190
#Constant LB_GETSELITEMS 0x0191
#Constant LB_SETTABSTOPS 0x0192
#Constant LB_GETHORIZONTALEXTENT 0x0193
#Constant LB_SETHORIZONTALEXTENT 0x0194
#Constant LB_SETCOLUMNWIDTH 0x0195
#Constant LB_ADDFILE 0x0196
#Constant LB_SETTOPINDEX 0x0197
#Constant LB_GETITEMRECT 0x0198
#Constant LB_GETITEMDATA 0x0199
#Constant LB_SETITEMDATA 0x019A
#Constant LB_SELITEMRANGE 0x019B
#Constant LB_SETANCHORINDEX 0x019C
#Constant LB_GETANCHORINDEX 0x019D
#Constant LB_SETCARETINDEX 0x019E
#Constant LB_GETCARETINDEX 0x019F
#Constant LB_SETITEMHEIGHT 0x01A0
#Constant LB_GETITEMHEIGHT 0x01A1
#Constant LB_FINDSTRINGEXACT 0x01A2
#Constant LB_SETLOCALE 0x01A5
#Constant LB_GETLOCALE 0x01A6
#Constant LB_SETCOUNT 0x01A7
#Constant LB_INITSTORAGE 0x01A8
#Constant LB_ITEMFROMPOINT 0x01A9
#Constant LB_MULTIPLEADDSTRING 0x01B1
#Constant LB_GETLISTBOXINFO 0x01B2
Global DBPHwnd As DWord
Global user32 As Integer
Global comctl32 As Integer
_initialize_API()
myfont As DWord
mylist As DWord
Global mybut As DWord
Dim buts(0) As DWord
flag = 1
For i = 1 To 5
x = x + _button_width(buts(i - 1))
y = y + _button_height(buts(i - 1))
Array Insert At Bottom buts(0)
buts(i) = _button("Hello World99",x,y,flag)
flag = 0
Next i
mylist = _list_box(10,50,200,100,1)
_list_add_string(mylist,"List Item 1")
_list_add_string(mylist,"PACHING")
_list_add_string(mylist,"AAAAList Item 1")
_list_add_string(mylist,"BBBBList Item 2")
_list_add_string(mylist,"CCCCList Item 3")
_list_add_string(mylist,"List Item 4")
_list_add_string(mylist,"List Item 5")
_list_add_string(mylist,"List Item 6")
_list_add_string(mylist,"List Item 7")
_list_add_string(mylist,"List Item 8")
_list_add_string(mylist,"List Item 9")
_list_add_string(mylist,"List Item 10")
_list_add_string(mylist,"List Item 11")
_list_remove_string(mylist,1)
myfont = Call DLL(user32,"SendMessageA",mylist,WM_SETFONT,50,1)
Repeat
Cls
Text 0,500,Str$(myfont)
If _button_down(buts(2)) = 1
Cls RGB(Rnd(255),Rnd(255),Rnd(255))
Text 200,0,"'" + _list_get_sel_string(mylist) + "'"
Wait 1000
EndIf
FastSync
Until EscapeKey()
For x = 1 To 5
Call DLL user32,"DestroyWindow",buts(x)
Next x
Delete DLL user32
Delete DLL comctl32
Function _initialize_API()
Local styles As DWord
`Load in the user32.dll
user32 = _find_free_dll()
Load DLL "user32.dll",user32
`Set up the window so it can use window's styles;
comctl32 = _find_free_dll()
Load DLL "comctl32.dll",comctl32
Call DLL comctl32,"InitCommonControls"
`Get the handle to the window
DBPHwnd = Call DLL(user32,"GetActiveWindow")
`Set up the DBP window so that it doesn't draw over API screen areas
styles = Call DLL(user32,"GetWindowLongA",DBPHwnd,GWL_STYLE)
styles = styles || WS_CLIPCHILDREN
styles = Call DLL(user32,"SetWindowLongA",DBPHwnd,GWL_STYLE,styles)
EndFunction
Function _list_box(x As Integer,y As Integer,cx As Integer,cy As Integer,flag As Boolean)
Local retval As DWord
Local params As DWord
params = WS_VISIBLE || WS_CHILD || LBS_NOTIFY || LBS_SORT || WS_VSCROLL || WS_BORDER
retval = 0
retval = Call DLL(user32,"CreateWindowExA",NULL,"LISTBOX",NULL,params,x,y,cx,cy,DBPHwnd)
EndFunction retval
Function _list_add_string(lbox As DWord,str As String)
Local result As Integer
Local ptr As DWord
ptr = _get_str_ptr(str + "|")
result = Call DLL(user32,"SendMessageA",lbox,LB_ADDSTRING,NULL,ptr)
If result > 0
ExitFunction 1
EndIf
EndFunction 0
Function _list_remove_string(lbox As DWord,index As DWord)
result = Call DLL(user32,"SendMessageA",lbox,LB_DELETESTRING,index,NULL)
EndFunction
Function _list_get_sel(lbox As DWord)
Local result As DWord
result = Call DLL(user32,"SendMessageA",lbox,LB_GETCURSEL,NULL,NULL)
EndFunction result
Function _list_get_sel_string(lbox As DWord)
Local tmp As DWord
Local str As String
Local strptr As DWord
str = Space$(255)
strptr = _get_str_ptr(str + "|")
tmp = Call DLL(user32,"SendMessageA",lbox,LB_GETTEXT,_list_get_sel(lbox),strptr)
str = _strip_space(2,_get_str(strptr,255))
` str =_get_str(strptr,255)
EndFunction str
Function _button(butstr As String,x As Integer,y As Integer,flag As Boolean)
Local retval As DWord
Local params As DWord
Local strptr As DWord
Local cx As DWord
Local cy As DWord
Local size As Integer
Local SIZEptr As DWord
Local pointsize As Integer
pointsize = Text Size()
Set Text Size 10
cx = Text Width(butstr) + 5
cy = Text Height(butstr) + 5
Set Text Size pointsize
If flag = 1
params = WS_VISIBLE || WS_CHILD || BS_AUTOCHECKBOX || BS_PUSHLIKE
retval = 0
strptr = _get_str_ptr(butstr)
retval = Call DLL(user32,"CreateWindowExA",NULL,"BUTTON",strptr,params,x,y,cx,cy,DBPHwnd)
Else
params = WS_VISIBLE || WS_CHILD || BS_PUSHBUTTON
retval = 0
strptr = _get_str_ptr(butstr)
retval = Call DLL(user32,"CreateWindowExA",NULL,"BUTTON",strptr,params,x,y,cx,cy,DBPHwnd)
EndIf
remstart
SIZEptr = Make Memory(8)
tmp = Call DLL(user32,"SendMessageA",retval,BCM_GETIDEALSIZE,0,SIZEptr)
cx = *SIZEptr
Inc SIZEptr,4
cy = *SIZEptr
Dec SIZEptr,4
tmp = Call DLL(user32,"SetWindowPos",retval,0,x,y,cx,cy,SWP_NOMOVE || SWP_NOOWNERZORDER || SWP_NOZORDER || SWP_SHOWWINDOW)
Delete Memory SIZEptr
remend
EndFunction retval
Function _button_set_ideal_size(but As DWord)
Local ptr As DWord
Local result As DWord
ptr = Make Memory(8)
result = Call DLL(user32,"SendMessageA",but,BCM_GETIDEALSIZE,NULL,NULL)
EndFunction
Function _button_down(but As DWord)
Local result As DWord
result = Call DLL(user32,"SendMessageA",but,BM_GETSTATE,NULL,NULL)
If result = 108
ExitFunction 1
EndIf
EndFunction 0
Function _button_width(but As DWord)
Local result As DWord
Local lprect As Integer
Local lprectptr As DWord
lprect = _find_free_mem()
Make MemBlock lprect,12
lprectptr = Get MemBlock Ptr(lprect)
result = Call DLL(user32,"GetWindowRect",but,lprectptr)
result = MemBlock DWord(lprect,8) - MemBlock DWord(lprect,0)
Delete MemBlock lprect
EndFunction result
Function _button_height(but As DWord)
Local result As DWord
Local lprect As Integer
Local lprectptr As DWord
lprect = _find_free_mem()
Make MemBlock lprect,16
lprectptr = Get MemBlock Ptr(lprect)
result = Call DLL(user32,"GetWindowRect",but,lprectptr)
result = MemBlock DWord(lprect,12) - MemBlock DWord(lprect,4)
Delete MemBlock lprect
EndFunction result
Function _get_str_ptr(pstr As String)
`pstr$ should be a "|" ( NULL ) seperated string.
memnum As Integer
strlen As Integer
char As Byte
memptr As DWord
strptr As DWord
memnum = _find_free_mem()
strlen = Len(pstr)
Make MemBlock memnum,strlen
For i = 1 To strlen
If Mid$(pstr,i) = "|"
char = 0
Else
char = Asc(Mid$(pstr,i))
EndIf
Write MemBlock Byte memnum,(i - 1),char
Next i
memptr = Get MemBlock Ptr(memnum)
strptr = Make Memory(strlen)
Copy Memory strptr,memptr,strlen
Delete MemBlock memnum
EndFunction strptr
Function _get_str(strptr As DWord,strsize As Integer)
`strptr is the pointer returned by _get_str_ptr()
`strsize is the Integer length of the string specified by the pointer
memnum As Integer
memptr As DWord
str As String
char As String
memnum = _find_free_mem()
Make MemBlock memnum,strsize
memptr = Get MemBlock Ptr(memnum)
Copy Memory memptr,strptr,strsize
For i = 1 To strsize
str = str + Chr$(MemBlock Byte(memnum,i - 1))
Next i
EndFunction str
Function _find_free_dll()
retval = 0
Repeat
Inc retval
Until DLL Exist(retval) = 0
EndFunction retval
Function _find_free_mem()
retval = 0
Repeat
Inc retval
Until MemBlock Exist(retval) = 0
EndFunction retval
Function _strip_space(part As Integer,sstr As String)
`str is the string to be striped.
`part can be 1, 2 or 3.
`1 to strip space at the start of the string
`2 to strip space at the end of the string
`3 to strip all space in the string
strlen = Len(sstr)
tmpstr$ = ""
If part = 1
For i = 1 To strlen
If Mid$(sstr,i) <> " "
tmpstr$ = Right$(sstr,strlen - i + 1)
ExitFunction tmpstr$
EndIf
Next i
EndIf
If part = 2
For i = strlen To 1 Step -1
If Mid$(sstr,i) <> " "
tmpstr$ = Left$(sstr,i)
ExitFunction tmpstr$
EndIf
Next i
EndIf
If part = 3
For i = 1 To strlen
If Mid$(sstr,i) <> " "
tmpstr$ = tmpstr$ + Mid$(sstr,i)
EndIf
Next i
ExitFunction tmpstr$
EndIf
EndFunction "Error"
It's fairly self-explanitory,
Attached is a zip of a JukeBox program I made, which uses these two things, and the can interact
Make of them what you will, and use them for whatever you want.
Good luck!
Jess.