Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CreateWindowEx

Status
Not open for further replies.

ashthud

Programmer
Oct 6, 2008
53
GB
This is a vb6 slash win api problem:

I am creating a win32 dll in vb6 (which *is* possible btw:
Basically the dll's purose is to paint a control on screen:
1) initiate common control (initcommoncontrolsex)
2) create window (createwindowex)
NB: i send the window handle of the vb form as a parameter

I want the dll to draw the window/control on my vb form...
* I can directly call 1) and 2) from my vb app and paint a control
* I can directly call 1) and 2) from my vb app and paint a control to another form
* I CAN'T call 1) and 2) from dll (with my vb app handle) to paint the control

(I don't have the code available on me so i will post that later today maybe)
 
Correction: I can actually initialize the common control (1) with the dll; it returns true... but createwindowex(2) only returns 0... as in DIDN'T WORK!
 
This is the code in the dll:
Code:
Public Function CreateWindow(oControl As icc, oClass As String, oName As String, oHwnd As Long, oDWStyle As Long) As Long
   InitCommonControlsEx oControl
   CreateWindow=CreateWindowExA(0,oClass,oName,oDWStyle,0,0,10,10,oHwnd,0,0,0)
   MsgBox GetLastError()
End Function

This is the code to call it:
Code:
Private Type icc
   osize As Long
   oicc As Long
End Type
dim t as icc
t.osize = 8
t.oicc = 2
CreateWindow(t, "SysTreeView32", "TV", Me.hWnd, WS_VISIBLE + WS_BORDER + WS_CHILD)

The getlasterror returns 0.

Ashthud
 
Error number is 1407... im going to have quick google around and see what i can find

Ashthud
 
Ok, apparently the 1407 error is related to an incorrect class name...
the value i sent to the dll was "SysTreeView32", but ends up being something stupid like: "??????2". Do dlls have a problem handling strings?

Ashthud
 
I solved the problem; because my dll has no advanced string handling technique, i have to pass any string values using the strconv() function and convert a string value to unicode string value:

Code:
StrConv("SysTreeView32", vbUnicode)

Ashthud
 
Is there any reason why i can use my dll in VB6 but cannot use it in FOXPRO (2.6)? I get a "ACCESS VIOLATION ERROR"

Ashthud
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top