Win32 APi with C#
-
Any sample on using CreateWindow API from c# ? I’m aware of “MessageBox” sample on MSDN but I’ve no idea on how to retrieve HWND of Form and Instance handle. I’m trying to put together code to use virtual listview. virtual listview is available in SDK not with .Net. Any idea would be truly appreciated. Thanks
-
Any sample on using CreateWindow API from c# ? I’m aware of “MessageBox” sample on MSDN but I’ve no idea on how to retrieve HWND of Form and Instance handle. I’m trying to put together code to use virtual listview. virtual listview is available in SDK not with .Net. Any idea would be truly appreciated. Thanks
kasturirawat wrote: ...I’ve no idea on how to retrieve HWND of Form and Instance handle. For the HWND use the Forms Handle property. The HINSTANCE is a bit harder to get, but still possible. untested code, but from the docs this should work; though the GetHINSTANCE method confuses me a bit as i'll explain later.
IntPtr hInstance = System.Runtime.InteropServices.Marshal.GetHINSTANCE( typeof(ClassThatHasYourHInstance).Module );
Here's the confusing part about this methodParameters
m
The module whose HInstance is desired.
Return Value
The HInstance for m;-1 if the module does not have an HInstance.Remarks
Whether dynamic or in-memory, modules do not have an HInstance.It looks like this method will work until you read the remarks. We pass in the module whose hinstance we wish to retreive, but then the remarks tells us that modules don't have one. Thus we will always get -1. :confused: :confused: :confused: I seem to vaguely remember there being some win32 function that would give you the hinstance if you had the hwnd. Since you have the hwnd you could call this function and get the hinstance (call via p/invoke). HTH, James Sonork ID: 100.11138 - Hasaki
-
kasturirawat wrote: ...I’ve no idea on how to retrieve HWND of Form and Instance handle. For the HWND use the Forms Handle property. The HINSTANCE is a bit harder to get, but still possible. untested code, but from the docs this should work; though the GetHINSTANCE method confuses me a bit as i'll explain later.
IntPtr hInstance = System.Runtime.InteropServices.Marshal.GetHINSTANCE( typeof(ClassThatHasYourHInstance).Module );
Here's the confusing part about this methodParameters
m
The module whose HInstance is desired.
Return Value
The HInstance for m;-1 if the module does not have an HInstance.Remarks
Whether dynamic or in-memory, modules do not have an HInstance.It looks like this method will work until you read the remarks. We pass in the module whose hinstance we wish to retreive, but then the remarks tells us that modules don't have one. Thus we will always get -1. :confused: :confused: :confused: I seem to vaguely remember there being some win32 function that would give you the hinstance if you had the hwnd. Since you have the hwnd you could call this function and get the hinstance (call via p/invoke). HTH, James Sonork ID: 100.11138 - Hasaki
I’ve created sample for virtual listview using SDK. Since dotnet does not support virtual list view, is there any way I can use my sdK sample with dotnet app. Using PINVOKE is very time consuming
-
I’ve created sample for virtual listview using SDK. Since dotnet does not support virtual list view, is there any way I can use my sdK sample with dotnet app. Using PINVOKE is very time consuming
I believe you could wrap your code with MC++ providing an interface for your dotnet app to work with it. Thats about the extent of my knowledge on MC++ though. :p Perhaps someone with a better grasp could fill you in more? :) James Sonork ID: 100.11138 - Hasaki