K
K
Kirill H2016-06-12 18:12:53
C++ / C#
Kirill H, 2016-06-12 18:12:53

How to stop calculation in ShortCut event?

In short, I decided to make a simple console for the program. It is packed in GroupBox. Hiding and showing with the hide and show commands, respectively. The problem is that I tied both events in the tilde key. There is a boolean variable to define the state of the console (displayed = true and hidden = false). I know that it could have been made easier, but this is just an add-on (as it turned out, not effective), because. simpler code also produced an unacceptable result.
So, the essence of the problem:
When you press the '~' button, the console is displayed and immediately hidden, it is impossible to "catch" it open or close it correctly. I tried to interrupt the process using break (but for some reason it can not be used), but simply return does not help.
I am attaching the code below and immediately I apologize for the stupid question, I am just learning c ++, I just finished the second course ...

void __fastcall TForm1::FormShortCut(TWMKey &Msg, bool &Handled)
{
if (Msg.CharCode == 0xC0) { // Клавиша тильды для вызова консоли
  if (console_mod == true) {
    Gbox5->Hide();
    console_mod = false;
  }
  if (console_mod == false) {
    Gbox5->Show();
    console_mod = true;
  }
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
#
#algooptimize #bottize, 2016-06-12
@KirillHelm

1. Handled=true, it seems to be executed 2 times without it, not sure.
2.
if (console_mod == true) {
console_mod = false;
}
if (console_mod == false)
{
// end up here anyway ?????????????
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question