|
I've got an old project writetd in vc++ on VS 7.1. When I opened it on Visual Studio 2008 it was correctly converted and worked. Now i needed to use a part of this old code in the new project created on VS2008. Everything work exepct a part of old code:
int CDGabinetDlg::DefineGrammar(const char* fn)
{
int rc;
SM_MSG reply;
TCHAR lpBuffer[256];
GetCurrentDirectory(256, lpBuffer);
string filename(lpBuffer);
filename+="\\";
filename+=fn;
return rc;
}
I've get an error in this part:
string filename(lpBuffer);
This is an error what i get.
error C2664: 'std::basic_string<_Elem,_Traits,_Ax>::basic_string(const std::allocator<_Ty> &)' : cannot convert parameter 1 from 'TCHAR [256]' to 'const std::allocator<_Ty>
|
|
|
|
|
The difference between VC7 and VC8 (related to your error I mean) is that in VC2008, UNICODE is defined by default. If you want to better understand what that means, I suggest this article[^].
In your code snippet, you are not being consistent neither: sometimes you are using a char arrays, sometimes a TCHAR array. So, either you do not care at all about unicode and only use char array, or you care about UNICODE and use TCHAR arrays everywhere. But using both is ugly.
On the other hand, std::string do not support wide characters, so that's why you have the compilation error. For that part, if you want to support unicode builds, I suggest you define your own type:
#if defined _UNICODE || defined UNICODE
typedef std::wstring TMyString;
#else
typedef std::string TMyString;
#endif
This way, you'll be independant of the unicode settings.
|
|
|
|
|
Hey, I wanted to know that whether it is safe to use ADO in a DLL? The reason I'm asking this is that, to use ADO we need to initialize COM right? So calling CoInitialize in a DLL, is it okay?
|
|
|
|
|
Ahmed Manzoor wrote: we need to initialize COM right? So calling CoInitialize in a DLL, is it okay?
Yes. You do it and the matching uninitialize in DLLMain for every Process and Thread attach/detach message.
From the documentation:
Because there is no way to control the order in which in-process servers are loaded or unloaded, do not call CoInitialize, CoInitializeEx, or CoUninitialize from the DllMain function.
link[^]
|
|
|
|
|
What do you mean? Is it safe? Will there be any malfunction?
|
|
|
|
|
Ahmed Manzoor wrote: Will there be any malfunction?
That depends on you, your analysis of your scenario and developing a correct solution. Make sure you read the documentation I provided a link to.
The best scenario is the host process has already handled COM initialization. If that isn't happening then you have a less than perfect scenario. Make sure you understand the ramifications and develop the proper error handling code for the potential scenarios that could occur based on your hosting scenario.
My fault, I should have mentioned that your scenario can also call for dealing with the initialization in other exports of your DLL rather than DLLMain. The problem with that is you need to account for the messages you get passed in DLLMain so that you know which event is happening. It's really up to you to figure all this out based on your project details.
|
|
|
|
|
Well now, I guess I would have to use another solution.
Thanks anyways
|
|
|
|
|
GetDlgItemText(id)->EnableWindow(FALSE) is not working in windows vista OS when user admin is off.I want to disable a groupbox in vista OS.
|
|
|
|
|
Do you want to disable the group box window? Why? After all its a static control
Or the controls within it?
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Hi All
i am creating a report which data take time 1-5mins. So i want to display a Please wait message.Please help me
|
|
|
|
|
You may perform the processing in a worker thread while displaying the wait message in the main (GUI ) one, see [^].
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]
|
|
|
|
|
COleBusyDialog[^]
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Why don't you just let the user do his thing when the report is being prepared, instead of showing a 'plz wait' message? Just use a worker thread to prepare the report.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Thanks for reply
I am useing worker threda for prepare report.But When report is going to prepare that time i want to show Please wait message after that i show report dialog.
|
|
|
|
|
Why would you want the user to wait if the GUI is not blocked?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I have a dialog which consists of 2 list control items set in report view.
I wish to color a row in one of the list control.
How can i do it?
I can do it, if the app is Single Doc with base class CListView, by using OnCustomDraw.
But how can i implement OnCustomDraw in one of the List Control from dialog?
*12Code
|
|
|
|
|
Here is an example with dialog, see the CUSTLIST.ZIP sample:[^].
Nuri
|
|
|
|
|
Thanks Nuri, This is what i've been looking for.
*12Code
|
|
|
|
|
See here[^].
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Derive a class from the list control (CListCtrl) and implement the custom draw functionality in that. Then, in the dialog class, use your class derived from the list control instead of CListCtrl when declaring the list control variables. The way MFC works, your derived class should sub-class the list controls and you should get your row colouring functionality.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
i need to detect when i press the Return or The arrow down button how can id o that and in which file ?
in a SDI Application. Thanks .
|
|
|
|
|
susanne1 wrote: The arrow down butto
Add a handler for WM_LBUTTONDOWN using the class wizard in your view class.
Handle WM_KEYDOWN event and check if nChar==VK_DOWN & nChar==VK_RETURN (For enter key)
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
modified on Wednesday, May 20, 2009 8:12 AM
|
|
|
|
|
I gues she was talking about the arrow down key, and not button...
|
|
|
|
|
HALLO and thanks for the answer, i have the followinbg code in the view.cpp file:
BEGIN_MESSAGE_MAP(CTest_View, CEditView)
ON_WM_LBUTTONDOWN(OnCursorLine) // this should get if the user pressed the return or the up or down arrows
END_MESSAGE_MAP()
// where should i handle WM_KEYDOWN event?
CTest_View::OnCursorLine()
{
if(nChar==VK_DOWN & nChar==VK_RETURN)// how can i get the value of nChar?
}
When i start ma SDI application and press the Return or arrow up/down the Debuger does not go to the OnCursorLine ().
What should i do?
|
|
|
|