1

I'm actually in charge of a FIP networking c++ application, working for the first time with Embarcadero C++ Builder XE5. The app is nearly finished, but I can't find how to implement the last feature...

I wanted to open an external Windows HyperTerminal in order to see what happen on a given COM port, for this purpose I'm using ShellExecute() to launch it from my application but it's a bit ugly since there is 2 different windows.

I was wondering if it was possible to integrate this newly opened HyperTerminal into an existing form (Panel for instance). I couldn't find nothing related excepted this => Delphi style, but i don't understand a byte of @mghie answer since it's delphi.

If anyone have a clue I'm really interested, even the most basic clue!

Community
  • 1
  • 1
  • I found an old Delphi/borland pirate in the company (I'm an intern) and after 30 years of works he developped its own personal vcl components library (all kind of serial port communications modules). So I will probably use this! But I'm still curious of how to integrate another app, will check answers! Ps: if you have the same problem for serial port communication you can find serial vcl modules on the internet, may it help you! –  Feb 07 '14 at 09:45
  • I use WinApi for COM ports it is easy enough, but you must use threads – Spektre Feb 07 '14 at 09:53
  • I doesnt need thread here, I just write to my TMemo whenever the reception event is fired. –  Feb 07 '14 at 09:54
  • 1
    yep but if you read COM without threads than it can get Stuck sometimes (usually often) especially if you are sending data also – Spektre Feb 07 '14 at 09:57
  • 1
    The solution you linked uses `SetParent` to re-parent another executables window to embed it into your application. I would strongly recommend you to NOT do that: If the hosted application becomes unresponsive, so does yours. See [my question here](http://stackoverflow.com/q/16817112/2298252). Since HyperTerminal is not a console application, you cannot re-direct its std Input and output, unfortunately. Since you just want to monitor a COM port, I'd personally do it myself. It's not a lot of work. – Günther the Beautiful Feb 07 '14 at 11:11
  • @GünthertheBeautiful Yep, you are right, and that's what I did! I reused a homemade vcl component, made by a coworker as said above, it implement the basics of a serial port communication, so I get signals when input come etc. –  Feb 07 '14 at 11:20
  • http://sourceforge.net/projects/tpapro/ I think something like this should do anything you ever could want with COM ports. – J... Feb 07 '14 at 11:29
  • @J... Looks great, thanks for the tips, maybe you could post it as an aswer as I already solutioned my problem it could probably help the others!! –  Feb 07 '14 at 12:05
  • @Spektre: you do not need to use threads. If you use overlapped I/O or IOCP, you could use a simple timer, for instance. – Remy Lebeau Feb 07 '14 at 16:18

2 Answers2

4

For almost all of my projects where COM port interaction is needed I use AsyncPro. The project is very well documented with a ~1000 page reference manual.

Reference Manual

Developer's Guide

For this case, the package provides a VCL terminal that simply drops onto a form. It's quite flexible with a lot of options to configure its behaviour.

enter image description here enter image description here

J...
  • 30,968
  • 6
  • 66
  • 143
  • I solutionned my problem with a similar homemade solution since I can't use external code, but I recommend this answer for anyone who is in the same case as me! –  Feb 07 '14 at 13:44
1

I wanted something similar in past but with no success.

1.The only thing I was able to do is the exact opposite.

  • dock my VCL window inside another (not VCL app) but that solved my problems
  • If you terminal is console window then I doubt even this can be done.
  • anyway find handle of desired window
  • find handle to a dockable subcomponent
  • set the parent of your subwindow to it / or use manual dock

2.maybe you can do some funny stuff

  • like hide terminal somewhere
  • and continuoslly copy its graphics to your window
  • newer done that hide thing
  • but copy the contents is doable (although on windows a little unstable sometimes)
  • done it once to feed my App with IR-camera feed from different App
  • while 'focus' stays on hidden terminal it should work
  • also you can try to post messages to it somehow if you need the focus ...

Sorry for a vague answer but at least you see some approaches of mine

  • maybe someone has a better way to do this
Spektre
  • 49,595
  • 11
  • 110
  • 380
  • 1
    Answer 2 is really nasty man! But I still appreciate your asnwer. I already feel raped by using such a heavy IDE+cofeeMaker like c++ builder, I usualy code under emacs. I will keep the serial vcl module for now, but thanks for the infos! –  Feb 07 '14 at 09:53
  • I code in borland for decades ... when you grasp the feel of it and learn the downsides then it is unbeatable (at least for me) I hate when I have to do something in other IDE like Eclipse or MSVC++ many things are there so backwards (but that can be only the custom of mine I think) – Spektre Feb 07 '14 at 09:56
  • I don't like ide in general, even if they allow you to save a lot of time, I find that you loose a lot of control over your code, at least zhen you start. On emacs, the only shits happening are yours, I find it clearer :) –  Feb 07 '14 at 10:00
  • Both are a disaster. Don't expect a whole load of joy out of `SetParent`. It's a hangover from Win16. Don't use it today. – David Heffernan Feb 07 '14 at 13:38
  • yep I agree is it a mess but what else can I do if i Need for example dock a custom preview VCL subwindow to system dialog for which I do not have access to the source code ? – Spektre Feb 07 '14 at 17:52