Vet nån hur man kan använda sig utav conio.h:s gotoxy()-funktioner för att placera text i en dos-applikation? Det fungerar bra i Borland, men inte i Visual och det är Visual jag helst använder.
Visual C++ och gotoxy()...
1 svar · 413 visningar · startad av Engine^
Använd dig av följande följande header fil:
<font size="1" face="Verdana, Arial, Helvetica, sans-serif">Kod:<font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#666600">
#ifndef CONSOL_H
#define CONSOL_H
#include <windows.h>
#define SCROLL_POS 24
void Init_Consol(void);
inline void Set_Color(int fcolor, int bcolor);
inline void DrawString(int x, int y, char* string);
inline void Clear_Screen(void);
CONSOLE_SCREEN_BUFFER_INFO con_info;
HANDLE hconsole;
void Init_Graphics(void)
{
COORD console_size = {80,25};
srand((unsigned)time(NULL));
hconsole=CreateFile("CONOUT$",GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
0L, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0L);
SetConsoleScreenBufferSize(hconsole,console_size);
GetConsoleScreenBufferInfo(hconsole,&con_info);
}
inline void Set_Color(int fcolor, int bcolor=0)
{
SetConsoleTextAttribute(hconsole,(WORD)((bcolor << 4) | fcolor));
}
inline void Draw_String(int x, int y, char* string)
{
COORD cursor_pos;
cursor_pos.X = x;
cursor_pos.Y = y;
SetConsoleCursorPosition(hconsole,cursor_pos);
printf("%s",string);
}
inline void Clear_Screen(void)
{
Set_Color(15,0);
for(int index=0; index<=25; index++)
{
Draw_String(0, SCROLL_POS, "\n");
}
}
#endif
Innehåller functioner som man kan använda vid utveckling av consol program.
/Nisse
------------------
www.phpfunctions.com