|
You should take a look at the GetDeviceCaps() function which will give you the sizes you need to know about for the screen. A common method of creating a correct sized window is to scale it according to the size of the font used.
|
|
|
|
|
Thanks for your reply. Can you elaborate a little bit more or point me to a source that outlines that strategy.
Thanks again,
BP
|
|
|
|
|
See here[^] maybe it is some helpful to you
|
|
|
|
|
Thank you very much. It looks like that article will be of great help me.
BP
|
|
|
|
|
I glad that its good for you
|
|
|
|
|
I've heard of differences between debug and release builds, but never of with the bugger or without. I have a very simple console app printing the length of unicode strings to the screen. With a debug version, one of the values is being displayed wrong (should be 4 but shows 10). If I step through the code, it's correct, it display the correct value to the screen. If I hit the run button, the value is wrong. Any idea what could be causing this? Does the debugger make any changes to the code or any changes to the memory managment?
|
|
|
|
|
waldermort wrote: I've heard of differences between debug and release builds, but never of with the bugger or without. I have a very simple console app printing the length of unicode strings to the screen. With a debug version, one of the values is being displayed wrong (should be 4 but shows 10). If I step through the code, it's correct, it display the correct value to the screen. If I hit the run button, the value is wrong. Any idea what could be causing this? Does the debugger make any changes to the code or any changes to the memory managment?
Can you show the piece of code.
|
|
|
|
|
I managed to track down the problem, it was a simple case of not correctly nulling the memory before copying a string. But still, When running through the debugger I was not able to find it. I had to literaly follow the code line by line.
|
|
|
|
|
Hi everybody.
I want to add an Communication control on my dialog based project in VC2005.
In VC6.0 I was using Project->Add to project->Add Components and controls etc
In 2005 under the project menu I do not have Add to project
When I created new MFC project I selected Dialog based and made sure ActiveX control radio was checked.
Under Tools->Customize (Commands tab) I have Rearrange Commands->(Menu bar checked) select Project pressed Add, under categories select again Project and I can see "Add component" and "Add user control". However even if I added them they are greyish under Project menu.
Any ideas how can I get "Add to project" for VC2005?
Thanks
Marian
marian
|
|
|
|
|
ok, found if I click right on my dialog, I have "Insert ActiveX control" pressed;found my commcontrol, all ok.
but still I would like to know if I can make my "Add to project" to appear.
thanks
marian
|
|
|
|
|
If you mean to add it to your toolbox, in VC2005 right_click the toolbox and select "Choose items"
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
|
|
|
|
|
This function should count the number of occurrences of strSearch within sentence. The compiler doesn't like it when a string variable is given instead of a char for functions such as strstr, strlen...
unsigned int CSentenceList::searchInSentence(const string* sentence, const string* strSearch)
{
char buffer[MAX_SENTENCE_LENGTH + 1] = {0};
memcpy(buffer, sentence, MAX_SENTENCE_LENGTH);
char* strToken = 0;
unsigned long iWordCount = 0;
strToken = strstr(buffer, strSearch);
while (strToken !=NULL)
{
if (strlen(strToken) > 0)
{iWordCount++;
strToken += strlen(strSearch);
}
strToken = strstr(strToken, strSearch);
}
return iWordCount;
}
Errors:
cSentenceList.cpp(70): error C2664: 'strstr' : cannot convert parameter 2 from 'const std::string *' to 'const char *'
SentenceList.cpp(76): error C2664: 'strlen' : cannot convert parameter 1 from 'const std::string *' to 'const char *'
I tried (char) and (char*) but they don't work...
Within the class members of stl::string, I found the following specialization that allows the class to take advantage of library functions that manipulate objects of this type char.
char_traits<char> Class A class that is a specialization of the template class char_traits<CharType> to an element of type char.
(MSDN)
Any idea how to use them?
Is it possible to cast a string to a char, somehow?
Is it possible to use other functions to search for substrings within the string class?
Jon
p.s. sorry for the numerous q's, I'm lost...
-- modified at 12:49 Sunday 27th August, 2006
|
|
|
|
|
First thing is that I would attempt this using the STL algorithms. Can't tell you how off the top of my head though as (a) I'm away from home and (b) I haven't done any C++ for over 18 months!
Second, I would pass the strings by const reference rather than pointer
(const string& strSearch.
Third, regarding the error you need to call c_str() on the string, i.e., strSearch->c_str() or strSearch.c_str() if you had a reference to strSearch.
Kevin
|
|
|
|
|
You are going to have to stop passing these strings around like they are normal strings, they are NOT!! They are classes and come with their own methods of accessing the data within them. You should also look at your error messages before you start asking for help. Look:
cSentenceList.cpp(70): error C2664: 'strstr' : cannot convert parameter 2 from 'const std::string *' to 'const char *'
The important words here are cannot convert parameter 2 from. It also gives you the line number (70), so you should go to that line and look at the second paramater to that function. The error then goes on to tell you more from 'const std::string *' to 'const char *'. The function wants a char * but you gave it a std::string* . Like I said the std::string has methods to access the data, and like I told you yesterday, use the .c_str() to get a const char* .
|
|
|
|
|
Why not just use CString from MFC? I think it contains the proper overloads to address that situation. However, I would listen to the poster "Waldermot". I think what he recommends would enable you to understand some important principles that you can successfully apply later.
|
|
|
|
|
I've got nothing against CString but all things being equal you're better off using std::string . For one it means you've got less porting to do if you decide to move the application to another platform.
Steve
|
|
|
|
|
|
I would like to include a validation that excludes carriage returns, on the lines of,
...
{ fileToRead.getline(strLine, MAX_SENTENCE_LENGTH);
if (strLine != CRLF)
{Sentences.push_back(strLine);
Size++;}
}
...
How do I validate strLine, perhaps through the ASCII code?
Jon
|
|
|
|
|
getline strips out the CR/LF - this may be giving you problems.
A cynic is a man who, when he smells flowers, looks around for a coffin. -H.L. Mencken
|
|
|
|
|
No actually the problem is that when there is an empty line (assuming a CR/LF) ONLY I would like to skip a block of code.
Jon
|
|
|
|
|
THERE WILL BE NO CR/LF - it will be an empty string. You are misinterpreting the problem. getline takes out the CR/LF but advances the file pointer, your code clearly indicates that you are looking for an empty line that includes the CR/LF. That is your problem.
A cynic is a man who, when he smells flowers, looks around for a coffin. -H.L. Mencken
|
|
|
|
|
Hi everybody, can anyone tell me how to display a dialog in a SDI application (the dialog has the CRecordView class as a base class). I just need to display a few records from an Access database in editboxes in my dialog. (That's for VC++ 6.0)
And my second question will be: I have a dialog in VC++ 2005 , but i can't assign appropriate class like CRecordView (I can only CFormView, CDialog, COLEproperty etc.)
Thanx everybody in advance
|
|
|
|
|
|
Thanx, but could you be more precise, this is a site for training, i need some tutorials and stuff, if you can point me to that kind of page that would help me more.
|
|
|
|
|
ivanris wrote: ...the dialog has the CRecordView class as a base class).
You can't do this. Dialogs are derived from CDialog , whereas views are derived from CView . CDialog and CView are on different branches of CWnd .
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|