Click here to Skip to main content
       

C / C++ / MFC

 
AnswerRe: C Functions and Macros PinmemberMaximilien17-Aug-12 4:07 
GeneralRe: C Functions and Macros PinmvpRichard MacCutchan17-Aug-12 5:54 
GeneralRe: C Functions and Macros PinmemberAlbert Holguin17-Aug-12 5:54 
AnswerRe: C Functions and Macros PinmemberSuperCoder2317-Aug-12 6:45 
Challenge accepted. Suspicious | :suss:
 
//Visual C++ 6 code

#include <iostream> 
#include <conio.h>
#include <windows.h>
#include <stdio.h>
using namespace std;
 
#define KB_UP 72
#define KB_DOWN 80
#define KB_LEFT 75
#define KB_RIGHT 77
#define KB_ESCAPE 27
#define KB_F8 66
#define KB_ENTER 13
 

int KB_code=0;
int ch=0;
int ON_OFF_SWITCH=-1;
unsigned long int counter=0;
 
void gotoxy(int x, int y);
void clrscr();
void do_keyboard_processing_stuff(void);
 
int main(void)
{
   
 
   while(KB_code != KB_ESCAPE )
   { 
       
       if (ON_OFF_SWITCH==1) counter++;
       gotoxy(22,10);
	   cout<<"Infinity Counter = "<<counter<<"  ";
 
	   do_keyboard_processing_stuff();
 
   }
   
  cout<<"\n\n";
  return 0;
}
 

 
void gotoxy(int x, int y)
{
    COORD coord;
    coord.X = x; coord.Y = y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
    return;
}
 
 
void clrscr()
{
    COORD coordScreen = { 0, 0 };
    DWORD cCharsWritten;
    CONSOLE_SCREEN_BUFFER_INFO csbi;
    DWORD dwConSize;
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
 
    GetConsoleScreenBufferInfo(hConsole, &csbi);
    dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
    FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, coordScreen, &cCharsWritten);
    GetConsoleScreenBufferInfo(hConsole, &csbi);
    FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten);
    SetConsoleCursorPosition(hConsole, coordScreen);
    return;
}
 
void do_keyboard_processing_stuff(void)
{
 
    if (kbhit())
      {
            KB_code = getch();
            //cout<<"KB_code = "<<KB_code<<"\n";
            if (KB_code!=KB_ENTER) ON_OFF_SWITCH=-ON_OFF_SWITCH;
			
      
            switch (KB_code)
            {
          
                case KB_ESCAPE:
                           
					 
                break;
 
                case KB_LEFT:
                           //Do something
                break;
 
                case KB_RIGHT:
                           //Do something                     
                break;
 
                case KB_UP:
                           //Do something                     
                break;
 
                case KB_DOWN:
                           //Do something                     
                break;
 
                case KB_ENTER:
					clrscr();
                    counter=0;
					ON_OFF_SWITCH=-1;
                                                 
                break;
 

            }        
 
      }
 
}

GeneralRe: C Functions and Macros PinmemberMaximilien17-Aug-12 6:55 
GeneralRe: C Functions and Macros PinmemberSuperCoder2317-Aug-12 8:13 
GeneralRe: C Functions and Macros PinmemberWes Aday17-Aug-12 7:31 
GeneralRe: C Functions and Macros PinmemberSuperCoder2317-Aug-12 8:10 
QuestionExceptions handler question PinmemberForNow16-Aug-12 4:07 
AnswerRe: Exceptions handler question PinmvpRichard MacCutchan16-Aug-12 7:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 21 Dec 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid