|
I do this for an array of COM ports (element 0 shown):
Comport[0] = &m_comm0;
// Set up the COM ports
Comport[0]->SetCommPort( (short)i + 2); // start at COM2
Comport[0]->SetInBufferSize(2040); // both buffers to just under 2K
Comport[0]->SetOutBufferSize(2040);
Comport[0]->SetRThreshold(1); // call OnComm event after 1 char reced.
Comport[0]->SetSettings(cstr1);
if (! Comport[0]->GetPortOpen()) // if the port is closed, open it
Comport[i]->SetPortOpen(TRUE);
Also, the ON_COMM event handler is set up to be called by 1 character recieved. Note that var is declared as a VARIANT and that the condition of checking for a non zero length is because once in several million events this is called with no received character. There may be more than one character received in the string.
if(Comport[Port]->GetCommEvent() == 2)
{
VARIANT var;
// character(s) received ?
var.vt = VT_BSTR; // yes, we get a BSTR back
var = Comport[Port]->GetInput();
cstr1 = var.bstrVal; // convert to a CString for convenience
if(cstr1.GetLength() > 0) // if anything to add
{
// do it here
}
}
Elaine
The tigress is here
|
|
|
|
|
when I use SHGetFolderLocation in my program, system tells me :
error C2065: 'SHGetFolderLocation' : undeclared identifier
Error executing cl.exe.
My IDE is VC6+win2000
who can help me?TIA
|
|
|
|
|
have you included shlobj.h?
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Exactly, I've done that, but error is still there,later on , I try this:
#pragma comment(lib, "shell32")
It does not work yet! I dont know why!
|
|
|
|
|
I don't know then. This is what I got from MSDN on the error:
Compiler Error C2065
'identifier' : undeclared identifier
The specified identifier was not declared.
A variable’s type must be specified in a declaration before it can be used. The parameters that a function uses must be specified in a declaration, or prototype, before the function can be used.
Tips
Make sure any include file containing the required declaration is not omitted.
Make sure you are including any necessary header files if you have defined VC_EXTRALEAN, WIN32_LEAN_AND_MEAN, or WIN32_EXTRA_LEAN. Defining these symbols excludes some functionality (certain header files are excluded) from windows.h and afxv_w32.h (for MFC applications) to speed compiles. Search windows.h and afxv_w32.h for these symbols for the most up-to-date description of what is excluded.
Make sure the identifier name is spelled correctly.
Make sure the identifier is using the correct upper- and lowercase letters.
Make sure all string constants have closing quotes.
This error can be caused by having a newline character in a string constant without a continuation character. For example:
#include <stdio.h>
main() {
printf("\n %s
%s // error: 's' : undeclared identifier
%s",
"this", "is", "it");
}
Special considerations must be taken when splitting a constant string over several lines. The most common method is to change the format string. Strings separated only by whitespace (spaces, tabs, newlines) are concatenated. For example:
#include <stdio.h>
main() {
printf("\n %s"
" %s"
" %s",
"this", "is", "it");
}
An older, less-preferred method is to use line continuation by typing a backslash at the end of a line. For example:
printf("\n %s\
%s\
%s",
"this", "is", "it");
This method is not often used because the spaces at the beginning of each continued line become part of the string.
Make sure you're using proper namespace scope. For example, in order to properly resolve ANSI C++ Standard Library functions and operators, you must state that you're using the std namespace with the using directive.
For example, unless the using directive is uncommented, the following sample will fail to compile because the cout stream is defined in the std namespace:
#include <iostream>
// using namespace std;
void main()
{
cout << "Hello" << endl;
}
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
[edit]My previous reply was incorrect, sorry[/edit]
#define _WIN32_IE 0x0500 before including shlobj.h
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
I have test the above solution but I still cant find way out, who can solve the problem? Source code provided here would be much appriciated or you can send your code related to this subject to me at tiplip@msn.com, thanks a million
|
|
|
|
|
|
I want to send an recive a CString between COM1 and COM2.How can I use the function ReadFile() and WriteFile()?Can anyone give a example code?thanks very much.;P
YES, I am here.
|
|
|
|
|
Writing is easy but reading is not that simple. Check this website [^] for an example. Also search MSDN for serial communications.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
thank you .but that is too hard to find what my want.
can anyone give me a simple?
YES, I am here.
|
|
|
|
|
Angel Kid wrote:
that is too hard to find what my want
If you read the article that kuphryn gave you, maybe that example won't seem so hard. I agree with you when you say that it is too hard, because I had the same problem when I first saw the example a few years ago, but the thing is that I was unable to find anything more simple. I don't know how comfortable you are with threads because you have to use them. On the other hand just ignore all the stuff that seems complicated to you because you won't need most of it. I wish I could help you with some sample code, but unfortunately I don't have any available. Just take a look at [^] because there are some classes that deal with serial communications.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Look for this article on this site. Read it and implement.
Article name : "CSerialCom - A simple Class for Implementing Serial Communication in Win-9X/2000" by SHIBU K.V
Good luck.
Louis
|
|
|
|
|
Here is a link to MSDN that shows a good design sample from Microsoft.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp
Kuphryn
|
|
|
|
|
Hi All,
Anyway know how to process PowerPoint files other than using office automation? I need a threaded service, COM SERVER, etc, etc, that can export the slides from a PowerPoint deck, into individual images, like jpegs. I wrote a simple ASP COM object using the automation APIs, but it seems that its not threaded so multiple requests end up getting queued, just not a very good solution. If anyone knows of anything, please let me know.
Thanks,
Rick
|
|
|
|
|
Either write your own file parser/renderer, or download the OpenOffice[^] source code and extract the PowerPoint stuff. However, it's not that simple - The source is about 180MB compressed...
You might be able to find a commercial solution, but I've been looking for something similar and haven't found anything yet.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
hello @all,
i want to make a two dimensional matrix.
how can i do this? can anybody help me?
thank you very much
sunny
|
|
|
|
|
Do you want a static matrix or a dynamic matrix?
Kuphryn
|
|
|
|
|
thanks for reply.
i want a dynamic matrix!
thank you very much!!!
sunny
|
|
|
|
|
Okay. Here is an example of a two-dimensional array of char using dynamica allocation.
unsigned int nSize = 100;
char *text = new char*[nSize]
for (unsigned int i = 0; i < nSize; ++i)
text[i] = new char[nSize];
...
// Deallocation
Kuphryn
|
|
|
|
|
A chessboard matrix:
unsigned char pChess[8][8];
To access element 5,1 you would do it like this:
unsigned char u = pChess[1][5];
Dynamic matrix creation is a bit more difficult...
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
hello,
thanks for reply!!!!!
but i need a dynamic matrix!
can you help me?
thank you very much!
sunny
|
|
|
|
|
Is there any good way to do this or do I know a workaround of some sort?
|
|
|
|
|
To get the rect of the control or of the text itself?
// Control:
CRect oR;
CWnd *pStatic = GetDlgItem(IDC_THE_STATIC_CTRL);
pStatic->GetWindowRect(&oR);
ScreenToClient(&oR);
// bounding rectangle of static's text contents
CString cText;
GetDlgItemText(IDC_THE_STATIC_CTRL,cText);
CWnd *pStatic = GetDlgItem(IDC_THE_STATIC_CTRL);
pStatic->GetClientRect(&oR);
CDC *pDC = pStatic->GetDC();
pDC->DrawText(cText,&oR,DT_CALCRECT|DT_LEFT|DT_SINGLELINE|DT_TOP);
pStatic->ReleaseDC(pDC);
// oR now has the bounding rectangle needed to display the text.
onwards and upwards...
|
|
|
|
|
Wouldn't it be better to just make a memDC so the text itself won't show up on the control (it's already there ofcourse)? Or doesn't it do this anyway?
|
|
|
|