Click here to Skip to main content
12,748,244 members (41,479 online)

C / C++ / MFC

 
GeneralRe: C Functions and Macros Pin
roza12317-Aug-12 3:03
memberroza12317-Aug-12 3:03 
GeneralRe: C Functions and Macros Pin
Richard MacCutchan17-Aug-12 3:22
mvpRichard MacCutchan17-Aug-12 3:22 
AnswerRe: C Functions and Macros Pin
Malli_S17-Aug-12 3:41
memberMalli_S17-Aug-12 3:41 
QuestionRe: C Functions and Macros Pin
DavidCrow17-Aug-12 3:43
memberDavidCrow17-Aug-12 3:43 
AnswerRe: C Functions and Macros Pin
Maximilien17-Aug-12 4:07
memberMaximilien17-Aug-12 4:07 
GeneralRe: C Functions and Macros Pin
Richard MacCutchan17-Aug-12 5:54
mvpRichard MacCutchan17-Aug-12 5:54 
GeneralRe: C Functions and Macros Pin
Albert Holguin17-Aug-12 5:54
memberAlbert Holguin17-Aug-12 5:54 
AnswerRe: C Functions and Macros Pin
SuperCoder2317-Aug-12 6:45
memberSuperCoder2317-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 Pin
Maximilien17-Aug-12 6:55
memberMaximilien17-Aug-12 6:55 
GeneralRe: C Functions and Macros Pin
SuperCoder2317-Aug-12 8:13
memberSuperCoder2317-Aug-12 8:13 
GeneralRe: C Functions and Macros Pin
Wes Aday17-Aug-12 7:31
memberWes Aday17-Aug-12 7:31 
GeneralRe: C Functions and Macros Pin
SuperCoder2317-Aug-12 8:10
memberSuperCoder2317-Aug-12 8:10 
QuestionExceptions handler question Pin
ForNow16-Aug-12 4:07
memberForNow16-Aug-12 4:07 
AnswerRe: Exceptions handler question Pin
Richard MacCutchan16-Aug-12 7:59
mvpRichard MacCutchan16-Aug-12 7:59 
GeneralRe: Exceptions handler question Pin
ForNow17-Aug-12 4:44
memberForNow17-Aug-12 4:44 
GeneralRe: Exceptions handler question Pin
Richard MacCutchan17-Aug-12 5:53
mvpRichard MacCutchan17-Aug-12 5:53 
GeneralRe: Exceptions handler question Pin
Eugen Podsypalnikov17-Aug-12 6:01
memberEugen Podsypalnikov17-Aug-12 6:01 
AnswerRe: Exceptions handler question Pin
JackDingler16-Aug-12 8:59
memberJackDingler16-Aug-12 8:59 
QuestionCreateInstance(__uuidof(MYClass)); Pin
KeithF16-Aug-12 3:23
memberKeithF16-Aug-12 3:23 
AnswerRe: CreateInstance(__uuidof(MYClass)); Pin
KeithF20-Aug-12 7:06
memberKeithF20-Aug-12 7:06 
QuestionTreeCtrl edge not drawing when resized as part of CControlBar Pin
Phil Outram16-Aug-12 1:48
memberPhil Outram16-Aug-12 1:48 
AnswerSOLUTION!! Pin
Phil Outram16-Aug-12 3:06
memberPhil Outram16-Aug-12 3:06 
QuestionEnumprocessmodule fails Pin
Member 450808316-Aug-12 0:35
memberMember 450808316-Aug-12 0:35 
AnswerRe: Enumprocessmodule fails Pin
pasztorpisti16-Aug-12 0:39
memberpasztorpisti16-Aug-12 0:39 
AnswerRe: Enumprocessmodule fails Pin
DavidCrow16-Aug-12 4:59
memberDavidCrow16-Aug-12 4:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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
Web01 | 2.8.170215.1 | Last Updated 17 Feb 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid