I need to create a window that can be resized by pressing a key.

For example, Right Shift in the program Borland C ++ 3.1 in the C programming language. I created the window itself, but I don’t understand how to write a function that would understand that the right key was pressed and change the window size. I ask you for help.

  • At least read the listener first . - Denis
  • At least OS specify. Times BC 3.1 - DOS? Then the ideal (but severe) version is its int 9 handler :) - PinkTux
  • @Dave Manston You will probably find it easier to use the Turbo Vision classes in which this operation is already incorporated. - Vlad from Moscow
  • @PinkTux Windows 7, but I work in Borland through DosBox - Dave Manston

1 answer 1

The wrong way is to poll input devices inside the element that received the focus. We will not even consider it, let's move on to the right one.

The correct one is an external handler that queues the received events. And this queue is available to windows, buttons and other objects.

In Windows, there is no need to specifically do anything, this event handling scheme is already present from the very beginning.

For DOS, the ideal solution would be to work with interruptions (its int 9h handler for the keyboard, int 33h for the mouse, etc.). This is exactly how event handling in Turbo Vision is arranged, so it makes sense not to reinvent the wheel, but to take everything from there. Especially since the source is.

For Linux, things are a bit more complicated (see the example , and this is not the only option), but the general meaning remains the same.

And most importantly, you need to understand. Despite the fact that the general principle is the same, its implementation is very strongly tied to the OS and the platform, and it is this that constitutes the lion’s share of the work ( neither the C language nor the C ++ language have the means to fully work with input devices, so everything is needed do it yourself ). And while spending time on DOS, you need to understand well why this is done, since in most cases it will be wasted time.

  • , thanks for the advice, but do you have an example of using TurboVision, for I only stumble on theory - Dave Manston
  • @DaveManston, all TurboVision examples in its sources. I myself saw this fossil almost 20 years ago last time, so I will not tell you more precisely. - PinkTux
  • understood, and thanks for that) - Dave Manston Nov.