Re: Interop and Modal Forms
Can you pass the Handle of the .NET form?
Re: Interop and Modal Forms
Re: Interop and Modal Forms
Then that's what you should do. The Handle property of a Form is type IntPtr, which you can use as is if approriate or else call ToInt32 to get an Integer.
Re: Interop and Modal Forms
Ok, on the com side, how do I pass the handle to the .Show method?
Re: Interop and Modal Forms
No idea. Never done any COM development.
Re: Interop and Modal Forms
I'm also facing the same issue. Can you please help me , how you reslove the issue.
Re: Interop and Modal Forms
Maybe use the SetWindowLong API to set the dialog's parent (owner) ?
Syntax is something like,...
SetWindowLong dialogForm.handle, GWL_HWNDPARENT, myForm.handle
Re: Interop and Modal Forms
Based on the description provided by the OP I would expect it to be done like this:-
vbnet Code:
_ComForm.Show vbModal, _DotNetForm.Handle.ToInt32
I'm assuming the COM method would take a 32 bit integer for the window handle assuming a 32 bit OS.
@Op
Could you provide the signature for that COM method ?
Re: Interop and Modal Forms
Im using VB6
Me.Show vbModal
oldOwner = SetOwner(Oconverstion.hWnd, Me.hWnd)
These are API im using to set the owner
Private Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
Const GWL_HWNDPARENT = (-8)
Public Function SetOwner(ByVal HwndtoUse, ByVal HwndofOwner) As Long
SetOwner = SetWindowLong(HwndtoUse, GWL_HWNDPARENT, HwndofOwner)
End Function
Re: Interop and Modal Forms
Quote:
Originally Posted by
manish.amq
Im using VB6
Well you should make your own thread in the VB6 section. VB6 may have its own set of nuances.
Re: Interop and Modal Forms
Using SetWindowLong with GWL_HWNDPARENT is the correct approach. However you should also use EnableWindow to disable the parent window and call it again to enable it when the modal form is closed.