Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Paramètres de la console en C

16 réponses
Avatar
vive-gauthier
Bonjour a vous tous!
J'aimerais savoir si il est possible de changer la police et sa
dimension avec un programme.
De la m=EAme mani=E8re que :
system("title ");
system("mode con cols=3D120");

Voila, merci d'avance.

6 réponses

1 2
Avatar
vive-gauthier
On 19 juil, 11:16, Christian ASTOR wrote:
wrote:
> 1>.main.c(54) : warning C4013: 'GetNumberOfConsoleFonts' non défini
> (e) ; extern retournant int pris par défaut

Il faut les appeler dynamiquement (GetProcAddress())
(il ya aussi SetCurrentConsoleFontEx() pour Vista)
Un exemple =>

#include <windows.h>
#include <iostream>
#include <tchar.h>
#include <conio.h>

typedef BOOL (WINAPI*SCF)
(
  IN HANDLE hConsoleOutput,
  IN DWORD nFont
  );
typedef DWORD  (WINAPI*GNOCF)(void) ;
typedef  DWORD (WINAPI*GCFI)
(
    IN HANDLE hConsoleOutput,
    IN BOOL bMaxSize,
    IN DWORD dwLength,
    OUT PCONSOLE_FONT_INFO lpConsoleFontInfo
    ) ;

int _tmain(int argc, _TCHAR* argv[])
{
        HMODULE hDLL = LoadLibrary(TEXT("kernel32.dll"));
        SCF pSetConsoleFont = (SCF)GetProcAddress(hDLL, "SetCon soleFont");
        GNOCF pGetNumberOfConsoleFonts = (GNOCF)GetProcAddress( hDLL,
"GetNumberOfConsoleFonts");
        GCFI pGetConsoleFontInfo = (GCFI)GetProcAddress(hDLL,
"GetConsoleFontInfo");
        if (!pSetConsoleFont || !pGetNumberOfConsoleFonts  || ! pGetConsoleFontInfo)
         return 1;
        HANDLE hStdOut;
        hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
        DWORD dwNbFonts = pGetNumberOfConsoleFonts();
        printf ("Number of Fonts = %drn", dwNbFonts);
        CONSOLE_FONT_INFO cfi[50];
        DWORD dwFonts = pGetConsoleFontInfo(hStdOut, FALSE, dwN bFonts, cfi) ;
        for (int i = 0; i<dwFonts; i++)
        {
                pSetConsoleFont(hStdOut, i);
                printf ("Font number %d - X=%d-Y=%dr n", i, cfi[i].dwFontSize.X,
cfi[i].dwFontSize.Y);
                getch();
        }
        return 0;

}




Voila, j'ai plus que deux fonctions non définies :
1>main.obj : error LNK2001: symbole externe non résolu
_pGetConsoleFontInfo
1>main.obj : error LNK2001: symbole externe non résolu
_pGetNumberOfConsoleFonts

Sinon, je suis sous windows 7

Merci beaucoup pour votre aide
Avatar
Christian ASTOR
wrote:

Voila, j'ai plus que deux fonctions non définies :
1>main.obj : error LNK2001: symbole externe non résolu
_pGetConsoleFontInfo
1>main.obj : error LNK2001: symbole externe non résolu
_pGetNumberOfConsoleFonts



Ells sont définies dans l'exemple ci-dessus (typedef)
Avatar
vive-gauthier
On 19 juil, 12:39, Christian ASTOR wrote:
wrote:
> Voila, j'ai plus que deux fonctions non définies :
> 1>main.obj : error LNK2001: symbole externe non résolu
> _pGetConsoleFontInfo
> 1>main.obj : error LNK2001: symbole externe non résolu
> _pGetNumberOfConsoleFonts

Ells sont définies dans l'exemple ci-dessus (typedef)



Oui, ben pourtant :

/*Copyright (C) 2009 MASSART GAUTHIER

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/

#ifdef WIN32
#include <winsock2.h>
#include <windows.h>
#include <Wincon.h>
#include <tchar.h>
#include <conio.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <CSLP/CSLP.h>
#include "fonctions.h"
#include "utilitaires.h"
#include "menus.h"
#include "gestionnaireSon.h"

CSLP_COLORTYPE CT = CYAN|LIGHT, CTS = BLACK, CBS = CYAN|LIGHT;
unsigned char volume = 150;
char prenom[100];
long toucheHaut = '5', toucheBas = '2', toucheDroite = '3',
toucheGauche = '1', typeMenu = 1, ok = 0, teste = 0;
const char versionJeu[] = "VERSION 1.0.0";

typedef BOOL (WINAPI*SCF)
(
IN HANDLE hConsoleOutput,
IN DWORD nFont
);
typedef DWORD (WINAPI*GNOCF)(void) ;
typedef DWORD (WINAPI*GCFI)
(
IN HANDLE hConsoleOutput,
IN BOOL bMaxSize,
IN DWORD dwLength,
OUT PCONSOLE_FONT_INFO lpConsoleFontInfo
);

int _tmain(int argc, _TCHAR* argv[])
{
int i = 0;
long continuer = 1, iBienvenu = 0;
char *contenuMenu = "*Jeux :nJeu du plus ou moinsnJeu du pendunJeu
du pousse caissesnJeu du morpionnJeu du snakenJeu du chifuminJeu
des tours de hanoinJeu du bantumin*Autres :nCrx82"
"ditsnHistoriquesnOptionsnQuittern", *contenuTitre = "MENU
PRINCIPAL";

#ifdef WIN32
HANDLE hStdOut;
DWORD dwNbFonts = pGetNumberOfConsoleFonts();
CONSOLE_FONT_INFO cfi[50];
DWORD dwFonts = pGetConsoleFontInfo(hStdOut, FALSE, dwNbFonts, cfi) ;
HMODULE hDLL = LoadLibrary(TEXT("kernel32.dll"));
SCF pSetConsoleFont = (SCF)GetProcAddress(hDLL, "SetConsoleFont");
GNOCF pGetNumberOfConsoleFonts = (GNOCF)GetProcAddress(hDLL,
"GetNumberOfConsoleFonts");
GCFI pGetConsoleFontInfo = (GCFI)GetProcAddress(hDLL,
"GetConsoleFontInfo");
if (!pSetConsoleFont || !pGetNumberOfConsoleFonts || !
pGetConsoleFontInfo)
return 1;

hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);

printf ("Number of Fonts = %drn", dwNbFonts);


for (i<dwFonts; i++;)
{
pSetConsoleFont(hStdOut, i);
printf ("Font number %d - X=%d-Y=%drn", i, cfi[i].dwFontSize.X,
cfi[i].dwFontSize.Y);
getch();
}
system("title Les jeux indémodables V1.0.0 Alpha");
system("mode con cols0");
CSLP_ColorText(WHITE|LIGHT);
printf("Initialisation de la console : ");
CSLP_ColorText(GREEN|LIGHT);
printf("OKn");
#endif
CSLP_ColorText(WHITE|LIGHT);
printf("nLecture des configurations : ");
LireConf();
srand(time(NULL));
CSLP_ColorText(WHITE|LIGHT);
printf("nChargement des sons : ");
if(InitGestSons() == false)
{
CSLP_ColorText(RED|LIGHT);
printf(" !!n");
CSLP_Sleep(500);
}
else
{
CSLP_ColorText(GREEN|LIGHT);
printf(" OKn");
CSLP_ColorText(WHITE|LIGHT);
printf("nRx82glage du volume de la musique :");
while(ok != 1)
{
if(ChangeVolume(volume) == true)
{
ok = 1;
CSLP_ColorText(GREEN|LIGHT);
printf(" OKn");
}
else
{
teste++;
CSLP_Sleep(20);
if(teste == 10)
{
CSLP_ColorText(RED|LIGHT);
printf(" !!n");
CSLP_Sleep(500);
ok = 1;
}
}
}
}
CSLP_ColorText(WHITE|LIGHT);
printf("nnCHARGEMENT TERMINE!n");

while (continuer)
{
long choixMenu = 0;

if(iBienvenu == 0)
{
CSLP_ClearScreen();
bienvenue1();
iBienvenu++;
}
else
{
CSLP_ClearScreen();
bienvenue2();
}

choixMenu = AfficherMenuJeu(contenuMenu, contenuTitre);

switch(choixMenu)
{
case 1 : MenuPlusOuMoins(); break;
case 2 : MenuPendu(); break;
case 3 : MenuPousseCaisses(); break;
case 4 : MenuMorpion(); break;
case 5 : MenuSnake(); break;
case 6 : MenuChifumi(); break;
case 7 : MenuToursHanoi(); break;
case 8 : MenuBantumi(); break;
case 9 : credit(); break;
case 10 : historiques(); break;
case 11 : options(); break;
case 12 : quitter(); continuer = 0; break;
}
}
CloseGestSons();
CSLP_ResetColors();
}

renvoie ça :

1>Compilation en cours...
1>main.c
1>.main.c(51) : warning C4013: 'pGetNumberOfConsoleFonts' non défini
(e) ; extern retournant int pris par défaut
1>.main.c(53) : warning C4013: 'pGetConsoleFontInfo' non défini(e) ;
extern retournant int pris par défaut
1>.main.c(68) : warning C4018: '<' : incompatibilité signed/unsigned
1>.main.c(68) : warning C4552: '<' : opérateur sans effet ; opérat eur
avec effet secondaire attendu
1>.main.c(73) : warning C4996: 'getch': The POSIX name for this item
is deprecated. Instead, use the ISO C++ conformant name: _getch. See
online help for details.
1> C:Program FilesMicrosoft Visual Studio 9.0VCinclude
conio.h(145) : voir la déclaration de 'getch'
1>.main.c(85) : warning C4244: 'fonction' : conversion de 'time_t' en
'unsigned int', perte possible de données
1>.main.c(42) : warning C4100: 'argv' : paramètre formel non
référencé
1>.main.c(42) : warning C4100: 'argc' : paramètre formel non
référencé
1>c:users6jq32y9cgy3y986hdqktdocumentsvisual studio 2008projects
les indémodables1les indémodables1main.c(53) : warning C4700:
variable locale 'hStdOut' non initialisée utilisée
1>Édition des liens en cours...
1>main.obj : error LNK2019: symbole externe non résolu
_pGetConsoleFontInfo référencé dans la fonction _main
1>main.obj : error LNK2019: symbole externe non résolu
_pGetNumberOfConsoleFonts référencé dans la fonction _main
1>C:Users6jq32y9cgy3y986hdqktDocumentsVisual Studio 2008Projects
Les indémodables1DebugLes indémodables1.exe : fatal error LNK1120:
2 externes non résolus
1>Le journal de génération a été enregistré à l'emplacement "fi le://c:
Users6jq32y9cgy3y986hdqktDocumentsVisual Studio 2008ProjectsLes
indémodables1Les indémodables1DebugBuildLog.htm"
1>Les indémodables1 - 3 erreur(s), 9 avertissement(s)
========== Génération : 0 a réussi, 1 a échou é, 0 mis à jour, 0 a été
ignoré ==========
Avatar
Christian ASTOR
wrote:

1>Compilation en cours...
1>main.c
1>.main.c(51) : warning C4013: 'pGetNumberOfConsoleFonts' non défini
(e) ; extern retournant int pris par défaut
1>.main.c(53) : warning C4013: 'pGetConsoleFontInfo' non défini(e) ;
extern retournant int pris par défaut



Si tu mets la définition d'une fonction après le premier appel, c'est
plutôt normal..
Avatar
vive-gauthier
On 19 juil, 14:35, Christian ASTOR wrote:
wrote:
> 1>Compilation en cours...
> 1>main.c
> 1>.main.c(51) : warning C4013: 'pGetNumberOfConsoleFonts' non défini
> (e) ; extern retournant int pris par défaut
> 1>.main.c(53) : warning C4013: 'pGetConsoleFontInfo' non défini(e) ;
> extern retournant int pris par défaut

Si tu mets la définition d'une fonction après le premier appel, c'est
plutôt normal..



MILLE MERCIS !!
Tous fonctionne !
Je vous adore :D
Avatar
vive-gauthier
On 19 juil, 14:35, Christian ASTOR wrote:
wrote:
> 1>Compilation en cours...
> 1>main.c
> 1>.main.c(51) : warning C4013: 'pGetNumberOfConsoleFonts' non défini
> (e) ; extern retournant int pris par défaut
> 1>.main.c(53) : warning C4013: 'pGetConsoleFontInfo' non défini(e) ;
> extern retournant int pris par défaut

Si tu mets la définition d'une fonction après le premier appel, c'est
plutôt normal..



MERCI !! Ca fonctionne ^^

Sinon, il faut obligatoirement que ce code soit dans le main ?
1 2