Reader small image

You're reading from  C++ Windows Programming

Product typeBook
Published inSep 2016
Reading LevelIntermediate
PublisherPackt
ISBN-139781786464224
Edition1st Edition
Languages
Right arrow
Author (1)
Stefan Björnander
Stefan Björnander
author image
Stefan Björnander

Stefan Björnander is the author of the books Microsoft Windows C++ and C++ Windows Programming. He holds a Master of Engineering and a Licentiate in Computer Science. He has worked as a software developer and as a teacher in computer science and mathematics for many years.
Read more about Stefan Björnander

Right arrow

Keyboard handling


To begin with, we look into the input of regular characters. The OnChar method is called every time a user presses a graphical character (with an ASCII value between 32 and 127, inclusive) or the Return key. If a part of the text is marked, that part is removed first. Then the character is added to the character list by the InsertChar method of the OverwriteChar class, depending on the keyboard mode.

void WordDocument::OnChar(TCHAR tChar) { 
  if (isprint(tChar) || (tChar == NewLine)) { 
    if (wordMode == WordMark) { 
      OnDelete(); 
    } 
 
    Paragraph* paragraphPtr = charList[editIndex].ParagraphPtr(); 
 
    switch (GetKeyboardMode()) { 
      case InsertKeyboard: 
        OnInsertChar(tChar, paragraphPtr); 
        break; 
 
      case OverwriteKeyboard: 
        OnOverwriteChar(tChar, paragraphPtr); 
        break; 
    } 
 
    SetDirty(true); 
    GenerateParagraph...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
C++ Windows Programming
Published in: Sep 2016Publisher: PacktISBN-13: 9781786464224

Author (1)

author image
Stefan Björnander

Stefan Björnander is the author of the books Microsoft Windows C++ and C++ Windows Programming. He holds a Master of Engineering and a Licentiate in Computer Science. He has worked as a software developer and as a teacher in computer science and mathematics for many years.
Read more about Stefan Björnander