locked
HTC running applications list RRS feed

  • Question

  • Hi. I noticed that on HTC WM devices(like: touch diamond2, etc) there is an running applications list in the upper left corner of the screen and all the applications are shown there while running, like: Opera Browser or File Explorer. But for some strange reason my application isn't shown there. Maybe somebody familiar with this issue? How can I add my application to this list?

    Thanks in advance. 

    Sunday, February 20, 2011 4:22 PM

Answers

  • If you go to Settings->System->Task Manager does your application appear there as an "Application"?
    If it does, then the HTC app may be filtering on registered window classes. Just for giggles, try calling RegisterClass:

    ATOM MyRegisterClass(HINSTANCE hInstance, LPTSTR szWindowClass)
    {
      WNDCLASS wc;
    
      wc.style     = CS_HREDRAW | CS_VREDRAW;
      wc.lpfnWndProc  = WndProc;
      wc.cbClsExtra  = 0;
      wc.cbWndExtra  = 0;
      wc.hInstance   = hInstance;
      wc.hIcon     = LoadIcon(hInstance, MAKEINTRESOURCE(IDD_MAIN));
      wc.hCursor    = 0;
      wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
      wc.lpszMenuName = 0;
      wc.lpszClassName = szWindowClass;
    
      return RegisterClass(&wc);
    }
    -PaulH
    • Marked as answer by Bin-ze Zhao Monday, February 28, 2011 11:50 AM
    Wednesday, February 23, 2011 7:31 PM

All replies

  • Does the main window of your application have a caption/title?

     


    Christian Resma Helle - Commentor A/S
    Monday, February 21, 2011 7:56 AM
  • Yes, it has caption. I use SetWindowText to set it. 
    Monday, February 21, 2011 8:29 AM
  • And the window is also visible? A hidden window would not be displayed in the list of running tasks

     


    Christian Resma Helle - Commentor A/S
    Monday, February 21, 2011 8:34 AM
  • Yes, it's visible. I just build mfc dialog demo project and it's visible in task list. My program written without mfc, just vc++, maybe it can cause some kind of problem?
    Monday, February 21, 2011 9:16 AM
  • Can you post some code on how your main window is created?

     


    Christian Resma Helle - Commentor A/S
    Monday, February 21, 2011 12:00 PM
  • int WINAPI WinMain(	HINSTANCE hInstance,
    				 HINSTANCE hPrevInstance,
    				 LPTSTR lpCmdLine,
    				 int  nCmdShow)
    {
    	HACCEL hAccelTable;
    	
    	// Perform application initialization:
    	INITCOMMONCONTROLSEX comctrex = { 0 };
    	
    	comctrex.dwSize = sizeof(INITCOMMONCONTROLSEX);
    	comctrex.dwICC = ICC_DATE_CLASSES;
    	InitCommonControls();
    	InitCommonControlsEx(&comctrex);
    	g_hInst = hInstance;
    	if (!InitInstance (hInstance, nCmdShow)) 
    	{
    		return FALSE;
    	}
    	
    	hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_POOMMASTER);	
    
    	DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), 0, (DLGPROC)WndProc); 
    	
    	free(confInterface);
    	confInterface = NULL;
    
    	return 0;
    }
    
    BOOL InitInstance(HINSTANCE hInstance, 
    				 int nCmdShow)
    {
    	bool AlreadyRunning;
    	g_hInst = hInstance;
    
    
    	HANDLE hMutexOneInstance = ::CreateMutex( NULL, TRUE,
    		_T("MYAPPNAME-088FA840-B10D-11D3-BC36-006067709674"));
    
    	AlreadyRunning = (GetLastError() == ERROR_ALREADY_EXISTS);
    
    	if (hMutexOneInstance != NULL) 
    	{
    		::ReleaseMutex(hMutexOneInstance);
    	}
    
    	if ( AlreadyRunning )
    	{ 
    		/* kill this */
    		HWND hOther = g_hwndMain;
    
    		HWND pWnd1 = FindWindow(NULL, APP_PROMPT_NAME);
      HWND pWnd2 = FindWindow(NULL, APP_LOGIN_DILAOG);					
    
    		if(pWnd1 != NULL)
    		{
    			::SetForegroundWindow(pWnd1);
    			::ShowWindow(pWnd1, SW_RESTORE);
    		}		
    		else if (pWnd2 != NULL)
    		{
    			::SetForegroundWindow(pWnd2);
    			::ShowWindow(pWnd2, SW_RESTORE);
    		}
    
    		return FALSE; // terminates the creation
    	} /* kill this */
    
    	return TRUE;
    } 
    
    LRESULT CALLBACK WndProc(HWND hWnd, 
    						 UINT message, 
    						 WPARAM wParam, 
    						 LPARAM lParam) {
    ...
    
    	case WM_INITDIALOG:
    		{
    			SHINITDLGINFO shidi;
    
    			shidi.dwMask = SHIDIM_FLAGS;
    			shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN;
    			shidi.hDlg = hWnd;
    			SHInitDialog(&shidi);
    			
    			g_hwndMain = hWnd;
    			g_hwndCB = CreateRpCommandBar(hWnd, IDM_MOBILE_OFFICE_MAIN);
    
    			// Create the ListView control
    			g_hwndLV = CreateListView(hWnd);
    			// populate the main listview display
    
    			RefreshListView(g_hwndLV);
       
    			SetWindowText(g_hwndMain, CAPTION_MAIN_DILAOG);
    	
    			SetFocus(g_hwndLV);
    ...
    }
    
    Here are some key functions and code parts.
    Monday, February 21, 2011 12:04 PM
  • Try to pass the main handle of your application when calling DialogBox

     

    Something like:

    DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), g_hwndMain, (DLGPROC)WndProc); 

     


    Christian Resma Helle - Commentor A/S
    Monday, February 21, 2011 12:46 PM
  • But it will be some kind of loop, I will actually pass to DialogBox itself as a parent. Anyway WinMain executed before WM_INITDIALOG, so NULL always will be passed to DialogBox.

    I searched PPC WM5 examples and i found some win32(vc++) samples that also not shown in the running tasks list, for example CalendarView...

    Monday, February 21, 2011 2:51 PM
  • I have this old post on how to enumerate running apps from C#. 

    http://christian-helle.blogspot.com/2009/09/how-to-enumerate-running-programs-in.html

     

    Although not directly relevant, I tried to simulate how the "Running tasks" window works in the control panel of Windows Mobile. What I did in that app was enumerate the top level windows and display all the apps that whose main window has a caption. This is probably how the HTC running app list is implemented as well. Try to set a caption to your main window and set your modal dialog to use your main window as its owner

     


    Christian Resma Helle - Commentor A/S
    Monday, February 21, 2011 9:10 PM
  • Can you be more specific, my modal dialog creating main window and it have no parent because it is main window. I sure that i missing single line of code which make a difference, but the problem that i don't no how htc task manager works and what exactly it needs to include program in it's list.  
    Tuesday, February 22, 2011 12:45 PM
  • If you go to Settings->System->Task Manager does your application appear there as an "Application"?
    If it does, then the HTC app may be filtering on registered window classes. Just for giggles, try calling RegisterClass:

    ATOM MyRegisterClass(HINSTANCE hInstance, LPTSTR szWindowClass)
    {
      WNDCLASS wc;
    
      wc.style     = CS_HREDRAW | CS_VREDRAW;
      wc.lpfnWndProc  = WndProc;
      wc.cbClsExtra  = 0;
      wc.cbWndExtra  = 0;
      wc.hInstance   = hInstance;
      wc.hIcon     = LoadIcon(hInstance, MAKEINTRESOURCE(IDD_MAIN));
      wc.hCursor    = 0;
      wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
      wc.lpszMenuName = 0;
      wc.lpszClassName = szWindowClass;
    
      return RegisterClass(&wc);
    }
    -PaulH
    • Marked as answer by Bin-ze Zhao Monday, February 28, 2011 11:50 AM
    Wednesday, February 23, 2011 7:31 PM