0

I have a Windows console app created with Embarcadero XE 6 (in fact converted from a Borland C++Builder5 project). It has a single form with a few buttons and edit controls. All these controls have set TabStop=True and appropriate TabOrder's. However, pressing Tab in runtime when the form is shown does not do anything (it just produces a sound when a cursor/focus is in an Edit control and does nothing when a button is focused).

I have read in docs that Tab order would not work unless the Parent of the form is set. However, this is the only VCL form (the other windows are the console and the GLUT window), so there is no VCL parent AFAIK. I tried to set

Parent=Application->MainForm;

in the Form's constructor, but the Application->MainForm is also NULL. Any ideas?

dolphin
  • 1,192
  • 10
  • 27
  • Do you have a message loop? – David Heffernan Oct 04 '14 at 20:57
  • I don't have my own custom message loop. I create the form in the following way: MyForm=new TMyForm(Application); MyForm->Show(); and that's it. I also have handlers for OK and Cancel buttons that do everything I need. – dolphin Oct 04 '14 at 21:05
  • Where did you get a copy of **Borland** XE6? Borland sold Delphi several years ago, and is now defunct. If you have a copy of **Borland** XE6, it's probably worth enough money to allow you to not have to write code any longer. :-) – Ken White Oct 04 '14 at 21:20
  • @KenWhite Indeed, XE versions are sold by Embarcadero, yet they did not change dramatically from 1999 Borland C++ Builder 5 :-) – dolphin Oct 04 '14 at 21:43
  • @dolphin: Delphi and C++Builder **have** changed dramatically since 1999. New IDE, new RTL/VCL, new language features, new compilers. – Remy Lebeau Oct 05 '14 at 14:50
  • @RemyLebeau Yeah, I have read about it :-) I am a heavy user of Borland compilers since Builder version 3 (VCL and earlier OWL with Borland C++ 3.0). Yesterday I was porting a few big and complex projects from BCB5 to XE6, and apart from having to change to unicode/wide string, recompiling dlls, a lot of manual fixes in converted project files (bpr->cbproj) and a few tweaks in GUI (mostly because now I want high dpi awareness), everything works and looks just as it did in 1999. This is a high backward compatibility, great! – dolphin Oct 05 '14 at 17:23

1 Answers1

0

Your problem is that you don't have a message loop. This is because console applications are not expected to have windows and do not come with message loops by default.

You can run a message loop by calling:

Application->Run();

However this will probably stop the console part of your application from working properly. How can your main thread service the console synchronously and the asynchronous GUI message loop at the same time?

I suspect you will need to have a more serious re-think of your application design.


Regarding your update, it seems that you do have a message loop, but it is the message loop for the GLUT framework. The VCL framework requires its message loop to handle dialog messages like TAB key presses.

It's plausible that running the VCL message loop in place of the GLUT message loop would give better results. But it's quite likely that would just break the GLUT part of the app.

Trying to run two incompatible GUI frameworks out of a single message loop is hard to get right. There's probably no quick fix here. You'll need to dig deeper. Perhaps it would be best to give up on the VCL and stick to the one GUI framework.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • It is a GLUT app (updated my question) that is supposed to open a VCL form when some event occurs (and it does, everything works well except from the tabs). Even tooltips appear when hovering over controls. I added Application->Run(); after MyForm->Show(); but it did not change anything... – dolphin Oct 04 '14 at 21:55
  • Yeah. That's a major detail. It doesn't sound as though you really do have a console app. Sounds like you've a glut GUI app with a console window on the side. Probably via AllocConsole. But your glut message loop doesn't know about the vcl. – David Heffernan Oct 04 '14 at 22:29
  • It is a "console application" project, and its entry point is main(int,char**). Indeed, the glut message loop does not call vcl's message processing. Strange that everything else including tooltips works! [I confirmed that the same form in a regular vcl app handles tab properly.] – dolphin Oct 05 '14 at 02:17
  • Well it really is as I said. You need help from the VCL message loop, but it isn't running. – David Heffernan Oct 06 '14 at 06:14