|
Hello guys!
Anybody here knows the maximum allowable length of the Standard C++ string class?
Thanks!
|
|
|
|
|
As much as memory allows!
I Dream of Absolute Zero
|
|
|
|
|
don't really know, but maybe having a look at the indexes type will let you gess the max of items allowed...
physically, you will certainly be limited before you reach the logical limit of the string...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Have a look at basic_string::max_size() . I think that STL does not have a maximum length requirement, thus the reason why max_size() is a function and not a normal data member or a constant.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Thank you for your help.
Do you guys know where to get a detailed documentation on basic_string's max_size() function?
MSDN library does not elaborate on this... it only include a sample function.
I really need to support my solution.
Thanks a million!
|
|
|
|
|
Hello,
I am trying to use the windows serial port driver using VC++(MFC). I need to work with 76800 baud. But the function "SetCommState" is returning error "Parameter incorrect" when i fill DCB struct with 76800 baud.
Can any one please help in this regard.
I have downloaded serial classes from net, but My requirement is not working.
Thanks in advance
sivack
|
|
|
|
|
Could some kind soul please PLEASE tell me how to go about subclassing the CCheckListBox control within an OCX. I can see how to create a WinApp Dialog with a CCheckListBox etc, but for the life of me I cannot work out how to create an OCX based on the CCheckListBox and would apreciate any advise available.
|
|
|
|
|
When I compile a project which has a particular header file (marked in bold) included, I get the following error:
Compiling...
NEVEMRepositorySetupHelper.cpp
NEVEMSystemUtilities.cpp
e:\vem\product ev\version4.05\vc\src\vem\nevservicecontrolmanager\cnevservicesmanager.h(32) : error C2143: syntax error : missing ',' before '&'
e:\vem\product ev\version4.05\vc\src\vem\nevservicecontrolmanager\cnevservicesmanager.h(32) : error C2059: syntax error : '&'
Error executing cl.exe.
NEVEMRepositorySetupHelperD.lib - 2 error(s), 0 warning(s)
However, this particular header file is the part of another project and that one complies perfectly. What is going wrong?
Regards
Jos
|
|
|
|
|
Post the line(s) that's been flagged (line 32 in the header).
I Dream of Absolute Zero
|
|
|
|
|
This is the line.
HRESULT LogNTEvent(const LONG lSeverity, const CString & sAppName, const CString & sVersion, const CString & sFile, const LONG lLine, const LONG lErrorCode, const CString & sMsg1, const LONG lPassingCode, const CString & sMsg2);
the implementation for it is given below:
HRESULT LogNTEvent(const LONG lSeverity, const CString &sAppName, const CString &sVersion, const CString &sFile, const LONG lLine, const LONG lErrorCode, const CString &sMsg1, const LONG lPassingCode, const CString &sMsg2)
{
HRESULT hResult = S_OK;
IEVEventLog* pIEventLog = NULL;
long lMySeverity = 1;
if ( 0 <= lSeverity && 4 >= lSeverity )
lMySeverity = lSeverity;
// Write to debug trace log
CString sTraceMsg0;
sTraceMsg0.Format( L"Filename %s: Line=%x, ErrorCode=%x, Message=%s, Method=%s, Passing=%d\n", sFile, lLine, lErrorCode, sMsg1, sMsg2 ,lPassingCode );
TRACE( sTraceMsg0 );
hResult = CoCreateInstance( __uuidof( EVEventLog ), NULL, CLSCTX_ALL, __uuidof( IEVEventLog ), (void**)&pIEventLog );
if ( FAILED( hResult ) )
return ((DWORD)0xC000110DL);
BSTR bsAppName = SysAllocString( L"Vigilance" );
BSTR bsFileName = sFile.AllocSysString();
BSTR bsFuncName = sMsg1.AllocSysString();
BSTR bsMethod = sMsg2.AllocSysString();
hResult = pIEventLog->LogEvent( bsAppName, ((WORD)0x0000000AL), lErrorCode, bsFileName, bsFuncName, lLine, bsMethod, lPassingCode, NULL, NULL);
pIEventLog->Release();
SysFreeString( bsAppName );
SysFreeString( bsFileName );
SysFreeString( bsFuncName );
SysFreeString( bsMethod );
if ( FAILED( hResult ) )
return ((DWORD)0xC000110DL);
return S_OK;
}
|
|
|
|
|
By chance is it complaining about the CString reference.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
me think you might be missing a , or something similar on line 32 or somewhere above that line; or in a another header file that was included just before that one.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
This is what is there in the header file
#ifndef _CNEVSERVICESMANAGER_H_
#define _CNEVSERVICESMANAGER_H_
// included header files
#include <atlbase.h>
#include <lm.h>
#include "../NEVEMXMLParsingUtilities/NEVEMResponseMessageParser.h"
#include "../NEVEMXMLParsingUtilities/CNEVEMSystemServiceStructure.h"
#include "../NEVEMXMLParsingUtilities/CNEVEMSystemServicesStructure.h"
#include "../NEVEMCommon/NEVEMCommon.h"
#include "NEVCOMUtils.h"
const int VIGILANCE_SERVICES = 0;
const int SYSTEM_SERVICES = 1;
const int GLOBAL_SERVICES = 2;
const int ORACLE_SERVICES = 3;
HRESULT LogNTEvent(const LONG lSeverity, const CString & sAppName, const CString & sVersion, const CString & sFile, const LONG lLine, const LONG lErrorCode, const CString & sMsg1, const LONG lPassingCode, const CString & sMsg2);
class CNEVServicesManager {
public:
CNEVServicesManager();
~CNEVServicesManager();
HRESULT CNEVServicesManagerInit(wstring & szVEMXMLResponseMessage);
// Service Controls
HRESULT stopService (const wstring & szServiceName, wstring & szVEMXMLResponseMessage);
HRESULT startService (const wstring & szServiceName, wstring & szVEMXMLResponseMessage);
HRESULT pauseService (const wstring & szServiceName, wstring & szVEMXMLResponseMessage);
HRESULT restartService(const wstring & szServiceName, wstring & szVEMXMLResponseMessage);
HRESULT getallServices(wstring & szVigilanceRelatedServicesXMLStructure, wstring & szVEMXMLResponseMessage);
HRESULT setServiceStartupInfo(const wstring & szSystemServiceXMLStructure, wstring & szVEMXMLResponseMessage);
HRESULT getServiceStartupInfo(const wstring & szServiceName,
wstring & szServiceDescription,
DWORD & dwServiceType,
DWORD & dwStartType,
bool & bInteractWithDesktop,
wstring & szStartupAccount, vector<vemresponsemessage>& vecResponseMessages);
HRESULT getServiceCurrentState(const wstring & szServiceName, DWORD & dwCurrentState, wstring & szVEMXMLResponseMessage);
private:
SC_HANDLE hSCManager;
SC_HANDLE hService;
map<wstring, int=""> mapVigilanceRelatedServicesNames;
// functions
HRESULT fillCNEVServiceInfoStruct(CNEVServiceInfoStruct& oCNEVServiceInfoStruct,
LPENUM_SERVICE_STATUS lpServices, vector<vemresponsemessage>& vecResponseMessages);
HRESULT getDependentServices (const wstring & szServiceName,
vector<wstring> & szDependentServices, vector<vemresponsemessage>& vecResponseMessages);
HRESULT getErrorMessage(const DWORD & dwErrCode, wstring & szErrorMessage);
wstring getServiceDisplayName(const wstring & szServiceName);
};
#endif
|
|
|
|
|
I have a dialog with a white background. When I create buttons on that dialog, themed buttons are drawn with a thin grey border. I tried correcting the problem by responding to WM_CTLCOLORBTN , but it didn't help. In fact, I never received a WM_CTLCOLORBTN message.
Any solutions to this problem is welcome.
--
Schni Schna Schnappi! Schnappi Schnappi Schnapp!
|
|
|
|
|
When dealing with most things custom drawn (custom drawn controls) I have found that XP Themes often fight me all of the way. I would suggest disabling themes for that application (maybe SetThemeAppProperties ?).
Modifying the painting of most button controls often requires that it be done as an ownerdrawn button, returning brush information from WM_CTLCOLORBTN is often not enough. You might have to resort to getting the theme information and using GetThemeColor(...) to paint them ownerdraw style.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
I'm not drawing the button myself. It's a simple BS_PUSHBUTTON. It's just that the dialog has a white background. If you look closely on a button using the standard xp theme, you'll see that it is not rectangular - it's got rounded corners. It's this border between the buttons rectangle and it's "image" that turns grey, as if it's assuming it's on a grey dialog.
Very frustrating.
--
Schni Schna Schnappi! Schnappi Schnappi Schnapp!
|
|
|
|
|
Is this an owner-drawn button? 'Cause the only to change the appearance of a button control is to do you own drawing. Also the docs say that this message (WM_CTLCOLORBTN), only gets handled by an owner-drawn button.
I Dream of Absolute Zero
|
|
|
|
|
It's an ordinary button (not owner drawn), put on a dialog with a white background. No ownerdraw magic here.
--
Schni Schna Schnappi! Schnappi Schnappi Schnapp!
|
|
|
|
|
You need to make the buttons with BS_OWNERDRAW style.
Then you need to draw the buttons yourself in the handler for WM_DRAWITEM in the (your) class inheriting from CButton or CBitmapButton.
That is what it takes to change background color of dialog.
this is this.
|
|
|
|
|
Argh. Annoying.
But I will try it out. Thanks!
--
Schni Schna Schnappi! Schnappi Schnappi Schnapp!
|
|
|
|
|
Ah, taking care of WM_DRAWITEM doesn't really do it. What you need to do is subclassing the button and take care of WM_ERASEBKGND. It is the background drawing that is the culprit. It draws using the button class's brush, whose color is COLOR_BTNFACE, which is "dialog grey". The theme drawing code just doesn't draw on that area, hence one needs to draw the background oneself instead of letting the button's default WM_ERASBKGND handler do it.
To ensure correct background color, I communicate with the parent and asks for the background using the WM_CTLCOLORBTN message. If I don't get a brush back, I let the button's default handler paint the background.
--
Schni Schna Schnappi! Schnappi Schnappi Schnapp!
|
|
|
|
|
Hi Guys,
I have a thread running recv continuously listening for messages from a client. The same program sets up a second connection, this time acting as a client to another machine. However, when the setup runs it seems to prevent a message reaching recv in the main thread. I've pinned it down to this portion of code:
hostent* hp;
if (inet_addr(&m_sServerIP[0]) == INADDR_NONE)
{
hp = gethostbyname(&m_sServerIP[0]);
} else {
unsigned long addr = inet_addr(&m_sServerIP[0]);
hp = gethostbyaddr((char*)&addr,sizeof(addr),AF_INET);
}
When this code is commented out I get the message I'm expecting on the main thread. Also, if the server at the other end responds immediately then there's no problem. Is there anything I can do to prevent this interference.
Sorry, I'm a bit of a newbie to network stuff and multithreading.
Many thanks,
Simon
|
|
|
|
|
Hello,
I have a little problem with virtual functions in derived classes. The problem is that I want to call a virtual function in my base class CBase . This function is abstract in this class. In the derived class CDerived this function is implemented. When the code in the base class gets executed, the _purecall handler is invoked. This means that I call a non-existing (abstract) function which is not implemented.
Here is the sample code:
<br />
class CBase<br />
{<br />
public:<br />
virtual void Foo() = 0;
<br />
void DoFoo() { static_cast<CBase*>(this)->Foo(); }<br />
};<br />
<br />
class CDerived : public CBase<br />
{<br />
public:<br />
virtual void Foo() { }<br />
};<br />
As you can see, I want to supply an interface in which certain functionality is provided. Some core functionality depends on ssituation specific user code, which should be supplied in the derived class.
Does anybody know how to solve this problem?
I also got the blogging virus..[^]
|
|
|
|
|
I don't understand what you really want to do...
Virtual functions are used like in the following case:
CBase* pClass = new CDerived;<br />
pClass->Foo();
In this case, the function that will be called is the derived function. The thing I don't understand is why do you want to call the redifined Foo function from within the base class ???
Why not simply call the Foo function directly ?
Maybe because you want this function to do something common for every class ? But then a much better solution would be to call from within your redifined Foo function a function from the base class.
|
|
|
|
|
cedric moonen wrote:
Virtual functions are used like in the following case:
CBase* pClass = new CDerived;
pClass->Foo();
No, the purpose of virtual functions is that the correct function is called when the exact type of a class is not known. For exemple:
<br />
class A<br />
{ <br />
public:<br />
virtual void Foo() {}<br />
};<br />
<br />
class B<br />
{<br />
public:<br />
virtual void Foo() {}<br />
};<br />
<br />
A* pA = new B;<br />
pA->Foo();
cedric moonen wrote:
In this case, the function that will be called is the derived function. The thing I don't understand is why do you want to call the redifined Foo function from within the base class ???
The base class (the interface) relies on functionality that cannot be implemented at that level, but the general functionality is always the same...
So the user must supply some functionality that is different for each use of the class.
cedric moonen wrote:
Why not simply call the Foo function directly ?
What do you mean by that, calling the function directly. If you mean that I should cast to the derived type, I cannot. This is because I don't know which one of the infinitly amount of possible derived classes would be calling the function.
cedric moonen wrote:
Maybe because you want this function to do something common for every class ? But then a much better solution would be to call from within your redifined Foo function a function from the base class.
In the most cases this would be the better solution, but in my particular case, it requires more than just 2 lines of code that will need to be rewritten every time a new class is derived from the base class.
I have a couple of dozen lines that are identical for every case, but the implementation of a function in the middle of those lines is user specific. I need to call that function from the base class, because I cannot rely on the end user to execute certain code before and after the call. Besides that, I don't want the user to write all those lines over and over again...
I also got the blogging virus..[^]
|
|
|
|
|