Click here to Skip to main content
11,709,581 members (55,073 online)

C / C++ / MFC

 
GeneralRe: C Functions and Macros Pin
roza12317-Aug-12 2:03
memberroza12317-Aug-12 2:03 
GeneralRe: C Functions and Macros Pin
Richard MacCutchan17-Aug-12 2:22
mvpRichard MacCutchan17-Aug-12 2:22 
AnswerRe: C Functions and Macros Pin
Malli_S17-Aug-12 2:41
memberMalli_S17-Aug-12 2:41 
QuestionRe: C Functions and Macros Pin
DavidCrow17-Aug-12 2:43
memberDavidCrow17-Aug-12 2:43 
AnswerRe: C Functions and Macros Pin
Maximilien17-Aug-12 3:07
memberMaximilien17-Aug-12 3:07 
GeneralRe: C Functions and Macros Pin
Richard MacCutchan17-Aug-12 4:54
mvpRichard MacCutchan17-Aug-12 4:54 
GeneralRe: C Functions and Macros Pin
Albert Holguin17-Aug-12 4:54
memberAlbert Holguin17-Aug-12 4:54 
AnswerRe: C Functions and Macros Pin
SuperCoder2317-Aug-12 5:45
memberSuperCoder2317-Aug-12 5: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 5:55
memberMaximilien17-Aug-12 5:55 
GeneralRe: C Functions and Macros Pin
SuperCoder2317-Aug-12 7:13
memberSuperCoder2317-Aug-12 7:13 
GeneralRe: C Functions and Macros Pin
Wes Aday17-Aug-12 6:31
memberWes Aday17-Aug-12 6:31 
GeneralRe: C Functions and Macros Pin
SuperCoder2317-Aug-12 7:10
memberSuperCoder2317-Aug-12 7:10 
QuestionExceptions handler question Pin
ForNow16-Aug-12 3:07
memberForNow16-Aug-12 3:07 
AnswerRe: Exceptions handler question Pin
Richard MacCutchan16-Aug-12 6:59
mvpRichard MacCutchan16-Aug-12 6:59 
GeneralRe: Exceptions handler question Pin
ForNow17-Aug-12 3:44
memberForNow17-Aug-12 3:44 
GeneralRe: Exceptions handler question Pin
Richard MacCutchan17-Aug-12 4:53
mvpRichard MacCutchan17-Aug-12 4:53 
GeneralRe: Exceptions handler question Pin
Eugen Podsypalnikov17-Aug-12 5:01
memberEugen Podsypalnikov17-Aug-12 5:01 
AnswerRe: Exceptions handler question Pin
JackDingler16-Aug-12 7:59
memberJackDingler16-Aug-12 7:59 
QuestionCreateInstance(__uuidof(MYClass)); Pin
KeithF16-Aug-12 2:23
memberKeithF16-Aug-12 2:23 
AnswerRe: CreateInstance(__uuidof(MYClass)); Pin
KeithF20-Aug-12 6:06
memberKeithF20-Aug-12 6:06 
QuestionTreeCtrl edge not drawing when resized as part of CControlBar Pin
Phil Outram16-Aug-12 0:48
memberPhil Outram16-Aug-12 0:48 
AnswerSOLUTION!! Pin
Phil Outram16-Aug-12 2:06
memberPhil Outram16-Aug-12 2:06 
QuestionEnumprocessmodule fails Pin
Member 450808315-Aug-12 23:35
memberMember 450808315-Aug-12 23:35 
AnswerRe: Enumprocessmodule fails Pin
pasztorpisti15-Aug-12 23:39
memberpasztorpisti15-Aug-12 23:39 
AnswerRe: Enumprocessmodule fails Pin
DavidCrow16-Aug-12 3:59
memberDavidCrow16-Aug-12 3: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
Web01 | 2.8.150819.1 | Last Updated 28 Aug 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid