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. How to get the handles of all the windows opened in wince?

How to get the handles of all the windows opened in wince?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
4 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.
  • U Offline
    U Offline
    ujjawal kumar
    wrote on last edited by
    #1

    I want to retrieve handles for all the windows opened in wince machine. Using my application i need to retrieve the handle for the windows that has been opened in desktop and list the title of those windows in a list view . Thanks in Advance.

    R 1 Reply Last reply
    0
    • U ujjawal kumar

      I want to retrieve handles for all the windows opened in wince machine. Using my application i need to retrieve the handle for the windows that has been opened in desktop and list the title of those windows in a list view . Thanks in Advance.

      R Offline
      R Offline
      Rajkumar R
      wrote on last edited by
      #2

      have a look into [EnumWindows^] and [GetWindowText^] and search CP for ListView

      U 1 Reply Last reply
      0
      • R Rajkumar R

        have a look into [EnumWindows^] and [GetWindowText^] and search CP for ListView

        U Offline
        U Offline
        ujjawal kumar
        wrote on last edited by
        #3

        I have tried with the folowing code snippet.Still i am not able to retrieve the handle for the window. WNDENUMPROC lpEnumFunc = &EnumWindowsProc; TCHAR szName[50]; HWND hTempWnd = NULL; lpEnumFunc(hTempWnd,lParam); if(EnumWindows(lpEnumFunc ,LPARAM(hWnd))) MessageBox(hWnd,L"EnumWindows Successful",NULL,0); lpEnumFunc(hTempWnd,lParam); GetWindowText(hTempWnd,szName,50); MessageBox(hTempWnd,szName,szName,0);

        R 1 Reply Last reply
        0
        • U ujjawal kumar

          I have tried with the folowing code snippet.Still i am not able to retrieve the handle for the window. WNDENUMPROC lpEnumFunc = &EnumWindowsProc; TCHAR szName[50]; HWND hTempWnd = NULL; lpEnumFunc(hTempWnd,lParam); if(EnumWindows(lpEnumFunc ,LPARAM(hWnd))) MessageBox(hWnd,L"EnumWindows Successful",NULL,0); lpEnumFunc(hTempWnd,lParam); GetWindowText(hTempWnd,szName,50); MessageBox(hTempWnd,szName,szName,0);

          R Offline
          R Offline
          Rajkumar R
          wrote on last edited by
          #4

          Well, well try, If that API was supposed to work as per your understanding there are possible risks being caught in an infinite loop or referencing a destroyed window handle. Call Back functions of an Windows API are not that supposed to be called by you.

          struct MYLISTVIEW
          {
          };

          BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
          {
          #define MAX_TEXT_LEN 256
          MYLISTVIEW *plvData = (MYLISTVIEW *)lParam;
          if (plvData)
          {
          TCHAR szWndText[MAX_TEXT_LEN] = _T("");

          	LONG lStyle = GetWindowLong(hwnd, GWL\_STYLE);
          	LONG lExStyle = GetWindowLong(hwnd, GWL\_EXSTYLE);
          
          	// filter the window handles depending on your need
          	if (IsWindowVisible(hwnd) && !GetParent(hwnd) && hwnd != GetDesktopWindow() && (
          		/\*lExStyle & WS\_EX\_APPWINDOW || \*/
          		!(lExStyle & WS\_EX\_NOACTIVATE || lExStyle & WS\_EX\_TOOLWINDOW)))
          	{			
          		RECT rc = {0};
          		GetWindowRect(hwnd, &rc);
          		if (rc.bottom - rc.top && rc.right - rc.left)
          		{
          			GetWindowText(hwnd, szWndText, MAX\_TEXT\_LEN);
          
                                      // add the text to your view
          			AddWndTextToListView(plvData, szWndText);
          		}			
          	}
          }
          return TRUE;	
          

          }

          MYLISTVIEW g_lvData;

          void AddOpenedWindowsToListView()
          {
          EnumWindows(EnumWindowsProc, (LPARAM)&g_lvData);
          }

          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