IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Bibliothèques, systèmes et outils C Discussion :

removeTitle et GetLastError


Sujet :

Bibliothèques, systèmes et outils C

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Juin 2004
    Messages
    46
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2004
    Messages : 46
    Points : 35
    Points
    35
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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);
    	}
    }

  2. #2
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Juin 2004
    Messages
    46
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2004
    Messages : 46
    Points : 35
    Points
    35
    Par défaut
    c'est bon, j'ai rajouté
    SetWindowPos(hWindow, NULL, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 4
    Dernier message: 08/09/2008, 12h06
  2. Valeur retournée de GetLastError = 0 ?
    Par courantjet dans le forum Windows
    Réponses: 2
    Dernier message: 30/07/2007, 11h49
  3. [MFC][C++] errno et/ou GetLastError ?
    Par matazz dans le forum MFC
    Réponses: 3
    Dernier message: 12/05/2005, 14h50
  4. Fonction GetLastError()
    Par annedjomo dans le forum MFC
    Réponses: 14
    Dernier message: 09/03/2005, 10h13
  5. GetLastError()
    Par elodie escande dans le forum MFC
    Réponses: 21
    Dernier message: 16/01/2004, 17h23

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo