|
but LPCTSTR is compatible to both Unicode as well as ANSI
An LPCWSTR if UNICODE is defined, an LPCSTR otherwise
|
|
|
|
|
sunit5 wrote: but LPCTSTR is compatible to both Unicode as well as ANSI
yes, but not the two ones at the same time...
if UNICODE is not defined, LPCTSTR equals to a LPCSTR (which is a conct char* ) and so, writing a wstring in it is a mistake !!
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
sunit5 wrote: but LPCTSTR is compatible to both Unicode as well as ANSI
An LPCWSTR if UNICODE is defined, an LPCSTR otherwise
Sunit5,
You are right. Thanks for correcting.
suhredayan There is no spoon.
|
|
|
|
|
Unicode is defined, so the methods are expecting LPCWSTR not LPCSTR and the LPCTSTR is typedef of LPCWSTR. So going from wstring to LPCTSTR with unicode defined should be fine, right?
|
|
|
|
|
WNDCLASSEX.lpszMenuName = getSomething().c_str();
in the above line wstring returned is destroyed as soon as the execution passes to the next line. So the pointer to the wstring is invalid after that. But the WNDCLASSEX unaware of this still try to access this pointer.
Also from the function getSomething()use the following syntax to return:
return wstring(L"my wstring");
suhredayan There is no spoon.
|
|
|
|
|
wstring wstrMenuName=getSomething().c_str();
WNDCLASSEX.lpszMenuName=(LPCTSTR)wstrMenuName;
//remember dont call the destructor of wstrMenuName till the work is not finished
|
|
|
|
|
Thank you guys that worked great. Thanks all
|
|
|
|
|
I am (obviously) an amateur, but this thing has plagued me long enough. I'm trying to integrate a program that requires stdafx.h into a large UAV simulator program. The UAV program compiles normally without the stdafx.h inclusion. There is a struct called POSITION that the UAV program uses, which I believe is conflicting with the afx lib (error message: .\Globals\typedefs.h(4) : error C2040: 'POSITION' : 'overloaded function type' differs in levels of indirection from 'struct __POSITION *'). I've tried renaming the struct, but it's a large program and I can't seem to track down all the implementations. My question: is there a simpler way to deal with this? Thank you for any help.
|
|
|
|
|
Can you put the POSITION struct from your project in an namespace , say UAV?
In all files where the UAV struct but not the afx struct is used, you can then simply add using UAV::POSITION .
Or you would write the namespace directly before each use, which is not much better than renaming the struct globally.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
Thank you for your reply. I tend to get in way over my head in these things. I have messed around with namespaces, but until your reply, was not sure that was something that may work. I'll give it a shot! I should then be able to use "using UAV::POSITION" in the files that show errors at compilation, correct? Thanks again.
|
|
|
|
|
newbie5345 wrote: I should then be able to use "using UAV::POSITION" in the files that show errors at compilation, correct?
I hope so, but I have not run a test.
using UAV::POSITION is the C++ way of telling the compiler "When I say POSITION , i want UAV::POSITION ."
But I am not completely sure if that works when there is already a POSITION in the global namespace. But a simple test program will show it.
(You can, by the way, access the specific version of POSITION from the global namespace by saying ::POSITION )
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
Hi CPians,
Since yesterday, my VC6.0++ SP5 does not save files before compilation anymore (meaning I have now to "edit file->Ctrl+S->F7" to compile instead of "edit file->F7"). This is _very_ annoying.
I however did not find any setting that handles this and that could have randomly been removed.
Any idea ?
~RaGE();
|
|
|
|
|
Try at:
Tools->Options->Editor->Save before running tools
If it's unchecked, then check it.
Should do the trick.
|
|
|
|
|
It is checked. But thanks for the help.
~RaGE();
|
|
|
|
|
BOOL GetHistory()
{
STATURL url;
CString strUrl;
ULONG uFetched;
IUrlHistoryStg2Ptr history;
IEnumSTATURLPtr enumPtr;
if(FAILED(CoCreateInstance(CLSID_CUrlHistory, NULL, CLSCTX_INPROC_SERVER, IID_IUrlHistoryStg2,(void**)&history)))
{
return false;
}
if(FAILED(history->EnumUrls(&enumPtr)))
{
history->Release();
return false;
}
while(SUCCEEDED(enumPtr->Next(1,&url,&uFetched)))
{
if(uFetched==0)
break;
}
history->Release();
return true;
}
if I set a timer to call the function ,the memory leak
if I delete
while(SUCCEEDED(enumPtr->Next(1,&url,&uFetched)))
{
if(uFetched==0)
break;
}
memory is good !
why?
thanks!
|
|
|
|
|
You must free STATURL.pwcsUrl and STATURL.pwcsTitle after each call to enumPtr->Next. MSDN says so.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
to Steen Krogsgaard
how to free STATURL.pwcsUrl and STATURL.pwcsTitle
can you tell me?
|
|
|
|
|
don't you do it like this ?
delete STATURL.pwcsUrl;
delete STATURL.pwcsTitle;
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I try like this:
delete STATURL.pwcsUrl;
delete STATURL.pwcsTitle;
but I get an excetion!
|
|
|
|
|
szcococut wrote: but I get an excetion!
i believe you get a ComplainNotExplainedEnoughException , don't you ?
please provide us the infos if you want so help...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
<br />
LPMALLOC lpMalloc;<br />
CoGetMalloc(1, &lpMalloc);<br />
lpMalloc->Free(url.pwcsUrl);<br />
lpMalloc->Free(url.pwcsTitle);<br />
lpMalloc->Release();<br />
or
<br />
CoTaskMemFree(url.pwcsUrl);<br />
CoTaskMemFree(url.pwcsTitle);<br />
The two methods are analogous (actully, identical, CoTaskMemFree calls CoGetMalloc and IMalloc->Free). Add error handling for flavor.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
thanks Steen !
it just What I want!
|
|
|
|
|
How to set Paper Size, Orientation, Number of Copies, Print Range in a program. Thanx in advance
Regards
KK
|
|
|
|
|
Here are some articles that can help you
Printing with MFC[^]
If you are looking for something other than MFC, Google is ur friend.
Regards,
Aamir
|
|
|
|
|
If i have the IP of a LAN computer how can i get programaticaly retrive the pc's name( the name asociated with the ip) ?
|
|
|
|