|
I am not shouting, I am pointing the important points in my sentence (SHOUTING IS THIS )
I maintain my point : making assumption of the context is plainly wrong because someone else could change the compilation mode, and the code would not work anymore if not using Wide CString in ANSI compilation.
CPallini wrote: Have a nice day
Same.
|
|
|
|
|
toxcct wrote: I am not shouting, I am pointing the important points in my sentence
Hence 'the important points in my sentence' is the whole sentence itself? Clever!
toxcct wrote: I maintain my point
Never had doubts about...
toxcct wrote: and the code would not work anymore if not using Wide CString in ANSI compilation
The code would not work compile anymore if not using Wide CString in ANSI compilation.
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]
|
|
|
|
|
CPallini wrote: Writing robust code means writing code that will run reliably. Any other statement is 'bla bla bla'.
Actually, you are both wrong... in part only. Writing robust code means writing code that works well for its intent. That intent is where you are both arguing from, different points of view. Writing slow code but well maintainable code for a high end game, means the code will be thrown out regardless of Unicode settings. Define your intended target, and write for it.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
John Andrew Holmes "It is well to remember that the entire universe, with one trifling exception, is composed of others."
|
|
|
|
|
El Corazon wrote: Define your intended target, and write for it.
- My target: remove the obstacle from the OP way.
- Tox target: just me!
(just kidding, toxcct! )
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]
|
|
|
|
|
my target, advise efficiently (get the point there ? ^^ ) some newbies who don't actually know what thay are doing...
fixing a probleme is good, but teaching the OP why he is wrong is better, because if he understands what he's doing, he will no longer make the mistake.
"giving a man a fish will food him one day. teaching him to fish will food him all his life"
|
|
|
|
|
toxcct wrote: my target, advise efficiently (get the point there ? ^^ ) some newbies who don't actually know what thay are doing...
Well you've missed your the target here... Ah, OK, right: I'm the newbie...
toxcct wrote: (get the point there ? ^^ )
Nope: You know, I'm newbie...
toxcct wrote: fixing a probleme is good, but teaching the OP why he is wrong is better, because if he understands what he's doing, he will no longer make the mistake.
Possibly he wasn't doing a mistake. Maybe that was exactly what him intended to do (i.e. a ANSI compilation was excluded from start). You cannot force people to use generic text mapping just because you like it. You might advice, of course, but you cannot force (even the newbies like me) to advise people about.
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]
|
|
|
|
|
I see a Tox Bite on your hand.. did you make gestures on him? lol. He'd look harsh. but a cool guy lol . But here I'd agree with your point. And I dont disagree with him
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
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]
|
|
|
|
|
learn C++ and MFC
|
|
|
|
|
You mean you suggest ,
Effective C++ 5th Edition by Tox!
MFC internals 6th Edition by Great Grand Tox!
?
ROTFL!
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
I think what toxcct was saying is that in this specific case, you have to enforce a UNICODE string event if unicode is not defined for the project. AFAIK, the L macro enforces a 16-bits characters string. Thus, if you disable UNICODE, CString will hold 8-bits characters and you are trying to put a 16-bits character string in it, which will not compile properly.
Thus, in this specific case, you have to be sure that the CString is a 16-bits char string, thus the CStringW. Of course, you won't be able to do a lot of things with this string...
|
|
|
|
|
Cedric Moonen wrote: I think what toxcct was saying is that in this specific case, you have to enforce a UNICODE string event if unicode is not defined for the project. AFAIK, the L macro enforces a 16-bits characters string. Thus, if you disable UNICODE, CString will hold 8-bits characters and you are trying to put a 16-bits character string in it, which will not compile properly.
I known that. But that wasn't a lesson for generic text mappings. I just wanted to remove the obstacle from the OP way.
Cedric Moonen wrote: Thus, in this specific case, you have to be sure that the CString is a 16-bits char string, thus the CStringW. Of course, you won't be able to do a lot of things with this string...
That's not true: you can do a lot of things with such a string, provided you rewrite the whole project using (as suggested by toxcct) the W postfix for every API manipulating it.
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]
|
|
|
|
|
Cedric Moonen wrote: I think what toxcct was saying is that in this specific case, you have to enforce a UNICODE string event if unicode is not defined for the project.
Somehow, I have a strong reason to assume that the OP will have UNICODE defined. Because, he is clearly using Unicode and calling upon the "W" versions of each and every API is a real pain if you ask me.
Plus, that kind of code is not terribly good. That's because, if there's a need for an ANSI build sometime later, ... pain.
Of course, the OP needs a tutorial on generic text mappings, but what the heck...
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
don't get me wrong, I always take the road of Generic Text Mappings ( _T() and Co ) but sometimes, you just need a plain ANSI or a plain UNICODE string, regardless the compile mode...
that's what the OP wants here... he wants the 'Omega' symbol, even though he is building ANSI or not.
|
|
|
|
|
toxcct wrote: MessageBoxW(str);
CPallini is not wrong, you are. When UNICODE is defined, the compiler does this for you automatically. I don't see a need to call the "W" versions of the APIs explicitly.
I know the OP is possibly using only Unicode here. Usually, I would rather prefer to go with Generic Text Mappings: CString str(_T("\x03A9"));
With this, if we do an ANSI build sometime later, we don't have to change an an awful lot of things.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh R Subramanian wrote: I don't see a need to call the "W" versions of the APIs explicitly.
look closer bro, here, CPallini is not using _T(), he is directly creating a wide string using L"" ...
so as long the string literal is wide, the object that stores it will have to be wide too.
so why making things unclear and depend on a compilation mode rather than telling explicitely that we are using what the compiler would have chosen (if UNICODE defined) or failed (if ANSI)...???
|
|
|
|
|
toxcct wrote: look closer bro, here, CPallini is not using _T(), he is directly creating a wide string using L""...
I agree, that will require the OP to read a good tutorial on Generic Text Mappings.
The point what I wanted to make was that if we go around calling the "W" versions of APIs everywhere, then building an ANSI version will be an unnecessarily complicated task. Neither do I encourage using L"", but calling the Wide versions of APIs are even bad.
Plus, there's a strong reason for CPallini to assume that the OP has UNICODE defined, because he's clearly using Unicode!
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Using CStringW just here doesn't mean to use it everywhere in the code.
moreover, it is obvious the OP wants a UNICODE Character (Omega). so, no, don't make the code obscure. even though the compiler is set UNICODE or ANSI, it doesn't forbid you to write a clear (but not against performance anyway) code and show what you're actually doing here : getting a Wide character.
Note also that CStringW is somewhat useless for a single character. a WCHAR could have been used too here... and regardless we know or not if the OP has UNICODE defined !
|
|
|
|
|
toxcct wrote: a WCHAR could have been used too here
Yes and then what do you suggest, passing the WCHAR to the MessageBoxW function?
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]
|
|
|
|
|
Hi all,
I want to write some data into a DB using ADO. I got an error for the following code.
"Multiple-step operation generated errors. Check each status value."
Here is the code.
<br />
m_pRecSet->AddNew();<br />
<br />
vtData.vt = VT_INT;<br />
vtData.intVal = static_cast<int>(23);<br />
m_pRecSet->Fields->GetItem("PackID")->PutValue(vtData);<br />
<br />
m_pRecSet->Update();<br />
Can someone tell me what that error means?
I appreciate your help all the time...
CodingLover
|
|
|
|
|
CodingLover wrote: Can someone tell me what that error means?
Which statement generates the error?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Check if you are using transactions among the context
|
|
|
|
|
Hi,
In Visual studio 2005, when I use AfxGetInstanceHandle function directly or via calling another function such as CWnd::CreateEx inside an MFC extension dll, an assertion is thrown.
This is despite the fact that the same codes used to work fine in prior versions of visual studio.
What should be done to resolve this problem?
Thanks
|
|
|
|
|
Some questions:
1.) Are you expecting to recieve the base address of the DLL or the process executable?
2.) Is the extension DLL initialized properly? AfxInitExtensionModule[^]
3.) Whats the assertion?
Hack alert:
Replacing the call to AfxGetInstanceHandle with the following code might prevent the assertion... but HIDE the root cause of the it.
(HINSTANCE)&__ImageBase
Why it works:
AfxGetInstanceHandle[^] simply returns the base address of the DLL and __ImageBase is the intrinsic equivalent.
Here is another hacked-up way to get the instance handle:
__inline HINSTANCE MyGetInstanceHandle(LPCTSTR lpModuleName)
{
HINSTANCE h;
GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, lpModuleName, &h);
return h;
}
Don't use the code I have provided to bypass the assertion, it sounds to me like MFC has not been properly initialized.
Best Wishes,
-David Delaune
|
|
|
|
|
First of all answers to above questions:
1) Refering to Memory Management section of Extension DLLs in MSDN:
MFCx0.dll and all extension DLLs loaded into a client application's address space use the same memory allocator, resource loading, and other MFC global states as if they were in the same application. This is significant because the non-MFC DLL libraries and the regular DLLs do the exact opposite and have each DLL allocating out of its own memory pool.
If an extension DLL allocates memory, that memory can freely intermix with any other application-allocated object. Also, if an application that dynamically links to MFC fails, the protection of the operating system maintains the integrity of any other MFC application sharing the DLL.
Similarly other global MFC states, like the current executable file to load resources from, are also shared between the client application and all MFC extension DLLs as well as MFCx0.dll itself.
So I expect to receive the address space of process executable.
I checked hInstance value in DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved), it was 0x10000000 but it was not equal to the value returned by AfxGetInstanceHandle in process executable which was 0x00400000, despite the fact that they should have been the same!
2) Yes it's been properly initialized using AfxInitExtensionModule in its DllMain
3) AfxGetInstanceHandle asserts in its ASSERT(afxCurrentInstanceHandle != NULL); line
And I cannot use the code that you've mentioned because AfxGetInstanceHandle is also called from functions within MFC that I have no control on such as CWnd::CreateEx that cause the assertion again.
I really have no idea why MFC might have not been properly initialized!
Thank you for your feedback
|
|
|
|
|