|
I believe the second parameter to the Open function is a window handle.
You're trying to pass it a CWnd* .
Try this - port.Open(m_strComPort, m_hWnd);
|
|
|
|
|
It doesnt work. 
|
|
|
|
|
Please make your posts readable by putting code extracts within <pre> tags, indenting the code and removing unnecessary control or meta characters. Something like the following:
This uses <pre lang="c++"></pre>
CString m_strComPort;
m_strComPort.Format(TEXT("COM2"));
CSerial port;
if (port.Open(m_strComPort,this) != ERROR_SUCCESS
{
AfxMessageBox(TEXT("Unable to open COM"),MB_ICONSTOP | MB_OK);
GetParent()->PostMessage(WM_CLOSE);
return 0;
}
This uses <pre lang="text"></pre>
H:\\Program Files\\Microsoft Visual Studio\\MyProjects\\TestXbee\\TestXbeeDlg.cpp(130) : error C2664: 'Open' : cannot convert parameter 2 from 'class CTestXbeeDlg *const ' to 'unsigned long'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
As to your error message, the Open() function requires some value which is an unsigned long not a pointer to your enclosing class. You should check the documentation for the Open() function for specific details.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
So give the Open() func the correct parameter.
I havent a clue what it is, Ramions API doesnt have a second param, other APIs have baudrate, so look at the documentation.
==============================
Nothing to say.
|
|
|
|
|
How to use that library if it is so bad documented?
We do alot of serial programing. At the end it pays 10x using a good commercial library with technical support. We successfuly replaced MSComm with SuperCom ActiveX and it also solved us a lot other issues we had with Bluetooth devices.
|
|
|
|
|
I'm building a WCHAR Array, of server names to write to a REG_MULTISIZE Registry Key, But I'm unsure if I did the right thing.
The rule was a ServerName\0ServerName\00, but I get
"﷽﷽ꮫꮫꮫꮫﻮﻮﻮﻮﻮﻮDELLC521-01\SQLEXPRESSDELLC521-01\SQLEXPRESSWSA1\SQLEXPRESSDELL760\SQLEXPRESS2"
I'm not sure if my \0 went in, and I need to fix the prefix
WCHAR *pzServerNames = new WCHAR[0];
for ( int i = 0; i < sqlCount; ++i ) {
pzServerName = sqlSrvCollection[i];
wcsncat(pzServerNames, pzServerName, wcslen(pzServerName) );
wcsncat(pzServerNames, L"\0", wcslen(L"\0") );
}
_wcsncat_l(pzServerNames, L"\0\0", wcslen(L"\0\0"), NULL);
|
|
|
|
|
I guess first of all you're lucky it didn't crash since you allocated an array of 0 length.
Mark Salsbery
|
|
|
|
|
I guess that wasn't a good idea. I think I'm going to abandon that idea, and change the registry program to add 1 server name at a time. Read the key, and if the name is not there, then add the name and write the key back.
|
|
|
|
|
Try this:
int length = 0;
for ( int i = 0; i < sqlCount; ++i )
{
length += wcslen(sqlSrvCollection[i]);
length += 1; }
WCHAR* pzServerNames = new WCHAR[length + 1]; PWSTR pNext = pzServerNames; for ( int i = 0; i < sqlCount; ++i )
{
wcscpy_s(pNext, length, sqlSrvCollection[i]); int nlen = wcslen(sqlSrvCollection[i]); pNext += nlen; *pNext++ = L'\0'; length -= nlen + 1; }
*pNext = L'\0';
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Yeah, I thought I was going to have to do a per-calculation. I changed the format of the program, and opted for adding the server name 1 at a time. So when I add the name to the collection, I add the name to the registry key, which is multi-size. Sort of like the MimeMap Program, in which I read the key, look for a duplicate, if no duplicate, add the name, write the key back.
I will take your wisdom, and mix the 2 together. I wrote this yesterday, which is better than the the one I had in question. I know it has issues, in which I will straighten out today, on this rainy day.
I'm going to dump the wcsncmp for a straight value = value.
TCHAR szAddServerName[120];
WCHAR *pzServerNames = NULL;
int idx = wcslen(pzServerName);
for (int i = 0; i < idx; i++) {
szAddServerName[i] = pzServerName[i];
}
szAddServerName[idx] = L';';
szAddServerName[idx+1] = L'\0';
pzServerNames = CA_Registry::_get_Enumerated_SQLServers();
int iCompare;
wchar_t *token1, *nextToken;
wchar_t seps[] = L";";
token1 = wcstok_s(pzServerNames, seps, &nextToken);
do {
iCompare = wcsncmp(szAddServerName, token1, wcslen(szAddServerName)-1 );
if (iCompare != 0) {
wcsncat(pzServerNames, L";", wcslen(L";") );
wcsncat(pzServerNames, szAddServerName, wcslen(szAddServerName)+1 );
}
token1 = wcstok_s(NULL, seps, &nextToken);
if (token1 == NULL)
break;
} while (TRUE);
int iLength = wcslen(pzServerNames)+1;
pzServerNames[iLength+1] = L'\0';
WCHAR *szServerNames = new WCHAR[iLength+1];
wcsncpy_s(szServerNames, pzServerNames, wcslen(szServerNames) );
szServerNames[iLength] = L'\0\0';
|
|
|
|
|
I give your suggestion a spin, I don't understand this line. I know the pNext++ is a method to add a wchar to a const, but it goes backwards.
pNext += nlen; // The pNext goes Null
*pNext++ = L';'; // I wanted to add a ; to tokenize
*pNext++ = L'\0'; // takes a wchar off the front
int sql_Count = sqlSrvCollection.Count();
int length = 0;
for ( int i = 0; i < sql_Count; ++i )
{
length += wcslen(sqlSrvCollection[i]);
length += 2;
}
WCHAR* pzServerNames = new WCHAR[length + 1];
PWSTR pNext = pzServerNames;
for ( int i = 0; i < sql_Count; ++i )
{
wcscpy_s(pNext, length, sqlSrvCollection[i]);
int nlen = wcslen(sqlSrvCollection[i]);
pNext += nlen;
*pNext++ = L';';
*pNext++ = L'\0';
length -= nlen + 1;
}
*pNext = L'\0';
|
|
|
|
|
Incrementing the pNext pointer, merely moves it along the array, by a number of characters (pNext += nlen ) or a single character (pNext++ ). After incrementing it will appear to point to either an empty cell or some garbage. This is fine as long as the next statement fills that cell, by adding a new string or termination character. In my sample I was adding a NULL (L'\0' ) character after each string to create a REG_MULTISZ array. What you have done above is to add a semi-colon before each NULL which is superfluous. If you want a string that is tokenisable then put the semi-colon instead of the NULL, but make sure you still put the NULL at the very end.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
jkirkerx wrote: ...But I'm unsure if I did the right thing.
Anytime you are needing to deal with the '\0' character, functions like strcpy() , strcat() , strlen() and the like are off limits.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
This code removes the caption from the frame, however, it also removes all the title data from the Window – New view, only the number of the new window is there, but the document string (title) does not change.
strTitle = pDocument->GetTitle();
DWORD style = pFrame->GetStyle();
pFrame->ModifyStyle(style,WS_CHILD | WS_THICKFRAME ); // remove all , and no caption
strTitle = pDocument->GetTitle();
How do I access the standard Windows menu to put the title back in ?
As always, your help is appreciated.
Thanks Vaclav
I have modified
pFrame->ModifyStyle(WS_CAPTION,NULL);
It keeps the menu document title, but Window tiling does not work wihtout the caption. No surprise here.
I do not need tiling anyway.
I am still looking for ways to replace the New view "serial number " with
title preferably from menu.
-- modified 13-Nov-11 7:35am.
|
|
|
|
|
I do not think that removing all styles from your frame window and replacing by WS_CHILD | WS_THICKFRAME is what you want to do here.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Yes I do want to do that, but it may be the wrong place to do this.
I need to have a multiview of a single document and do not want to have title bar in these secondary views.
I may use it only to initialy let the user reposition these views, than I do not need / want the title bar to clutter the destop.
I think the answer must be somewhere in CDocument "title" string.
But I have not found how to change the string at run time.
As far as clearing all the styles - it would be nice to find out what exactly are the default / framework generated styles.
|
|
|
|
|
But it seems to me that you are changing the style of your FrameWnd window rather than the MDIChild . If you want to remove the title from a child window then you need to modify each one's properties individually.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I'm trying to do programming C++ for my project.
I got into trouble when I tried to do program for communicating with COM port(reading information in ComboBox).
The error " overloaded member function 'class CString(class CComboBox &a) not found in 'CXeedlg'. Could someone help me to overcome ?
overloaded member function not found in 'class'
The following is my code:
"
CString getCurStrInComboBox(const CComboBox &a)
{ CString str;
a.getLBText(a.GetCurSel(),str);
return str;
}
"
And the 2nd one is I dont know the reason why the complier informed that InsertString, AddString, GetCursel() arent members of ComboBox.
The deadline for my project is coming soon so I will really appreciate all your helps.
Thank you very much
|
|
|
|
|
Don't you need a class name in front of that function? As in, CXeedlg::getCurStrInComboBox
|
|
|
|
|
That was my bad in typing. I also have that part.
I also wanna ask you guys more questions.
"void CXbeefixedDlg::InitComboBox()
{
// ComboBox ComPort
m_cboComport.ResetContent();
m_cboComport.AddString("COM1");
m_cboComport.AddString("COM2");
m_cboComport.AddString("COM3");
m_cboComport.AddString("COM4");
m_cboComport.SetCurSel(2);
// ComboBox BitRate
m_cboBitrate.ResetContent();
m_cboBitrate.InsertString(0,"1200");
m_cboBitrate.InsertString(1,"2400");
m_cboBitrate.InsertString(2,"4800");
m_cboBitrate.InsertString(3,"9600");
m_cboBitrate.InsertString(4,"19200");
m_cboBitrate.InsertString(5,"38400");
m_cboBitrate.InsertString(6,"57600");
m_cboBitrate.InsertString(7,"115200");
m_cboBitrate.InsertString(8,"230400");
m_cboBitrate.SetCursel(3);
// Combobox Databit
m_cboDatabits.ResetContent();
m_cboDatabits.AddString("4");
m_cboDatabits.AddString("5");
m_cboDatabits.AddString("6");
m_cboDatabits.AddString("7");
m_cboDatabits.AddString("8");
m_cboDatabits.SetCurSel(0);
//Combox Stopbit
m_cboStopbits.ResetContent();
m_cboStopbits.AddString("1");
m_cboStopbits.AddString("1.5");
m_cboStopbits.AddString("2");
m_cboStopbits.SetCurSel(0);
//Combox Paritybit
m_cboParitybit.ResetContent();
m_cboParitybit.InsertSring(0,"None");
m_cboParitybit.InsertString(1,"Odd");
m_cboParitybit.InsertString(2,"Even");
m_cboParitybit.InsertString(3,"Mark");
m_cboParitybit.InsertString(4,"Space");
m_cboParitybit.SetCursel(0);
}
void CXbeefixedDlg::Settings()
{
// Check whether port was openned, Close port to setup parameter
if (m_mscomm.SetPortOpen())
m_mscomm.SetPortOpen(false);
// Initialize Port name
m_mscomm.SetCommPort(m_cboComport.GetCursel()+1);
// Initialize parameters, databits, stopbits, parity bits, flowcontrol
CString strBitrate = getCurStrInCombobox(m_cboBitrate);
CString strParitybit = getCurStrInCombobox(m_cboParitybit);
CString strStopbits = getCurStrInCombobox(m_cboStopbits);
CString strDatabits = getCurStrInCombobox(m_cboDatabits);
//Cstring strflowcontrol = getCurStrInCombobox(m_FlowControl);
CString strSetting;
strSetting.Format("%s,%c.%s,%s",strBitrate,strParitybit[1],strStopbits,strDatabits);
m_mscomm.SetSettings(strSetting);
// Other initializations
m_mscomm.SetRThreshold(1);
m_mscomm.SetInputlen(2); // Read 2 characters per once time
m_mscomm.SetInputBufferSize(1024);
m_mscomm.SetInputMode(0); // 0 - Text mode, 1 - Binary Mode
m_mscomm.SetPortOpen(true); // Open COM port
}
CString CXbeefixedDlg::getCurStrInCombobox(const CComBoBox &a)
{ CString str;
a.GetLBText(a.GetCurSel(),str);
return str;
}
"
The above is my code but I dont know the reason why my VC++ informed that GetCurSel is not a member of ComboBox class. And in the getCurStrInCombobox, it informed that missing "," before "&". Could you help me to solve this problem ?
The deadline for my project is coming so now I'm really rushed.
Thank you very much.
|
|
|
|
|
is this in your code or is this more "typo" during entry:
Quote: CComBoBox
you have too many capital "B"s in your CComboBox 
|
|
|
|
|
Most likely, this is your problem:
CString CXbeefixedDlg::getCurStrInCombobox(const CComBoBox &a) Instead of CComBoBox, it should be CComboBox
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
First:
The member function listed in the compiler message looks like a conversion constructor for the class CString, taking a parameter of type CComboBox. Apparently the compiler found a function call somewhere in your code that requires a parameter of type CString, but you passed it a parameter of type CComboBox. Therefore it tried to find a conversion function from CComboBox to CString, and because it didn't find one, it issued this error message.
Solution: locate the position in your code that the error message points to and replace the CComboBox argument with one of type String, or convertible to CString.
(P.S.: the error message looks like there's something missing - it might just be what Chuck said)
Second:
This might be a followup error, but I cannot fathom how. You might have forgotten to include the right header, but I doubt that - it would cause quite a lot more errors, and the compiler wouldn't even recognize the symbol CComboBox to be a class. Maybe you mistyped the type CComboBox for ComboBox, like you did in your posting? It might be helpful to see a piece of code that these error messages point to.
|
|
|
|
|
Hi,
The following code in VS2008
CString str;
char Singature[16];
strcpy (str.GetBuffer() , Singature);
str = "_________________Header_________________";
reports me the following message :
"Windows has triggered a breakpoint in xxxxx
This may be due a corruption of the heap, which indicates a bug in xxxx or any of the DLLs it has loaded."
When I delete the strcpy code, then it works fine. What seems to be the problem here ? The mentioned code it worked just fine in VS6.
sdancer75
|
|
|
|
|
The strcpy function keeps copying until it reaches a terminating null.
Since you did not initialize Signature, there is probably no null character contained in it.
Thus, strcpy is writing to memory that it should not. That is the cause of the error.
Try using the following code instead:
char Singature[16] = { 0 };
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|