|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
[DEV-C++] APPLICATION CONSOLE : REMÉDIER À L'ABSENCE DE CERTAINES FONCTIONS CONIO : CLRSCR, GOTOXY, TEXTCOLOR, PUTTEXT, GETTEXT, DELLINE, INSLINE, ...
Information sur la source
Description
J'ai réécrit la grande majorité des fonctions conio à l'aide des fonctions disponibles sous Dev-C++ (compilateur : mingw) (bibliothèques wincon, winbase et windows). On trouve assez aisément sur internet différentes sources correspondant à clrscr, gotoxy ou encore wherex. Mais, il m'a fallu écrire les sources pour remplacer des fonctions telles que delline, insline, getetxte, puttext, cgets, cputs ou encore clreol... Je n'ai pas réécrit les fonctions kbhit, putch et ungetch, car Dev-C++ possède une bibliothèque conio dans laquelle ces fonctions sont codées. Par contre, bien qu'elles fassent parties des bibliothèques fournies avec le compilateur mingw, j'ai modifié les fonctions getch et getche qui provoquaient un dysfonctionnement lorsqu'elles étaients suivi par un gets... Pour utiliser ces fonctions, il suffit de copier les fichiers myconio.cpp et myconio.h dans le répertoire include (de Dev-C++) et de remplacer la ligne #include<conio.h> par #include<myconio.h>.
Source
- // EXTRAIT du fichier myconio.h --- IL FAUT TELECHARGER myconio.zip ---
-
- // Nom du fichier : myconio.h
- // Auteur : prof.geii37@laposte.net
- // Version : Novembre 2004
- // Objectif : remédier à l'absence de certaines fonctions conio sous DevC++
-
- #ifndef _MYCONIO_H_
- #define _MYCONIO_H_
-
- #include <conio.h>
- #include <stdio.h>
- #include <stdlib.h>
-
- #include <stdarg.h>
- #include <windef.h>
- #include <winbase.h>
- #include <wincon.h>
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- struct text_info {
- unsigned char winleft;
- unsigned char wintop;
- unsigned char winright;
- unsigned char winbottom;
- unsigned char attribute;
- unsigned char normattr;
- unsigned char currmode;
- unsigned char screenheight;
- unsigned char screenwidth;
- unsigned char curx;
- unsigned char cury;
- };
-
- enum COLORS { BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY,
- DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED,
- LIGHTMAGENTA, YELLOW, WHITE } ;
-
- #define _NOCURSOR 0
- #define _SOLIDCURSOR 1
- #define _NORMALCURSOR 2
- #define C40 1
-
- void _setcursortype(int type);
- char *cgets(char *str);
- void clreol();
- void clrscr();
- void delline();
- #define cprintf printf
- #define cscanf scanf
- int cputs(const char *str) ;
- int Gettext(int left, int top, int right, int bottom, void *destin) ;
- #define gettext Gettext
- void gettextinfo(struct text_info *_r);
- int MYgetch(void) ;
- int MYgetche(void) ;
- void gotoxy(int x, int y);
- void highvideo();
- void insline();
- void lowvideo();
- int movetext(int left, int top, int right, int bottom, int destleft, int desttop);
- void normvideo();
- int puttext(int left, int top, int right, int bottom, void *source);
- void textattr(int _attr);
- void textbackground(int _color);
- void textcolor(int _color);
- int wherex();
- int wherey();
- void MYclrwin(int left, int top, int right, int bottom);
- void MYwindow(int left, int top, int right, int bottom);
-
- #ifdef __cplusplus
- }
- #endif
-
- #include <myconio.cpp>
- #endif //_MYCONIO_H_
// EXTRAIT du fichier myconio.h --- IL FAUT TELECHARGER myconio.zip ---
// Nom du fichier : myconio.h
// Auteur : prof.geii37@laposte.net
// Version : Novembre 2004
// Objectif : remédier à l'absence de certaines fonctions conio sous DevC++
#ifndef _MYCONIO_H_
#define _MYCONIO_H_
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <wincon.h>
#ifdef __cplusplus
extern "C" {
#endif
struct text_info {
unsigned char winleft;
unsigned char wintop;
unsigned char winright;
unsigned char winbottom;
unsigned char attribute;
unsigned char normattr;
unsigned char currmode;
unsigned char screenheight;
unsigned char screenwidth;
unsigned char curx;
unsigned char cury;
};
enum COLORS { BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY,
DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED,
LIGHTMAGENTA, YELLOW, WHITE } ;
#define _NOCURSOR 0
#define _SOLIDCURSOR 1
#define _NORMALCURSOR 2
#define C40 1
void _setcursortype(int type);
char *cgets(char *str);
void clreol();
void clrscr();
void delline();
#define cprintf printf
#define cscanf scanf
int cputs(const char *str) ;
int Gettext(int left, int top, int right, int bottom, void *destin) ;
#define gettext Gettext
void gettextinfo(struct text_info *_r);
int MYgetch(void) ;
int MYgetche(void) ;
void gotoxy(int x, int y);
void highvideo();
void insline();
void lowvideo();
int movetext(int left, int top, int right, int bottom, int destleft, int desttop);
void normvideo();
int puttext(int left, int top, int right, int bottom, void *source);
void textattr(int _attr);
void textbackground(int _color);
void textcolor(int _color);
int wherex();
int wherey();
void MYclrwin(int left, int top, int right, int bottom);
void MYwindow(int left, int top, int right, int bottom);
#ifdef __cplusplus
}
#endif
#include <myconio.cpp>
#endif //_MYCONIO_H_
Conclusion
Par conséquent, je vous invite à tester cet environnement (Dev-C++ si vous ne le connaissez pas) qui est assez agréable à utiliser : http://www.bloodshed.net/devcpp.html Mes fichiers sources sont assez peu documentés. Pour obtenir un programme exemple ou plus d'information sur une fonction donnée adressez-moi un message...
Fichier Zip
Pour les "Membres Club", vous pouvez télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !
Télécharger le zip
Historique
- 06 décembre 2004 18:56:17 :
- Corrections orthographiques mineurs !
Sources de la même categorie
Commentaires et avis
|
|