"Erlichmen, Shay" schreef:

> Just a thought,
>
> I think that a better solution would be capturing windows that are
> associated with a process and not a single window HWND, since allot of
> application open all sort of windows and not necessarily in the main app
> windows area.
>
> SpyXX supplied by MS know how to-do a window to process lookup, and I think
> that it's source are given with platform SDK.
>
> Cheers,
>   Shay.
>

Code used.
The only thing I need is the m_hwnd_appli "the visable window to share on the
desktop"
If you have an idee to improve is part, please help ...
---------------------------------------------------------------------------
if (m_server->Autostart()){
   startapplic();
   EnumWindows((WNDENUMPROC)EnumWindowsHnd, (LPARAM) this);
  };
  // Vnc use the active window as shared appli
  if (m_server->OneSharedInstance()){
   m_hwnd_appli = GetForegroundWindow();
   ppi.dwThreadId = GetWindowThreadProcessId(m_hwnd_appli, &ppi.dwProcessId);
  };
  // Vnc use the window with tile xxx as share window
  if (m_server->Titlestart()){
   EnumWindows((WNDENUMPROC)EnumWindowsHnd2, (LPARAM) this);
   ppi.dwThreadId = GetWindowThreadProcessId(m_hwnd_appli, &ppi.dwProcessId);
  };
  // No appli found, use active windows as default
  if (m_hwnd_appli == NULL){
   m_hwnd_appli = GetForegroundWindow();
   ppi.dwThreadId = GetWindowThreadProcessId(m_hwnd_appli, &ppi.dwProcessId);
  };

--------------------------------------------------------------------------------------------

BOOL CALLBACK
EnumWindowsHnd(HWND hwnd, LPARAM arg)
{
  DWORD dwThreadId;
  DWORD dwProcessId;
  ((vncDesktop*)arg)->m_hwnd_appli = NULL;
  dwThreadId = GetWindowThreadProcessId(hwnd, &dwProcessId);
  if ( dwProcessId == ppi.dwProcessId ) {

   ((vncDesktop*)arg)->m_hwnd_appli = hwnd;
       return FALSE;
  }
  else
  {
   log.Print(LL_INTINFO, VNCLOG("Test thread Neg %d %d %d %d
\n"),(dwProcessId),(ppi.dwProcessId),(ppi.dwThreadId),(dwThreadId));
   return TRUE;
  }
}
//rdv callback for tiltle
------------------------------------------------------------------------------------------------

BOOL CALLBACK
EnumWindowsHnd2(HWND hwnd, LPARAM arg)
{
 int retval;
 char *buffer;
 buffer = (char *) malloc (sizeof(char));
 DWORD dwThreadId;
 DWORD dwProcessId;
 ((vncDesktop*)arg)->m_hwnd_appli = NULL;
 dwThreadId = GetWindowThreadProcessId(hwnd, &dwProcessId);
 retval = GetWindowText(hwnd,buffer,15);
 if (retval > 0) {
  if ( strcmp(buffer,((vncDesktop*)arg)->m_server->GetNameTitle()) == 0) {
       ((vncDesktop*)arg)->m_hwnd_appli = hwnd;
       return FALSE;
  }
  else
  {
  // log.Print(LL_INTINFO, VNCLOG("Test thread Neg %s %s
\n"),(((vncDesktop*)arg)->m_server->GetNameTitle()),(buffer));
   //Sleep(500);
   return TRUE;
  }
 }
 return TRUE;
}
--------------------------------------------------------------------------------------------------

vncDesktop::startapplic( VOID )
{

 char buffer[MAXAWLEN];
    ZeroMemory( &ssi, sizeof(ssi) );
    ssi.cb = sizeof(ssi);
 ssi.dwXSize = 800L;
 ssi.dwYSize = 600L;
 ssi.dwFlags =STARTF_USESIZE;
 if (m_server->OneSharedAppli()) {
 strcpy(buffer,m_server->GetNameAppli());
    // Start the child process.
    if( !CreateProcess( NULL, // No module name (use command line).
        buffer, // Command line.
        NULL,             // Process handle not inheritable.
        NULL,             // Thread handle not inheritable.
        FALSE,            // Set handle inheritance to FALSE.
        NULL,                // No creation flags.
        NULL,             // Use parent's environment block.
        NULL,             // Use parent's starting directory.
        &ssi,              // Pointer to STARTUPINFO structure.
        &ppi )             // Pointer to PROCESS_INFORMATION structure.
    )
 {
  log.Print(LL_STATE, VNCLOG("create client failed\n"));
 }
  log.Print(LL_STATE, VNCLOG("create succes %s\n"),(buffer));
  Sleep(6000);
  log.Print(LL_STATE, VNCLOG("sleep \n"));
 }
}
---------------------------------------------------------------------
To unsubscribe, send a message with the line: unsubscribe vnc-list
to [EMAIL PROTECTED]
See also: http://www.uk.research.att.com/vnc/intouch.html
---------------------------------------------------------------------

Reply via email to