C++ MFC

Moderators: Lundin
Number of threads: 3354
Number of posts: 9032

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
serialport.h - missing something simple im sure Posted by coyoteboy on 16 Feb 2004 at 7:41 AM
I'm trying to use serialport.h MFC wrapper to send data to COM1. Where do I put the
CSerialport port;
port.Open(bla bla bla)

to ensure that the port is opened the instant the program is initiated, and only closes when the program exits? At the moment I'm stuck trying to figure out the scopes of each function. If I put the declaration in the message handler it works fine but i dont want the added time taken to open the port and close it again every time, plus I may have a different thread recieving at the same time or very shortly after. Where ever I put it it either throws compile-time errors about 'port' not existing or it closes it immediately after sending. Its simple in proceedural - you just lob the open in at the top and the close at the end, in a GUI i'm stuck :) I'd post the full code but I think people would get mad - its a long program.

James
Report
Re: serialport.h - missing something simple im sure Posted by dwccgc on 16 Feb 2004 at 12:50 PM
Where did you get this serialport.h file -- it is not a part of MFC.

Check out this site; you might find your answer here.
http://www.codeguru.com/network/CSerialPort.html


: I'm trying to use serialport.h MFC wrapper to send data to COM1. Where do I put the
: CSerialport port;
: port.Open(bla bla bla)
:
: to ensure that the port is opened the instant the program is initiated, and only closes when the program exits? At the moment I'm stuck trying to figure out the scopes of each function. If I put the declaration in the message handler it works fine but i dont want the added time taken to open the port and close it again every time, plus I may have a different thread recieving at the same time or very shortly after. Where ever I put it it either throws compile-time errors about 'port' not existing or it closes it immediately after sending. Its simple in proceedural - you just lob the open in at the top and the close at the end, in a GUI i'm stuck :) I'd post the full code but I think people would get mad - its a long program.
:
: James
:

Report
Re: serialport.h - missing something simple im sure Posted by coyoteboy on 17 Feb 2004 at 6:35 AM
: Where did you get this serialport.h file -- it is not a part of MFC.
:
: Check out this site; you might find your answer here.
: http://www.codeguru.com/network/CSerialPort.html

Thats where I got it from I think, but I have found a newer version that works as I expected it to - obviously some sort of a fix or the author has figured out how to cater for idiots like me :)

Thanks
James



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.