c++ - How the access the HOME END keys in a console application
- Ed Schroder (7/7) Jan 05 2007 As the title says.....
- Walter Bright (3/10) Jan 05 2007 Download ftp://ftp.digitalmars.com/me.zip, which has example code in it
-
Bertel Brander
(45/50)
Jan 05 2007
#include
- Ed Schroder (3/3) Jan 05 2007 Got it working..... thx Bertil & Walter!
As the title says..... Under DOS I was used to get access to the HOME / END / DEL / PAGE- UP etc. keys using the _bios_keybrd(0) function. This function is not available in a console application. So how does one get access? TIA Ed
Jan 05 2007
Ed Schroder wrote:As the title says..... Under DOS I was used to get access to the HOME / END / DEL / PAGE- UP etc. keys using the _bios_keybrd(0) function. This function is not available in a console application. So how does one get access?Download ftp://ftp.digitalmars.com/me.zip, which has example code in it to do that.
Jan 05 2007
Ed Schroder skrev:As the title says..... Under DOS I was used to get access to the HOME / END / DEL / PAGE- UP etc. keys using the _bios_keybrd(0) function. This function is not available in a console application.#include <windows.h> #include <iostream> HANDLE StdIn = GetStdHandle(STD_INPUT_HANDLE); WORD GetChar() { DWORD NumEventsRead; INPUT_RECORD InputRecord; while(1) { if(!ReadConsoleInput(StdIn, &InputRecord, 1, &NumEventsRead)) return 0; if(InputRecord.EventType & KEY_EVENT && InputRecord.Event.KeyEvent.bKeyDown) { if(InputRecord.Event.KeyEvent.wVirtualKeyCode != VK_CONTROL && InputRecord.Event.KeyEvent.wVirtualKeyCode != VK_MENU && InputRecord.Event.KeyEvent.wVirtualKeyCode != VK_SHIFT) { return InputRecord.Event.KeyEvent.wVirtualKeyCode; } } } } int main() { std::cout << "Hit Esc to exit" << std::endl; WORD Ch; while((Ch = GetChar()) != VK_ESCAPE) { switch(Ch) { case VK_END: std::cout << "End" << std::endl; break; case VK_HOME: std::cout << "Home" << std::endl; break; } } } -- Just another homepage: http://damb.dk But it's mine - Bertel
Jan 05 2007
Got it working..... thx Bertil & Walter! Regards, Ed
Jan 05 2007