Posted: 19th Feb 2003 2:10
Hello everyone,

This is my first contribution to DB since the very early days. I've been gone for quite a while, good to be back. Anyways, the code sample below uses a .dll created with PureBasic to demonstrate how to place real "Windows" as children of the DB directX window. It also shows how to add controls (buttons etc.) to the window and get messages back into DB. You will need to d/l the .dll and place it into the same folder as your project files (or windows/system). When you click the button, the windows handle for the button is displayed in the main DB window! If you would like the dll source code please e-mail at [url=mailto:wickedrush@wickedrush.com]wickedrush@wickedrush.com[/url] and i will send the source. I'm sure that a similar lib could be created with C++ or whatever.

link to dll..http://www.wicekdrush.com/purebasic.dll

+ Code Snippet
Rem Project: gdi
Rem Created: 2/16/2003 1:50:02 AM

Rem ***** Main Source File *****

WS_CHILD = 0x40000000
WS_MINIMIZE = 0x20000000
rem **Sample for using Windows native gui with DB!**
rem **written by Sean**

WS_VISIBLE = 0x10000000
WS_CLIPCHILDREN = 0x2000000
WS_BORDER = 0x800000
WS_TABSTOP = 0x10000
GWL_STYLE = -16
WS_EX_CLIENTEDGE = 0x200
WS_EX_LEFT = 0x00000000

sync on
sync rate 0
load dll "user32.dll",1
load dll "purebasic.dll",2

hWnd=call dll(1,"GetForegroundWindow")
style=call dll(1,"GetWindowLongA",hWnd,GWL_STYLE)
call dll 1,"SetWindowLongA",hWnd,GWL_STYLE,style Or WS_CLIPCHILDREN
rem **Set Blitz window to ws_clipchildren style so directX doesn't draw over child windows**

chWnd=call dll(2,"Window","Window",10,10,200,200,0,hWnd,1)
rem **use .dll to create a child window**
call dll 2,"Button",1,10,10,50,30,"Button",0
rem **add a button control to the window**

do

 a=call dll(2,"CheckStatus")
 If a>0 Then Print a
 rem **Check the status of child window for activity, if so print handle of control clicked**
 sync
loop
Posted: 19th Feb 2003 2:15
sorry, no edit function yet

correct link:http://www.wicekdrush.com/purebasic.dll
Posted: 19th Feb 2003 2:16
aaarrrrgh...

http://www.wickedrush.com/purebasic.dll
Posted: 19th Feb 2003 3:08
hmm
Posted: 19th Feb 2003 7:45
Wow, that's pretty impressive. I did have a few problems, though. First, The background wasn't refreshed when I dragged the window until I released the mouse button. Second, It doesn't work in fullscreen exlusive (at least not very well). Other than that, it's great
Posted: 19th Feb 2003 12:36
ESC, When in exclusive you can't have any other windows open. The App becomes "exclusive" and hijacks the screen for itself.

However, in any Desktop (including full screen) mode it will work fine, as it's just another window.
Posted: 19th Feb 2003 18:39
hum . . . then it is possible to make DLLs with pure basic for DBPro . . .
Could you give a DLL skeleton for DBPro under PureBAsic ?
Posted: 20th Feb 2003 4:10
I would just like to add,
Please, Do NOT write a wrapper of PureBasic functions etc. and distribute it as freeware for all! PB is the hard work of one man and something like that could seriously hurt the PB project, and even get you into legal troubles. That being said.. Have fun
Posted: 22nd Feb 2003 17:34
I repost this forgotten code snippet.
The only problem of the code below is if you move the window the old one remains.

(Somebody is so clever to integrate the above code with this one in order to resolve the "leave trail" problem?)
(I don't know where to post this question..)


+ Code Snippet
Rem Project: FileBox Example © 2002 Dragonfly
Rem Created: 29.09.2002 16:12:04

Rem ***** Main Source File *****

load dll "user32.dll",1
load dll "kernel32.dll",2
load dll "comdlg32.dll",3

set window on

rem Memblock Table
OFN_MB          = 1
PathBuffer_MB   = 2
FileFilter_MB   = 3
FileBoxTitle_MB = 4

rem Offset Table OPENFILENAME Struct
lStructSize       = 0
hwndOwner         = 4
hInstance         = 8
lpstrFilter       = 12
lpstrCustomFilter = 16
nMaxCustFilter    = 20
nFilterIndex      = 24
lpstrFile         = 28
nMaxFile          = 32
lpstrFileTitle    = 36
nMaxFileTitle     = 40
lpstrInitialDir   = 44
lpstrTitle        = 48
Flags             = 52
nFileOffset       = 56
nFileExtension    = 58
lpstrDefExt       = 60
lCustData         = 64
lpfnHook          = 68
lpTemplateName    = 72
StructEnd         = 76

rem OPENFILENAME Flag Table
OFN_ALLOWMULTISELECT       = 0x00000200
OFN_CREATEPROMPT           = 0x00002000
OFN_ENABLEHOOK             = 0x00000020
OFN_ENABLETEMPLATE         = 0x00000040
OFN_ENABLETEMPLATEHANDLE   = 0x00000080
OFN_EXPLORER               = 0x00080000
OFN_EXTENSIONDIFFERENT     = 0x00000400
OFN_FILEMUSTEXIST          = 0x00001000
OFN_HIDEREADONLY           = 0x00000004
OFN_LONGNAMES              = 0x00200000
OFN_NOCHANGEDIR            = 0x00000008
OFN_NODEREFERENCELINKS     = 0x00100000
OFN_NOLONGNAMES            = 0x00040000
OFN_NONETWORKBUTTON        = 0x00020000
OFN_NOREADONLYRETURN       = 0x00008000
OFN_NOTESTFILECREATE       = 0x00010000
OFN_NOVALIDATE             = 0x00000100
OFN_OVERWRITEPROMPT        = 0x00000002
OFN_PATHMUSTEXIST          = 0x00000800
OFN_READONLY               = 0x00000001
OFN_SHAREAWARE             = 0x00004000
OFN_SHOWHELP               = 0x00000010

rem FileBox Info
FileFilter$    = "All Files^*.*^DarkBasic Files^*.dba;*.dbpro^^"
FileBoxTitle$  = "FileBox Example^"
FileBoxFlags   = OFN_EXPLORER or OFN_FILEMUSTEXIST or OFN_PATHMUSTEXIST or OFN_LONGNAMES
PathBufferSize = 256
hWnd           = call dll(1,"GetActiveWindow")
hMod           = call dll(2,"GetModuleHandleA",0)

rem Create Memblock Struct
make memblock OFN_MB,StructEnd
make memblock PathBuffer_MB,PathBufferSize
make memblock FileFilter_MB,len(FileFilter$)
make memblock FileBoxTitle_MB,len(FileBoxTitle$)
OFN          = get memblock ptr(OFN_MB)
PathBuffer   = get memblock ptr(PathBuffer_MB)
FileFilter   = get memblock ptr(FileFilter_MB)
FileBoxTitle = get memblock ptr(FileBoxTitle_MB)

rem Dump Strings to Memblock
dump(FileFilter_MB,FileFilter$)
dump(FileBoxTitle_MB,FileBoxTitle$)

rem Write to OPENFILENAME Struct
write memblock dword OFN_MB,lStructSize,StructEnd
write memblock dword OFN_MB,hWndOwner,hWnd
write memblock dword OFN_MB,hInstance,hMod
write memblock dword OFN_MB,lpstrFilter,FileFilter
write memblock dword OFN_MB,lpstrFile,PathBuffer
write memblock dword OFN_MB,nMaxFile,PathBufferSize
write memblock dword OFN_MB,Flags,FileBoxFlags
write memblock dword OFN_MB,lpstrTitle,FileBoxTitle

rem Open FileBox
call dll 3,"GetOpenFileNameA",OFN
print getstr(PathBuffer_MB)
wait key

rem Delete Memblock Struct
delete memblock OFN_MB
delete memblock PathBuffer_MB
delete memblock FileFilter_MB
delete memblock FileBoxTitle_MB

delete dll 1
delete dll 2
delete dll 3
end

function dump(m,s$)
for p=1 to len(s$)

   b=asc(mid$(s$,p))
   if b=asc("^") then b=0
   write memblock byte m,p-1,b

next p
endfunction

function getstr(m)
do

   b=memblock byte(m,p)
   if b=0 then exit
   s$=s$+chr$(b)
   inc p

loop
endfunction s$