Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Win32 APi with C#

Win32 APi with C#

Scheduled Pinned Locked Moved C#
csharpjsontutorialquestion
4 Posts 2 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kasturirawat
    wrote on last edited by
    #1

    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

    J 1 Reply Last reply
    0
    • K kasturirawat

      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

      J Offline
      J Offline
      James T Johnson
      wrote on last edited by
      #2

      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 method

      Parameters
      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

      K 1 Reply Last reply
      0
      • J James T Johnson

        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 method

        Parameters
        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

        K Offline
        K Offline
        kasturirawat
        wrote on last edited by
        #3

        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

        J 1 Reply Last reply
        0
        • K kasturirawat

          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

          J Offline
          J Offline
          James T Johnson
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups