Passing around params VC++6.0 VC#
-
:confused:Greetings. I'm using a VC++ 6.0 MDI to call a VC# form .dll. I exposed the VC# dll as a COM interface... n now I need to tell the VC# dll who's the daddy... but the VC# forms daddy should be a System.Windows.Forms.Form()... So i want to pass the handle of the VC++ 6.0 MDI app to a method from the VC#... it asks for an IUnknown... Please tell me how do i take the this->m_hWnd pass it through an IUnknow* and finally put it in a System.Windows.Forms.Form object... can this b done? is there a more friendly way? Thanks:confused: NHM
-
:confused:Greetings. I'm using a VC++ 6.0 MDI to call a VC# form .dll. I exposed the VC# dll as a COM interface... n now I need to tell the VC# dll who's the daddy... but the VC# forms daddy should be a System.Windows.Forms.Form()... So i want to pass the handle of the VC++ 6.0 MDI app to a method from the VC#... it asks for an IUnknown... Please tell me how do i take the this->m_hWnd pass it through an IUnknow* and finally put it in a System.Windows.Forms.Form object... can this b done? is there a more friendly way? Thanks:confused: NHM
If the only thing you need to pass is a window handle, then ::SendMessage(...) is probably the fastest way to achieve it. It does not require the COM interop you have mentioned.
-
If the only thing you need to pass is a window handle, then ::SendMessage(...) is probably the fastest way to achieve it. It does not require the COM interop you have mentioned.
-
how can the VC# dll receive messages... in vc++6.0 PreTranslateMessage is the answer... n in VC#?:confused:
NHM wrote: how can the VC# dll receive messages... in vc++6.0 PreTranslateMessage is the answer... n in VC#? A Windows Forms app has a UI thread which processes windows messages just like any WIN32 app with a message loop. Any Windows Form control has a virtual WndProc method that can be overridden to respond accordingly. The other way, a C# app can send a WIN32 message to any window (for instance a window from a VC++6 app) by using the [DllImport] P/Invoke technique : [DllImport("user32.dll", CharSet=CharSet.Auto)] public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
-
NHM wrote: how can the VC# dll receive messages... in vc++6.0 PreTranslateMessage is the answer... n in VC#? A Windows Forms app has a UI thread which processes windows messages just like any WIN32 app with a message loop. Any Windows Form control has a virtual WndProc method that can be overridden to respond accordingly. The other way, a C# app can send a WIN32 message to any window (for instance a window from a VC++6 app) by using the [DllImport] P/Invoke technique : [DllImport("user32.dll", CharSet=CharSet.Auto)] public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
-
if i override WndProc in the windows form (C# dll) then when i try to open it through the VC++ 6.0 App it stops execution... just gives a runtime error... ideas? thanks 4 your suport .S.Rod!
NHM wrote: when i try to open it through the VC++ 6.0 App What do you mean ? Has it anything to do with the debug session ? Do you mean you are trying to access the C# WndProc implementation from your VC++ debug session ? No need to go further, you simply can't. Or do you mean you are processing the message in the C# wndproc implementation and then it fails? If the code fails at this point, then it might be helpful for those listening if you post the code.
-
NHM wrote: when i try to open it through the VC++ 6.0 App What do you mean ? Has it anything to do with the debug session ? Do you mean you are trying to access the C# WndProc implementation from your VC++ debug session ? No need to go further, you simply can't. Or do you mean you are processing the message in the C# wndproc implementation and then it fails? If the code fails at this point, then it might be helpful for those listening if you post the code.
i've just overriden the WndProc... no code added to the base override... this is what i have... a) a vc++ 6.0 Mdi app (.exe) b) a vc# dll with: - class A (interface) (cominterop) (i have to call some methods and access some properties) - class B (windows form) in the vc++ 6.0 mdi app i create an instance of classA then i call a method from class A wich does this: public void SomeThing() { Form1 f = new Form1(); f.Show(); } and this is what i intended to do: public void SomeThing( Form parent) { Form1 f = new Form1( Form parent); f.MdiParent = parent; f.Show(); } i just want to say to the VC# winForm that his container is the VC++ 6.0 APP what can i do?
-
i've just overriden the WndProc... no code added to the base override... this is what i have... a) a vc++ 6.0 Mdi app (.exe) b) a vc# dll with: - class A (interface) (cominterop) (i have to call some methods and access some properties) - class B (windows form) in the vc++ 6.0 mdi app i create an instance of classA then i call a method from class A wich does this: public void SomeThing() { Form1 f = new Form1(); f.Show(); } and this is what i intended to do: public void SomeThing( Form parent) { Form1 f = new Form1( Form parent); f.MdiParent = parent; f.Show(); } i just want to say to the VC# winForm that his container is the VC++ 6.0 APP what can i do?
The simplest thing that comes to my mind is to reparent the C# form window. This can be done with simple things : - the window handle of the C# form is obtained using this.Handle if you use managed code. Otherwise, from C++ code you can enum windows or use FindWindow(...) with a particular caption to get that window handle. - then, use WIN32 ::SetParent(hwndForm, hwndNewParent /*MDIapp frame window hande*/) to reparent the form. Good luck!