I dont have much idea about VB as i am vc++ programmer, My colleague says its impossible to display a vc++ child dialog(dll) in her VB form but can display a vc++ dialog if its of popup style.
But my requirement is VC++ child dialog has to be displayed inside VB forms and not as popop window.
Re: Place VC++ child dialog(dll) inside VB form ??
Possible it is.
First you have to declare the function and its origin like
Code:
Declare Function myDllFunction Lib "mydll.dll" ([optioanl parameters]) As Long
In your VB ptogram you invoke it like
Code:
Dim retval As Long
retval = myDllFunction([parameters if any])
The appearance of the popup, however, would propably be on top of the B windows, but not actually inside them.
The function should return the actual window handle (hWnd) of the popup, then we could think of methods to make a VB window parent to it, or at least simulate an appearance "within" the VB window.
Re: Place VC++ child dialog(dll) inside VB form ??
Originally Posted by WoF
Well, why can't you?
Beacause i dont know VB
Originally Posted by WoF
Did you try the SetParent function according to the instructions?
I cant tell the VB guys as they say they are expert and they cant achieve above requirement.
Originally Posted by WoF
It gives us all a bad feeling to run unknown code from a dll on our ccomputers.
To be honest, If i were you i would have created the VB app and would have attached VB source here instead of using an unknown code. I guess it hardly a 5 lines of code.
Re: Place VC++ child dialog(dll) inside VB form ??
Ok, I misunderstood.
So, assumed you have a form named Form1 and you want to open your dll's child and attach it to Form1 then this is the code:
Code:
'First the SetParent API function is declared.
Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
'Then the function inside your dll is declared.
Declare Function CallDllChildWindow Lib "VCDllChildDlg.dll" () As Long
'A variable ChildWindow is declared to hold the hWnd of the child
Private ChildhWnd As Long
Sub OpenAndAttachChild()
' this calls your dll for the child window and calls SetParent to attach it to the Form1.
Dim res As Long
ChildhWnd = CallDllChildWindow
res = SetParent(ChildhWnd, Form1.hWnd)
If res <> 0 Then 'you have succeeded, otherwise the call failed for some reason.
End Sub
Instead of Form1.hWnd you could write Me.hWnd when the code is within the parent form.
Re: Place VC++ child dialog(dll) inside VB form ??
@WoF - Much appreciated for the code.
When i copied your code to form1.frm it was giving compiler errors.
I figured out that we have to add Private before 'Declare' keyword with the help of google.
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.