Précédent   Forum du club des développeurs et IT Pro > C et C++ > C > Bibliothèques, systèmes et outils
Bibliothèques, systèmes et outils Forum d'entraide sur les bibliothèques, la programmation système et les outils en C
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 13/01/2012, 16h02   #1
beavis6511
Candidat au titre de Membre du Club
 
Inscription : juin 2004
Messages : 46
Détails du profil
Informations forums :
Inscription : juin 2004
Messages : 46
Points : 14
Points : 14
Par défaut removeTitle et GetLastError

Bonjour,

je rencontre un problème avec la fonction SetWindowLong() quand je veux enlever la barre de titre de certaines fenêtres.
Sur certain PC (de mon entreprise) la fonction marche, sur certain ça ne marche pas.
J'ai ajouté dans le code un GetLastError() histoire de cibler le problème mais j'ai toujours 0 comme erreur (que le SetWindowLong() marche ou pas)

J'appelle mon .exe (généré avec VisuelStudio) depuis un .bat avec 2 paramètres (ex: removeTitle.exe DU1 RESIZE)

Ma question est: pourquoi j'ai toujours 0 en code erreur et pourquoi le SetWindowLong() marche sur certain pc et pas sur d'autre.

Voici mon code:
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 
#include <stdio.h>
#include <windows.h>
 
// Programme permettant de supprimer la barre de titre 
 
int Resizable = FALSE;
 
int main(int argc, char *argv[], char *envp[])
{
	char   cWindowName[256];
	HWND   hWindow;
	LONG   current_style, new_style;
 
	DWORD style;
 
	if (argc < 2)
	{
		printf("Usage : %s titre\n", argv[0]);
		return (0);
	}
 
	strcpy(cWindowName, argv[1]);
 
	if (argc == 3)
	{
		if (strcmp (argv[2], "RESIZE") == 0)
			Resizable = TRUE;
		else
			Resizable = FALSE;
	}
	else
	{
		Resizable = FALSE;
	}
 
	hWindow = FindWindow(NULL, cWindowName);
 
	if (hWindow)
	{
		printf("Found window %s\n", cWindowName);
		current_style = GetWindowLong (hWindow, GWL_STYLE);
 
		printf("Current style of the window = %x\n", current_style);
		// Suppression titre fenetre seulement
		if (Resizable)
			new_style = WS_VISIBLE | WS_DLGFRAME | WS_CLIPSIBLINGS | WS_THICKFRAME;
		else
			new_style = WS_VISIBLE | WS_DLGFRAME | WS_CLIPSIBLINGS;
 
		style = SetWindowLong(hWindow, GWL_STYLE, new_style);
		printf("GetLastError=%u\n", GetLastError());
		printf("Send new style to the window = %x\n", new_style);
	}
	else
	{
		printf("Error, window %s not found ...\n", cWindowName);
	}
}
beavis6511 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/01/2012, 18h00   #2
beavis6511
Candidat au titre de Membre du Club
 
Inscription : juin 2004
Messages : 46
Détails du profil
Informations forums :
Inscription : juin 2004
Messages : 46
Points : 14
Points : 14
c'est bon, j'ai rajouté
SetWindowPos(hWindow, NULL, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
beavis6511 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Cette discussion est résolue.
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 14h53.


 
 
 
 
Partenaires

Hébergement Web