|
I don't actually trust the serialisation of MFC all that much - it looks fine for trivial things, but it doesn't take a lot before it fails, or is not flexible enough.
I have a few questions...
You say about doc variables being valid in another routine, but that's hidden with a comment - we can't help you a lot there.
Do you make sure you clear all your doc variables in the constructor so they're valid but... boring... ?
Where does the file name m_DataPathName come from? It's not from the opening process? But as the Serialize function is called during CDocuments auto loading process, which include constructing the CDocument, ehen do you set it?
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Hi Guys,
I am pretty new to C++. And would require your help.
I am trying to get surname into a string using getline(cin,surName) and then passing it to a function to convert the string to upper case. Please note that I know there are functions available to do the conversion but I am trying to learn passing / returning "string" from a function.
Thanks in Advance
Tomic
char* conv_str_to_upper (char* str_io)
{
int stringlength = strlen(str_io);
for (int i=0; i
|
|
|
|
|
A C++ string isn't a char* . You can't apply old C char* based methods to handling C++ string s.
|
|
|
|
|
Tomicmanka wrote: for (int i=0; i str_io[i] = std::toupper(str_io[i]);
Did you bother to preview this before posting?
Tomicmanka wrote: conv_str_to_upper (surName);
Is conv_str_to_upper() going to know what to do with a string object?
Tomicmanka wrote: free (pstrText);
What are you freeing?
Go back and edit your post so that it is: 1) syntactically correct, and 2) easier to read.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Sorry mate, The text "free (pstrText);" was part of a larger program.
As I said I am very new (I have benn working on C++ for the last one week) so just bear with me.
I just want to know how to write a c++ function that accepts a string as parameter and return a string back to the main() function.
At this moment in time I want to convert a lowercase Surname to uppercase using a C++ function.
char* conv_str_to_upper (char* str_io)
{
int stringlength = strlen(str_io);
for (int i=0; i
str_io[i] = std::toupper(str_io[i]);
}
return (str_io);
}
The code above may be wrong, I just want to know how it can be done.
Thanks
|
|
|
|
|
Tomicmanka wrote: I just want to know how to write a c++ function that accepts a string as parameter and return a string back to the main() function.
string foo1( string str )
{
string strTemp;
strTemp = str;
return strTemp;
}
void foo2( string &str )
{
str = ...
}
Tomicmanka wrote:
At this moment in time I want to convert a lowercase Surname to uppercase using a C++ function.
Use the transform() function. See here
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Thanks David
My code now works
|
|
|
|
|
Tomicmanka wrote: I just want to know how to write a c++ function that accepts a string as parameter and return a string back to the main() function.
Rather than passing a string by value, you should generally prefer passing a string by reference to minimise copying.
std::string conv_str_to_upper (std::string const& str)
{
std::string upper;
upper.reserve(str.length());
std::transform(s.begin(), s.end(), std::back_inserter(upper), (int (*)(int))&std::toupper);
return upper;
}
The code for the function is taken from this page[^], which is kind of on your topic.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Good point, Thanks. I will do that then.
|
|
|
|
|
I have a simple static splitter with two panes.
I have managed to delete the right pane and having problem repainting it.
While developing I used the attached code for testing and discovered that ShowWindow(SW_HIDE) works after getting the access to parent window and then it does not work after the right pane is deleted and recreated.
That is one part of the puzzle.
The other part is that the new pane can only be repainted when the parent window is resized. Since MoveWindow does resizing too it also repaints the pane.
Seems like awkward way to accomplish repaint.
Any other opinions on the subject are as always appreciated.
Thanks for reading.
Here is the code snippet, Please IGNORE the goofy "-%gt;" characters!
I have given up fixing it!!!
CSplitterWnd * pParent = ( CSplitterWnd * )GetParent();
//pParent->ShowWindow(SW_HIDE); works here
CC_TabView_Pane * pPane = (CC_TabView_Pane * ) pParent->GetPane(0,1);
iCount = pPane->m_aPages.GetCount();
if(!iCount)
{
{
TRACEFN("\nNothing to delete in Tab %i m_aPages",iCount);
}
return iCount;
}
//pParent->MoveWindow(0,0,100,100);
pParent->ShowWindow(SW_HIDE); and it does not work here
|
|
|
|
|
I write a code for the prime numbers of large number in the C programming language and compile the code on the Turbo and it displays two errors
Error1. Constant Expression Required
Error2. Constant Expression Required
Why this error occurs?
|
|
|
|
|
nowrocktheworld wrote: Error1. Constant Expression Required
hard to guess witout seeing the code..but let me ask..did you put a variable in the "case" statement inside a "switch" case..like case aVariable:
|
|
|
|
|
I use the long int type of datatype and if i change the datatype then no error.
|
|
|
|
|
nowrocktheworld wrote: Why this error occurs?
Because you did not use a constant where one was expected/required.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Possibly you used a variable to specify an array dimension.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
As you have seen from the replies, you have not supplied us with any real clues.
The only help you'll get is:
"Hmm, I think the problem is you need to supply a constant expression."
Maybe provide the line the error is from?
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Hi to all,
Could anyone please tell me how do I get/set the controls of an another dialog box in MFC? (ie getting the values of editbox of dialogB from dialogA). Basically from dialogA, I am opening another model dialog to enter some data in edit box. Now when user press OK, I need those data in my dialogA.
Please help me
thanks in advance
-----------------------------
I am a beginner
modified on Friday, September 25, 2009 10:55 AM
|
|
|
|
|
Several ways exist.
CDialogB::OnOK()
{
m_strData = "Some text that was keyed in by user";
CDialog::OnOK();
}
CDialogA::SomeFunction()
{
CDialogB dlgB;
if (dlgB.DoModal() == IDOK)
m_strData = dlgB.m_strData;
}
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Hello,
I try to open the certificat store on a eToken but i failed.
I not very aware about CAPI and I think i missed something.
My code:
m_hMyCertStore =CertOpenStore( CERT_STORE_PROV_PHYSICAL, PKCS_7_ASN_ENCODING | X509_ASN_ENCODING,NULL, CERT_SYSTEM_STORE_CURRENT_USER, L"MY\\eToken");
I get hMyCertStore =0 and The GetLastError() return 2.
I don't know how to do.
I didn't manage to find a complete small example.
Thank you
|
|
|
|
|
Hi,
We have one program that is taking current cursor position in timer with GetCursorPos().
In normal exe its working fine.We have changed the program in to service.
Now In service mode the GetCursurPos return true but values are given by the function are garbage values.
we changed function with GetMessagePos but the result is same.
Any body know how to make it work.
We had also tried to get desktop rights to our service with OpenDesktop and SetThreadDesktop but
SetThreadDesktop function failed with error code 170.
If anybody knows about this problem please let me know the solution.
Thank you,
Regards,
Jay.
|
|
|
|
|
For getting the cursor position in a desktop, you will need to run an application on the same desktop.
If that is an option you can have the service communicate with the application using named events and the application can pass the cursor position to the service using shared memory or the file system or the registry.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
hi i have a basic doubt in cstring..
i have like this:
CString test = hello;
#define abc L"hello"
if (test.find(CString(abc)) == 0)
------
-----
But this if condition is failing...May i know the reason? how to make it to pass???
Can anyone enlighten me about this issue?
Thanks,
rakesh.
|
|
|
|
|
Rakesh5 wrote: CString test = hello;
What is hello? Is it a string literal or an undeclared variable?
Rakesh5 wrote: if (test.find(CString(abc)) == 0)
find() is not a member of CString . Perhaps you meant Find() . Why the extraneous CString construct?
All that aside, your code snippet works for me.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Hi David,
hello is just a string literal (for example purpose..) and I meant Find only...
my doubt is :
CString str(test);
CString str1 = L"test";
Are str and str1 same?? if not, how to make it same??
thanks,
rakesh.
|
|
|
|
|
Rakesh5 wrote: Are str and str1 same??
No, they are two separate objects. How would that differ from:
int x = 5;
int y = 5; Are x and y the same?
Rakesh5 wrote: if not, how to make it same??
You can't, but you can make them contain the same value.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|