CreateWindowEx problem

BlitzPlus Forums/BlitzPlus Programming/CreateWindowEx problem

Cold Harbour(Posted 2005) [#1]
Anyone see what I’m doing wrong using CreateWindowEx with B+?
This just crashes but ‘should’ create a listbox.
Thanks a lot.

; 	.lib "User32.dll"
;	api_CreateWindowEx% (dwExStyle%, lpClassName$, lpWindowName$, dwStyle%, x%, y%, nWidth%, nHeight%, hWndParent%, hMenu%, hInstance%, lpParam*) : "CreateWindowExA"
;	api_GetActiveWindow% () : "GetActiveWindow"

AppTitle "test"
Const 	dwExStyle			=	512
Const	hMenu				=	0;3
WS_CHILD = 16384 Shl 16
WS_GROUP = 2 Shl 16
WS_TABSTOP = 1 Shl 16
WS_VISIBLE = 4096 Shl 16
WS_VSCROLL = 32 Shl 16
LBS_USETABSTOPS = 128

xdwStyle = WS_CHILD Or WS_VISIBLE; Or WS_VSCROLL
dwStyle			=	xdwStyle

win=CreateWindow ("Win",10,10,800,600,main,11)

hWnd = api_GetActiveWindow()

api_CreateWindowEx (dwExStyle,"ListBox","test",dwStyle,10,10,200,200,hWnd,hMenu,0,0)

While WaitEvent(10)<>$803
Wend
End 



Kev(Posted 2005) [#2]
Hi Cold Harbour, your passing a bank on the lparam of createwindowex without creating one. also hInstance requires an handle to the module thats calling createwindowex.


; decls
;
.lib "kernel32.dll"
kernel32_GetModuleHandle%(lpModuleName%):"GetModuleHandleA" 

.lib "user32.dll"
api_CreateWindowEx% (dwExStyle%, lpClassName$, lpWindowName$, dwStyle%, x%, y%, nWidth%, nHeight%, hWndParent%, hMenu%, hInstance%, lpParam%) : "CreateWindowExA"
api_GetActiveWindow% () : "GetActiveWindow"

; example
;
AppTitle "test"
Const 	dwExStyle			=	512

Const WS_CHILD = $40000000
Const WS_VISIBLE  = $10000000

win = CreateWindow ("Win",10,10,800,600,0,11)

hWnd = QueryObject(win,1);api_GetActiveWindow()

listbox = api_CreateWindowEx(dwExStyle,"LISTBOX","test",WS_CHILD Or WS_VISIBLE,10,10,200,200,hWnd,0,kernel32_GetModuleHandle(0),0)

Repeat 
If WaitEvent()=$803 Then Exit 
Forever 

End


kev


Cold Harbour(Posted 2005) [#3]
Thanks a lot Kev! :)