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 / C++ / MFC
  4. Talking to CListCtrl that resides in a different process window

Talking to CListCtrl that resides in a different process window

Scheduled Pinned Locked Moved C / C++ / MFC
2 Posts 2 Posters 0 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.
  • M Offline
    M Offline
    Muhammad Ahmed 0
    wrote on last edited by
    #1

    Suppose that there is a window of another process and that window has a CListCtrl on it , i only have the CWnd pointer of the main window that hosts the CListCtrl, i need to add/remove entries in that CListCtrl, ... My approach is that First i need to first get access to the CListCtrl window by getting its handle using BOOL EnumChildWindows( HWND hWndParent, WNDENUMPROC lpEnumFunc, LPARAM lParam ); and once i get this handle i would either try to get CWnd* from it or try sending LVM_XXX messages using CListCtrl handle... I am unsure about if all this would work ... any of you guys , if have any views please share Ahmed

    A 1 Reply Last reply
    0
    • M Muhammad Ahmed 0

      Suppose that there is a window of another process and that window has a CListCtrl on it , i only have the CWnd pointer of the main window that hosts the CListCtrl, i need to add/remove entries in that CListCtrl, ... My approach is that First i need to first get access to the CListCtrl window by getting its handle using BOOL EnumChildWindows( HWND hWndParent, WNDENUMPROC lpEnumFunc, LPARAM lParam ); and once i get this handle i would either try to get CWnd* from it or try sending LVM_XXX messages using CListCtrl handle... I am unsure about if all this would work ... any of you guys , if have any views please share Ahmed

      A Offline
      A Offline
      Antti Keskinen
      wrote on last edited by
      #2

      If you have the CWnd pointer of the target window (main window, for now), then continuing from there is very, very easy. First, use GetTopWindow to get the first child window of the main window. Save this into a seperate pointer. Using the returned pointer, first call ::GetClassName to get the class name of the window. Specify CWnd::m_hWnd as the HWND parameter. If the returned name matches "SysListView32", then this CWnd is the list view control. If the name doesn't match, use the child window pointer and call CWnd::GetWindow( GWL_HWNDNEXT ) to retrieve the next window in the chain. When the pointer is returned, use CWnd::IsChild with the main window pointer to determine if this window is still a child of the target window. If it is, compare the ::GetClassName again with the list view control classname. After you find the CWnd that a) Is a child of the main window b) Matches the list view control classname, then use DYNAMIC_DOWNCAST like this:

      CListCtrl* pListCtrl = DYNAMIC_DOWNCAST( CListCtrl, pMainWindow );

      This will give you a pointer to the CListCtrl class of the list control. If the returned value is NULL, the cast failed. It shouldn't be NULL, because the SysListView32 is encapsulated by the CListCtrl. Remember that your project must be compiled with the Run-Time Type Checking option set to Yes. Otherwise the cast will also fail. Now use the CListCtrl pointer to manipulate the list view control. -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.

      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