accès aux groupes de discussion, consultation et publication d'articles, recherche de "newsgroups"...
membres, identifiez-vous
é-mail Mot de passe
nouveau ? mot de passe oublié ?
Chargement... Chargement en cours...

Groupes français belges canadiens suisses internationaux Nétiquette
Échangez opinions et commentaires dans les forums de discussion.

Re: API win32 et gestion d'applications (background/foreground)

 [  Nouvelle Discussion Nouvelle discussion  |  Répondre au groupe Répondre au groupe  |  fr.comp.os.ms-windows.programmation ] 

Retour : Accueil du site fr comp os ms-windows programmation   charte stats de ce groupe


  Sujet:   Re: API win32 et gestion d'applications (background/foreground)  
 De: casto...@club-internet.fr (Christian ASTOR)
 Groupes: fr.comp.os.ms-windows.programmation
 Organisation: http://groups.google.com
 Date: 23. Apr 2008, 05:39:00
 References: 1
On 22 avr, 18:36, Altaïr <altair_...@hotmail.com> wrote:
> > SetForegroundWindow() a des limitations à contourner (KB97925 :
> > AttachThreadInput(), SPI_SETFOREGROUNDLOCKTIMEOUT)
> > Sinon, SwitchToThisWindow() marche généralement.
>
> Merci pour ta réponse Christian.
>
> A propos de AttachThreadInput():
> Jusqu'à présent j'obtenais le HWND de la seconde application à son
> lancement par une fonction Labwindows. Mais je me suis rendu compte
> qu'en appliquant GetWindowThreadProcessId() avec cette valeur,
> j'obtenais le même Id que pour ma première application...

J'ai du mal à comprendre...
Si je lance une autre appli, comme Notepad par ex :
ShellExecute(NULL, "", "notepad", "", "", SW_SHOW);

Et si je fais :
HWND hWndNotepad = FindWindow("Notepad",NULL );
DWORD dwProcessID;
DWORD dwThreadId = GetWindowThreadProcessId(hWndNotepad,
&dwProcessID);

dwThreadId ne peut pas être égal à GetCurrentThreadId()

Si on veut mettre au premier plan Notepad, on peut faire :

SwitchToWindow(hWndNotepad);

avec :

void SwitchToWindow(HWND hWnd)
{
	if (IsIconic(hWnd))
		ShowWindow(hWnd, SW_RESTORE);
	HWND hWndLastActivePopup = GetLastActivePopup(hWnd);
	void (FAR STDAPICALLTYPE * pSTTW)(HWND hWnd, BOOL bAltTab);
	HINSTANCE hInst = LoadLibrary("USER32.DLL");
	if (hInst)
	{
		(FARPROC&)pSTTW = GetProcAddress(hInst, "SwitchToThisWindow");
		if (pSTTW != NULL)
			pSTTW(hWndLastActivePopup, TRUE);
		FreeLibrary(hInst);
	}
}


DateSujet  Auteur
01.01.
o 
Groups Explorer contact votre avis comment ça marche? rechercher un groupe suggérer un groupe abuse accueil du site   Imprimer cette page   Envoyer cette page à un(e) ami(e)