Hello,

As I read the following document a few times at:

http://www.codeproject.com/system/serial.asp

given to me by fellow friend Jochen in my previous post I am ready to give
rs232 a crack at it! :)

I am using the "Windows messages" option of rs232 interfacing (See
document). In spite of me using VC++ for 9 months now, I still consider
myself a beginer when it comes to much of the language and especially the
VC++ GUI. Here is my first problem. I have started to code for the rs232 as
indicated in the above link's web document as so:

#define STRICT
#include <tchar.h>
#include <windows.h>
#include "CSerialWnd.h"

I still don't know what the "#define STRICT" statement is doing there? But I
am just copying the sample.

Given the above include statements I get the following error at build time:

c:\_DTS_PROGRAMMING\C_PROGRAMMING\vc++\MY_APPS_LAB\RS232Test_XPPLC\WndProc_CW1.cpp(20):
fatal error C1083: Cannot open include file: 'CSerialWnd.h': No such file or
directory

In the document, it clearly states that I need to include the serial class
header file, in which I did, and I must make sure that the header-files of
this library are in my compiler's include path.

Up to now all I am used to is including windows.h and some odd header file
that I created. I don't know how to include the header files of CSerialWnd
library in my compiler's include path.

I didn't get very far, but its a start and I don't know what to do, I tried
to look at the project properties to see if there is a field that requires
include paths, or something like this.... I would appreciate any guidence or
direction towards this!

Any help is very appreciated!
Thanks

--
Best regards
Robert

Re: rs232! by Frank

Frank
Tue Jun 20 12:47:37 CDT 2006

"Robby" <Robby@discussions.microsoft.com> wrote in message
news:27043D0F-44DC-407A-A43A-8ACCA8BA469E@microsoft.com...
> Hello,
>
> As I read the following document a few times at:
>
> http://www.codeproject.com/system/serial.asp
>
> given to me by fellow friend Jochen in my previous post I am ready to give
> rs232 a crack at it! :)
>
> I am using the "Windows messages" option of rs232 interfacing (See
> document). In spite of me using VC++ for 9 months now, I still consider
> myself a beginer when it comes to much of the language and especially the
> VC++ GUI. Here is my first problem. I have started to code for the rs232
> as
> indicated in the above link's web document as so:
>
> #define STRICT
> #include <tchar.h>
> #include <windows.h>
> #include "CSerialWnd.h"
>
> I still don't know what the "#define STRICT" statement is doing there? But
> I
> am just copying the sample.
>
> Given the above include statements I get the following error at build
> time:
>
> c:\_DTS_PROGRAMMING\C_PROGRAMMING\vc++\MY_APPS_LAB\RS232Test_XPPLC\WndProc_CW1.cpp(20):
> fatal error C1083: Cannot open include file: 'CSerialWnd.h': No such file
> or
> directory
>
> In the document, it clearly states that I need to include the serial class
> header file, in which I did, and I must make sure that the header-files of
> this library are in my compiler's include path.
>
> Up to now all I am used to is including windows.h and some odd header file
> that I created. I don't know how to include the header files of CSerialWnd
> library in my compiler's include path.
>
> I didn't get very far, but its a start and I don't know what to do, I
> tried
> to look at the project properties to see if there is a field that requires
> include paths, or something like this.... I would appreciate any guidence
> or
> direction towards this!
>
> Any help is very appreciated!
> Thanks
>
> --
> Best regards
> Robert

You can do a couple of things here. Either open the project settings and
depending on the version of the development environment, add the location of
the CSerialWnd.h path in the C++ preprocessor options. In VC6, select
Project->Settings->C++ and change the combobox to Preprocessor. In VS2k5,
select Project->Properties->Configuration Properties->C/C++->General. This
will allow the compiler to find the required header file.

For this particular case though, the other option would be better suited as
the CSerialWnd class code must also be available to the project so, copy the
files into your project folder and add them to the project.

--
============
Frank Hickman
Microsoft MVP
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.



RE: rs232! by Robby

Robby
Tue Jun 20 13:13:02 CDT 2006

Thanks Frank!

A little problem though!

As for the first part of your post:

"You can do a couple of things here. Either open the project settings and
depending on the version of the development environment, add the location of
the CSerialWnd.h path in the C++ preprocessor options."

1) I don't know where the CSerialWnd.h file is on my hard drive, I also did
a searched and nothing was found?
2) I don't see any options to add the location of any path in the C++
preprocessor options?

The only options I see are:
-Preprocessor definitions >>set to>> WIN32;_DEBUG;_WINDOWS
-Ignore standard include path >>set to>> no
-Generate preprocessed file >>set to>> no
-Keep comments >>set to>> no

As for the next part of your post:

"In VC6, select Project->Settings->C++ and change the combobox to
Preprocessor. In VS2k5,
select Project->Properties->Configuration Properties->C/C++->General. This
will allow the compiler to find the required header file."

1) Well... I am using VC++ .net

And for the last sugestion:

"For this particular case though, the other option would be better suited as
the CSerialWnd class code must also be available to the project so, copy the
files into your project folder and add them to the project."

1) Where is the CSerialWnd class code ?

I am sorry, but is there anything else I can do!

Again thanks for your reply!

get back!

--
Best regards
Robert


"Robby" wrote:

> Hello,
>
> As I read the following document a few times at:
>
> http://www.codeproject.com/system/serial.asp
>
> given to me by fellow friend Jochen in my previous post I am ready to give
> rs232 a crack at it! :)
>
> I am using the "Windows messages" option of rs232 interfacing (See
> document). In spite of me using VC++ for 9 months now, I still consider
> myself a beginer when it comes to much of the language and especially the
> VC++ GUI. Here is my first problem. I have started to code for the rs232 as
> indicated in the above link's web document as so:
>
> #define STRICT
> #include <tchar.h>
> #include <windows.h>
> #include "CSerialWnd.h"
>
> I still don't know what the "#define STRICT" statement is doing there? But I
> am just copying the sample.
>
> Given the above include statements I get the following error at build time:
>
> c:\_DTS_PROGRAMMING\C_PROGRAMMING\vc++\MY_APPS_LAB\RS232Test_XPPLC\WndProc_CW1.cpp(20):
> fatal error C1083: Cannot open include file: 'CSerialWnd.h': No such file or
> directory
>
> In the document, it clearly states that I need to include the serial class
> header file, in which I did, and I must make sure that the header-files of
> this library are in my compiler's include path.
>
> Up to now all I am used to is including windows.h and some odd header file
> that I created. I don't know how to include the header files of CSerialWnd
> library in my compiler's include path.
>
> I didn't get very far, but its a start and I don't know what to do, I tried
> to look at the project properties to see if there is a field that requires
> include paths, or something like this.... I would appreciate any guidence or
> direction towards this!
>
> Any help is very appreciated!
> Thanks
>
> --
> Best regards
> Robert

Re: rs232! by Frank

Frank
Tue Jun 20 13:28:04 CDT 2006

"Robby" <Robby@discussions.microsoft.com> wrote in message
news:883C1D30-7DAE-4F4B-86C3-06DB3662F86C@microsoft.com...
> Thanks Frank!
>
> A little problem though!
>
> As for the first part of your post:
>
> "You can do a couple of things here. Either open the project settings and
> depending on the version of the development environment, add the location
> of
> the CSerialWnd.h path in the C++ preprocessor options."
>
> 1) I don't know where the CSerialWnd.h file is on my hard drive, I also
> did
> a searched and nothing was found?
> 2) I don't see any options to add the location of any path in the C++
> preprocessor options?
>
> The only options I see are:
> -Preprocessor definitions >>set to>> WIN32;_DEBUG;_WINDOWS
> -Ignore standard include path >>set to>> no
> -Generate preprocessed file >>set to>> no
> -Keep comments >>set to>> no
>
> As for the next part of your post:
>
> "In VC6, select Project->Settings->C++ and change the combobox to
> Preprocessor. In VS2k5,
> select Project->Properties->Configuration Properties->C/C++->General.
> This
> will allow the compiler to find the required header file."
>
> 1) Well... I am using VC++ .net
>
> And for the last sugestion:
>
> "For this particular case though, the other option would be better suited
> as
> the CSerialWnd class code must also be available to the project so, copy
> the
> files into your project folder and add them to the project."
>
> 1) Where is the CSerialWnd class code ?
>
> I am sorry, but is there anything else I can do!
>
> Again thanks for your reply!
>
> get back!
>
> --
> Best regards
> Robert
>

Did you download the sample project files from codeproject?
http://www.codeproject.com/system/Serial/Serial_demo.zip

Since you are using VS.Net follow the VS2k5 directions to add the path,
should be the same for VS2k3. It would be in the General section for .Net

--
============
Frank Hickman
Microsoft MVP
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.



Re: rs232! by Robby

Robby
Tue Jun 20 14:52:02 CDT 2006

Hello Frank!

I downloaded the serial sample as you told me to. I took a long and hard
look at the source code... I don't really understand how everything works....
However I copied all the files under the "serial" folder in my project
folder. I don't think I need all of them.... Do I?

Anyhow at the top of my cpp file I included the "CSerialWnd.h" header file
but this gave me the same error, so I changed it to "SerialWnd.h" which is
one of the header files that I copied into my project folder, and it compiled
without errors!

So why is it that in the web documentation they say to include
"CSerialWnd.h" as opposed to "SerialWnd.h"?

Okay, so this is step #1, I will now try to add the following code in my
winproc and see what gives!

===================================================
LONG Open (
LPCTSTR lpszDevice,
HWND hwndDest,
UINT nComMsg = WM_NULL,
LPARAM lParam = 0,
DWORD dwInQueue = 0,
DWORD dwOutQueue = 0
)

[and]

LRESULT CALLBACK MyWndProc (HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM
lParam)
{
if (nMsg == CSerialWnd::mg_nDefaultComMsg)
{
// A serial message occurred
const CSerialWnd::EEvent eEvent = CSerialWnd::EEvent(LOWORD(wParam));
const CSerialWnd::EError eError = CSerialWnd::EError(HIWORD(wParam));

switch (eEvent)
{
case CSerialWnd::EEventRecv:
// TODO: Read data from the port
break;

...
}

// Return successful
return 0;
}
==================================================

Just one thing though, where can I find the explanations to the function
parameters of:

LONG Open (
LPCTSTR lpszDevice,
HWND hwndDest,
UINT nComMsg = WM_NULL,
LPARAM lParam = 0,
DWORD dwInQueue = 0,
DWORD dwOutQueue = 0
)

I have looked in help and I find different variations.... I know the web
documentation explains it but here is what I don't get from their explanation:

================================================
"The lpszDevice, dwInQueue and dwOutQueue are used as in CSerial."

***I don't get it, where is it used in CSerial, all I saw was a simple:

long open(_T("COM1")) call?

And what is the "LPCTSTR lpszDevice"? , I know this is a long pointer to a
constant string, but where does it come from,.... is it a HDC?
====================================================

"The hwndDest argument specifies the window, where the message should be
sent to."

Okay so this is the window handle!
====================================================

"The library registers a default message during startup, which can be used
in most cases. Simply pass WM_NULL to use this message. The value of this
message is stored in the CSerialWnd::mg_nDefaultComMsg variable, which is a
static member variable of CSerialWnd. If you prefer one of your own messages,
then you can use that instead. "

Okay I can stay with their default message for now!

===================================================

"The optional lParam argument is sent as the second parameter (lParam) in
each message that is being sent by CSerial. The serial library doesn't do
anything with this value, so be free to use it as you like. "

So I just need to pass lParam.... Okay that's fine!
===================================================

Im just worried to try all of this, that's all!

Anyways, Frank, Thankyou very much, you have been very resourcefull and it
is much appreciated.

*you don't go away now... you hear!*
You have brought me through a long way, but I ain't out of the woods yet!

I hope to hear from you on my next probable imminent snag! :-)

If you have any suggestions on my questions above, please get back!

Thanks

--
Kind regards
Robert


"Frank Hickman [MVP]" wrote:

> "Robby" <Robby@discussions.microsoft.com> wrote in message
> news:883C1D30-7DAE-4F4B-86C3-06DB3662F86C@microsoft.com...
> > Thanks Frank!
> >
> > A little problem though!
> >
> > As for the first part of your post:
> >
> > "You can do a couple of things here. Either open the project settings and
> > depending on the version of the development environment, add the location
> > of
> > the CSerialWnd.h path in the C++ preprocessor options."
> >
> > 1) I don't know where the CSerialWnd.h file is on my hard drive, I also
> > did
> > a searched and nothing was found?
> > 2) I don't see any options to add the location of any path in the C++
> > preprocessor options?
> >
> > The only options I see are:
> > -Preprocessor definitions >>set to>> WIN32;_DEBUG;_WINDOWS
> > -Ignore standard include path >>set to>> no
> > -Generate preprocessed file >>set to>> no
> > -Keep comments >>set to>> no
> >
> > As for the next part of your post:
> >
> > "In VC6, select Project->Settings->C++ and change the combobox to
> > Preprocessor. In VS2k5,
> > select Project->Properties->Configuration Properties->C/C++->General.
> > This
> > will allow the compiler to find the required header file."
> >
> > 1) Well... I am using VC++ .net
> >
> > And for the last sugestion:
> >
> > "For this particular case though, the other option would be better suited
> > as
> > the CSerialWnd class code must also be available to the project so, copy
> > the
> > files into your project folder and add them to the project."
> >
> > 1) Where is the CSerialWnd class code ?
> >
> > I am sorry, but is there anything else I can do!
> >
> > Again thanks for your reply!
> >
> > get back!
> >
> > --
> > Best regards
> > Robert
> >
>
> Did you download the sample project files from codeproject?
> http://www.codeproject.com/system/Serial/Serial_demo.zip
>
> Since you are using VS.Net follow the VS2k5 directions to add the path,
> should be the same for VS2k3. It would be in the General section for .Net
>
> --
> ============
> Frank Hickman
> Microsoft MVP
> NobleSoft, Inc.
> ============
> Replace the _nosp@m_ with @ to reply.
>
>
>

Re: rs232! by Frank

Frank
Tue Jun 20 16:07:16 CDT 2006

Answers inline...

"Robby" <Robby@discussions.microsoft.com> wrote in message
news:34CE94A0-7FE8-4E81-888F-9ED582AD8B97@microsoft.com...
> Hello Frank!
>
> I downloaded the serial sample as you told me to. I took a long and hard
> look at the source code... I don't really understand how everything
> works....
> However I copied all the files under the "serial" folder in my project
> folder. I don't think I need all of them.... Do I?
>

No you should only need the Serial.cpp/Serial.h, SerialEx.cpp/SerialEx.h,
SerialWnd.cpp/SerialWnd.h files from the Serial subfolder.


> Anyhow at the top of my cpp file I included the "CSerialWnd.h" header file
> but this gave me the same error, so I changed it to "SerialWnd.h" which is
> one of the header files that I copied into my project folder, and it
> compiled
> without errors!
>
> So why is it that in the web documentation they say to include
> "CSerialWnd.h" as opposed to "SerialWnd.h"?
>

Probably just a typo.


> Okay, so this is step #1, I will now try to add the following code in my
> winproc and see what gives!
>
> ===================================================
> LONG Open (
> LPCTSTR lpszDevice,
> HWND hwndDest,
> UINT nComMsg = WM_NULL,
> LPARAM lParam = 0,
> DWORD dwInQueue = 0,
> DWORD dwOutQueue = 0
> )
>
> [and]
>
> LRESULT CALLBACK MyWndProc (HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM
> lParam)
> {
> if (nMsg == CSerialWnd::mg_nDefaultComMsg)
> {
> // A serial message occurred
> const CSerialWnd::EEvent eEvent =
> CSerialWnd::EEvent(LOWORD(wParam));
> const CSerialWnd::EError eError =
> CSerialWnd::EError(HIWORD(wParam));
>
> switch (eEvent)
> {
> case CSerialWnd::EEventRecv:
> // TODO: Read data from the port
> break;
>
> ...
> }
>
> // Return successful
> return 0;
> }

You probably already have a window proceedure already defined. Just use the
code within the proceedure, not the whole proceedure itself.


> ==================================================
>
> Just one thing though, where can I find the explanations to the function
> parameters of:
>
> LONG Open (
> LPCTSTR lpszDevice,
> HWND hwndDest,
> UINT nComMsg = WM_NULL,
> LPARAM lParam = 0,
> DWORD dwInQueue = 0,
> DWORD dwOutQueue = 0
> )
>
> I have looked in help and I find different variations.... I know the web
> documentation explains it but here is what I don't get from their
> explanation:
>
> ================================================
> "The lpszDevice, dwInQueue and dwOutQueue are used as in CSerial."
>
> ***I don't get it, where is it used in CSerial, all I saw was a simple:
>
> long open(_T("COM1")) call?
>

This is for the standard CSerial use, not the windows message based one.


> And what is the "LPCTSTR lpszDevice"? , I know this is a long pointer to a
> constant string, but where does it come from,.... is it a HDC?
> ====================================================
>

No. This is the communications port you want to talk to. It can be
something from the user, registry or where ever you deside it should come
from. It just happens to be hard coded in the samples.


> "The hwndDest argument specifies the window, where the message should be
> sent to."
>
> Okay so this is the window handle!
> ====================================================
>

Yep.


> "The library registers a default message during startup, which can be used
> in most cases. Simply pass WM_NULL to use this message. The value of this
> message is stored in the CSerialWnd::mg_nDefaultComMsg variable, which is
> a
> static member variable of CSerialWnd. If you prefer one of your own
> messages,
> then you can use that instead. "
>
> Okay I can stay with their default message for now!
>
> ===================================================
>
> "The optional lParam argument is sent as the second parameter (lParam) in
> each message that is being sent by CSerial. The serial library doesn't do
> anything with this value, so be free to use it as you like. "
>
> So I just need to pass lParam.... Okay that's fine!
> ===================================================
>
> Im just worried to try all of this, that's all!
>
> Anyways, Frank, Thankyou very much, you have been very resourcefull and it
> is much appreciated.
>

Your welcome.


> *you don't go away now... you hear!*

I have sperts, you caught me on a good day :)


> You have brought me through a long way, but I ain't out of the woods yet!
>
> I hope to hear from you on my next probable imminent snag! :-)
>
> If you have any suggestions on my questions above, please get back!
>
> Thanks
>
> --
> Kind regards
> Robert
>
>

--
============
Frank Hickman
Microsoft MVP
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.



Re: rs232! by Robby

Robby
Tue Jun 20 16:58:01 CDT 2006

Boy oh boy, I never thought this would be so hard!

I feel like I need your support everyt step of the way!
Shame on me!

Frank:

I have to include "CSerialWnd" right? and so I did!
Now I have to create a serial object right? and so I did! and it gives me
the following errors:

XPPLC error LNK2019: unresolved external symbol "public: virtual __thiscall
CSerialWnd::~CSerialWnd(void)" (??1CSerialWnd@@UAE@XZ) referenced in function
"long __stdcall WndProc_CW1(struct HWND__ *,unsigned int,unsigned int,long)"
(?WndProc_CW1@@YGJPAUHWND__@@IIJ@Z)

XPPLC error LNK2019: unresolved external symbol "public: __thiscall
CSerialWnd::CSerialWnd(void)" (??0CSerialWnd@@QAE@XZ) referenced in function
"long __stdcall WndProc_CW1(struct HWND__ *,unsigned int,unsigned int,long)"
(?WndProc_CW1@@YGJPAUHWND__@@IIJ@Z)

XPPLC fatal error LNK1120: 2 unresolved externals

Its like as if I am missing some kind of declaration in the serial
files....???

Here is my code:

===============================================
#include <windows.h>
#include <tchar.h>
#include "SerialWnd.h"


LRESULT CALLBACK WndProc_CW1 (HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{


CSerialWnd MySerial;


//long MySetrial.open(
// TEXT("COM1"),
// hwnd, WM_NULL,
// lParam,0,0
// );

....other code ...

}

===================================================

Sorry for all the failures I am involving you in, I appreciated... Thank god
I caught you on a good day :-)

P.S. I can't wait to read a byte through this computer port I tell ya!

--
Best regards
Robert


"Frank Hickman [MVP]" wrote:

> Answers inline...
>
> "Robby" <Robby@discussions.microsoft.com> wrote in message
> news:34CE94A0-7FE8-4E81-888F-9ED582AD8B97@microsoft.com...
> > Hello Frank!
> >
> > I downloaded the serial sample as you told me to. I took a long and hard
> > look at the source code... I don't really understand how everything
> > works....
> > However I copied all the files under the "serial" folder in my project
> > folder. I don't think I need all of them.... Do I?
> >
>
> No you should only need the Serial.cpp/Serial.h, SerialEx.cpp/SerialEx.h,
> SerialWnd.cpp/SerialWnd.h files from the Serial subfolder.
>
>
> > Anyhow at the top of my cpp file I included the "CSerialWnd.h" header file
> > but this gave me the same error, so I changed it to "SerialWnd.h" which is
> > one of the header files that I copied into my project folder, and it
> > compiled
> > without errors!
> >
> > So why is it that in the web documentation they say to include
> > "CSerialWnd.h" as opposed to "SerialWnd.h"?
> >
>
> Probably just a typo.
>
>
> > Okay, so this is step #1, I will now try to add the following code in my
> > winproc and see what gives!
> >
> > ===================================================
> > LONG Open (
> > LPCTSTR lpszDevice,
> > HWND hwndDest,
> > UINT nComMsg = WM_NULL,
> > LPARAM lParam = 0,
> > DWORD dwInQueue = 0,
> > DWORD dwOutQueue = 0
> > )
> >
> > [and]
> >
> > LRESULT CALLBACK MyWndProc (HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM
> > lParam)
> > {
> > if (nMsg == CSerialWnd::mg_nDefaultComMsg)
> > {
> > // A serial message occurred
> > const CSerialWnd::EEvent eEvent =
> > CSerialWnd::EEvent(LOWORD(wParam));
> > const CSerialWnd::EError eError =
> > CSerialWnd::EError(HIWORD(wParam));
> >
> > switch (eEvent)
> > {
> > case CSerialWnd::EEventRecv:
> > // TODO: Read data from the port
> > break;
> >
> > ...
> > }
> >
> > // Return successful
> > return 0;
> > }
>
> You probably already have a window proceedure already defined. Just use the
> code within the proceedure, not the whole proceedure itself.
>
>
> > ==================================================
> >
> > Just one thing though, where can I find the explanations to the function
> > parameters of:
> >
> > LONG Open (
> > LPCTSTR lpszDevice,
> > HWND hwndDest,
> > UINT nComMsg = WM_NULL,
> > LPARAM lParam = 0,
> > DWORD dwInQueue = 0,
> > DWORD dwOutQueue = 0
> > )
> >
> > I have looked in help and I find different variations.... I know the web
> > documentation explains it but here is what I don't get from their
> > explanation:
> >
> > ================================================
> > "The lpszDevice, dwInQueue and dwOutQueue are used as in CSerial."
> >
> > ***I don't get it, where is it used in CSerial, all I saw was a simple:
> >
> > long open(_T("COM1")) call?
> >
>
> This is for the standard CSerial use, not the windows message based one.
>
>
> > And what is the "LPCTSTR lpszDevice"? , I know this is a long pointer to a
> > constant string, but where does it come from,.... is it a HDC?
> > ====================================================
> >
>
> No. This is the communications port you want to talk to. It can be
> something from the user, registry or where ever you deside it should come
> from. It just happens to be hard coded in the samples.
>
>
> > "The hwndDest argument specifies the window, where the message should be
> > sent to."
> >
> > Okay so this is the window handle!
> > ====================================================
> >
>
> Yep.
>
>
> > "The library registers a default message during startup, which can be used
> > in most cases. Simply pass WM_NULL to use this message. The value of this
> > message is stored in the CSerialWnd::mg_nDefaultComMsg variable, which is
> > a
> > static member variable of CSerialWnd. If you prefer one of your own
> > messages,
> > then you can use that instead. "
> >
> > Okay I can stay with their default message for now!
> >
> > ===================================================
> >
> > "The optional lParam argument is sent as the second parameter (lParam) in
> > each message that is being sent by CSerial. The serial library doesn't do
> > anything with this value, so be free to use it as you like. "
> >
> > So I just need to pass lParam.... Okay that's fine!
> > ===================================================
> >
> > Im just worried to try all of this, that's all!
> >
> > Anyways, Frank, Thankyou very much, you have been very resourcefull and it
> > is much appreciated.
> >
>
> Your welcome.
>
>
> > *you don't go away now... you hear!*
>
> I have sperts, you caught me on a good day :)
>
>
> > You have brought me through a long way, but I ain't out of the woods yet!
> >
> > I hope to hear from you on my next probable imminent snag! :-)
> >
> > If you have any suggestions on my questions above, please get back!
> >
> > Thanks
> >
> > --
> > Kind regards
> > Robert
> >
> >
>
> --
> ============
> Frank Hickman
> Microsoft MVP
> NobleSoft, Inc.
> ============
> Replace the _nosp@m_ with @ to reply.
>
>
>

Re: rs232! by Drew

Drew
Tue Jun 20 17:22:57 CDT 2006

You, of course also included the CPP file in your project. Right?

Drew

"Robby" <Robby@discussions.microsoft.com> wrote in message
news:B32B9BFA-7969-4ADA-8754-97F019848C50@microsoft.com...
> Boy oh boy, I never thought this would be so hard!
>
> I feel like I need your support everyt step of the way!
> Shame on me!
>
> Frank:
>
> I have to include "CSerialWnd" right? and so I did!
> Now I have to create a serial object right? and so I did! and it gives me
> the following errors:
>
> XPPLC error LNK2019: unresolved external symbol "public: virtual
> __thiscall
> CSerialWnd::~CSerialWnd(void)" (??1CSerialWnd@@UAE@XZ) referenced in
> function
> "long __stdcall WndProc_CW1(struct HWND__ *,unsigned int,unsigned
> int,long)"
> (?WndProc_CW1@@YGJPAUHWND__@@IIJ@Z)
>
> XPPLC error LNK2019: unresolved external symbol "public: __thiscall
> CSerialWnd::CSerialWnd(void)" (??0CSerialWnd@@QAE@XZ) referenced in
> function
> "long __stdcall WndProc_CW1(struct HWND__ *,unsigned int,unsigned
> int,long)"
> (?WndProc_CW1@@YGJPAUHWND__@@IIJ@Z)
>
> XPPLC fatal error LNK1120: 2 unresolved externals
>
> Its like as if I am missing some kind of declaration in the serial
> files....???
>
> Here is my code:
>
> ===============================================
> #include <windows.h>
> #include <tchar.h>
> #include "SerialWnd.h"
>
>
> LRESULT CALLBACK WndProc_CW1 (HWND hwnd, UINT message,
> WPARAM wParam, LPARAM lParam)
> {
>
>
> CSerialWnd MySerial;
>
>
> //long MySetrial.open(
> // TEXT("COM1"),
> // hwnd, WM_NULL,
> // lParam,0,0
> // );
>
> ....other code ...
>
> }
>
> ===================================================
>
> Sorry for all the failures I am involving you in, I appreciated... Thank
> god
> I caught you on a good day :-)
>
> P.S. I can't wait to read a byte through this computer port I tell ya!
>
> --
> Best regards
> Robert
>
>
> "Frank Hickman [MVP]" wrote:
>
>> Answers inline...
>>
>> "Robby" <Robby@discussions.microsoft.com> wrote in message
>> news:34CE94A0-7FE8-4E81-888F-9ED582AD8B97@microsoft.com...
>> > Hello Frank!
>> >
>> > I downloaded the serial sample as you told me to. I took a long and
>> > hard
>> > look at the source code... I don't really understand how everything
>> > works....
>> > However I copied all the files under the "serial" folder in my project
>> > folder. I don't think I need all of them.... Do I?
>> >
>>
>> No you should only need the Serial.cpp/Serial.h, SerialEx.cpp/SerialEx.h,
>> SerialWnd.cpp/SerialWnd.h files from the Serial subfolder.
>>
>>
>> > Anyhow at the top of my cpp file I included the "CSerialWnd.h" header
>> > file
>> > but this gave me the same error, so I changed it to "SerialWnd.h" which
>> > is
>> > one of the header files that I copied into my project folder, and it
>> > compiled
>> > without errors!
>> >
>> > So why is it that in the web documentation they say to include
>> > "CSerialWnd.h" as opposed to "SerialWnd.h"?
>> >
>>
>> Probably just a typo.
>>
>>
>> > Okay, so this is step #1, I will now try to add the following code in
>> > my
>> > winproc and see what gives!
>> >
>> > ===================================================
>> > LONG Open (
>> > LPCTSTR lpszDevice,
>> > HWND hwndDest,
>> > UINT nComMsg = WM_NULL,
>> > LPARAM lParam = 0,
>> > DWORD dwInQueue = 0,
>> > DWORD dwOutQueue = 0
>> > )
>> >
>> > [and]
>> >
>> > LRESULT CALLBACK MyWndProc (HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM
>> > lParam)
>> > {
>> > if (nMsg == CSerialWnd::mg_nDefaultComMsg)
>> > {
>> > // A serial message occurred
>> > const CSerialWnd::EEvent eEvent =
>> > CSerialWnd::EEvent(LOWORD(wParam));
>> > const CSerialWnd::EError eError =
>> > CSerialWnd::EError(HIWORD(wParam));
>> >
>> > switch (eEvent)
>> > {
>> > case CSerialWnd::EEventRecv:
>> > // TODO: Read data from the port
>> > break;
>> >
>> > ...
>> > }
>> >
>> > // Return successful
>> > return 0;
>> > }
>>
>> You probably already have a window proceedure already defined. Just use
>> the
>> code within the proceedure, not the whole proceedure itself.
>>
>>
>> > ==================================================
>> >
>> > Just one thing though, where can I find the explanations to the
>> > function
>> > parameters of:
>> >
>> > LONG Open (
>> > LPCTSTR lpszDevice,
>> > HWND hwndDest,
>> > UINT nComMsg = WM_NULL,
>> > LPARAM lParam = 0,
>> > DWORD dwInQueue = 0,
>> > DWORD dwOutQueue = 0
>> > )
>> >
>> > I have looked in help and I find different variations.... I know the
>> > web
>> > documentation explains it but here is what I don't get from their
>> > explanation:
>> >
>> > ================================================
>> > "The lpszDevice, dwInQueue and dwOutQueue are used as in CSerial."
>> >
>> > ***I don't get it, where is it used in CSerial, all I saw was a simple:
>> >
>> > long open(_T("COM1")) call?
>> >
>>
>> This is for the standard CSerial use, not the windows message based one.
>>
>>
>> > And what is the "LPCTSTR lpszDevice"? , I know this is a long pointer
>> > to a
>> > constant string, but where does it come from,.... is it a HDC?
>> > ====================================================
>> >
>>
>> No. This is the communications port you want to talk to. It can be
>> something from the user, registry or where ever you deside it should come
>> from. It just happens to be hard coded in the samples.
>>
>>
>> > "The hwndDest argument specifies the window, where the message should
>> > be
>> > sent to."
>> >
>> > Okay so this is the window handle!
>> > ====================================================
>> >
>>
>> Yep.
>>
>>
>> > "The library registers a default message during startup, which can be
>> > used
>> > in most cases. Simply pass WM_NULL to use this message. The value of
>> > this
>> > message is stored in the CSerialWnd::mg_nDefaultComMsg variable, which
>> > is
>> > a
>> > static member variable of CSerialWnd. If you prefer one of your own
>> > messages,
>> > then you can use that instead. "
>> >
>> > Okay I can stay with their default message for now!
>> >
>> > ===================================================
>> >
>> > "The optional lParam argument is sent as the second parameter (lParam)
>> > in
>> > each message that is being sent by CSerial. The serial library doesn't
>> > do
>> > anything with this value, so be free to use it as you like. "
>> >
>> > So I just need to pass lParam.... Okay that's fine!
>> > ===================================================
>> >
>> > Im just worried to try all of this, that's all!
>> >
>> > Anyways, Frank, Thankyou very much, you have been very resourcefull and
>> > it
>> > is much appreciated.
>> >
>>
>> Your welcome.
>>
>>
>> > *you don't go away now... you hear!*
>>
>> I have sperts, you caught me on a good day :)
>>
>>
>> > You have brought me through a long way, but I ain't out of the woods
>> > yet!
>> >
>> > I hope to hear from you on my next probable imminent snag! :-)
>> >
>> > If you have any suggestions on my questions above, please get back!
>> >
>> > Thanks
>> >
>> > --
>> > Kind regards
>> > Robert
>> >
>> >
>>
>> --
>> ============
>> Frank Hickman
>> Microsoft MVP
>> NobleSoft, Inc.
>> ============
>> Replace the _nosp@m_ with @ to reply.
>>
>>
>>



Re: rs232! by Frank

Frank
Tue Jun 20 18:52:51 CDT 2006

"Drew" <drew.nospam.myers@esrd.com> wrote in message
news:%232okVgLlGHA.3512@TK2MSFTNGP03.phx.gbl...
> You, of course also included the CPP file in your project. Right?
>
> Drew
>
> "Robby" <Robby@discussions.microsoft.com> wrote in message
> news:B32B9BFA-7969-4ADA-8754-97F019848C50@microsoft.com...
>> Boy oh boy, I never thought this would be so hard!
>>
>> I feel like I need your support everyt step of the way!
>> Shame on me!
>>
>> Frank:
>>
>> I have to include "CSerialWnd" right? and so I did!
>> Now I have to create a serial object right? and so I did! and it gives me
>> the following errors:
>>
>> XPPLC error LNK2019: unresolved external symbol "public: virtual
>> __thiscall
>> CSerialWnd::~CSerialWnd(void)" (??1CSerialWnd@@UAE@XZ) referenced in
>> function
>> "long __stdcall WndProc_CW1(struct HWND__ *,unsigned int,unsigned
>> int,long)"
>> (?WndProc_CW1@@YGJPAUHWND__@@IIJ@Z)
>>
>> XPPLC error LNK2019: unresolved external symbol "public: __thiscall
>> CSerialWnd::CSerialWnd(void)" (??0CSerialWnd@@QAE@XZ) referenced in
>> function
>> "long __stdcall WndProc_CW1(struct HWND__ *,unsigned int,unsigned
>> int,long)"
>> (?WndProc_CW1@@YGJPAUHWND__@@IIJ@Z)
>>
>> XPPLC fatal error LNK1120: 2 unresolved externals
>>
>> Its like as if I am missing some kind of declaration in the serial
>> files....???
>>

Just as Drew pointed out, you need to add the code files to the project so
they are compiled as well. Press Shift-Alt-A or right click on your project
workspace window and select Add->Existing Items... This will open a file
open dialog where you can select all the .cpp files Serial.cpp, SerialEx.cpp
and SerialWnd.cpp. This will add them to the project workspace and they
will be compiled with the rest of the files.

--
============
Frank Hickman
Microsoft MVP
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.