|
Hi all,
I have written a code in vc6 in which i have written this code for getting a resource handle....
FindResource(NULL,MAKEINTRESOURCE(IDR_IDR_EXE_EXEEXTRACTOR),"IDR_EXE");
now when i am writing this same code in VC2005
it gives an error:-
error C2664: 'FindResourceW' : cannot convert parameter 3 from 'const char [8]' to 'LPCWSTR'
but error is resolved when i add prefix 'L' to my third parameter
FindResource(NULL,MAKEINTRESOURCE(IDR_IDR_EXE_EXEEXTRACTOR),L"IDR_EXE");
now my problem is...
it compiles correctly but at runtime its giving debug assertion failed error.
Is there any other way to Find my resource in VC2005
|
|
|
|
|
It's because UNICODE is enabled by default in VC2005, which was not the case with VC6.
neha.agarwal27 wrote: it compiles correctly but at runtime its giving debug assertion failed error.
Well, you don't provide a lot of usefull information do you ? What is the exact problem ? Where does your code crashes ? Use your debugger to locate the problem more precisely and inspect the state of the different variables before the crash.
|
|
|
|
|
Try
FindResourceA(NULL,MAKEINTRESOURCEA(IDR_IDR_EXE_EXEEXTRACTOR),"IDR_EXE");
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
|
|
|
|
|
CPallini wrote: MAKEINTRESOURCEA()
eurk, that's pretty awful
|
|
|
|
|
toxcct wrote: CPallini wrote:
MAKEINTRESOURCEA()
eurk, that's pretty awful
Nope. That's pretty Awful
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
|
|
|
|
|
Thanks for your solution it implemented correctly.
now i am having same problem with UpdateResource
VERIFY(UpdateResource(hUpdateRes,L"IDR_EXE",MAKEINTRESOURCE(IDR_IDR_EXE_EXEEXTRACTOR),MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
buff,nSize));
same error if i remove it
error C2664: 'UpdateResourceW' : cannot convert parameter 2 from 'const char [8]' to 'LPCWSTR'
how can i use it in VC2005
|
|
|
|
|
I think you can go on using the same approach, i.e.
VERIFY(UpdateResourceA(hUpdateRes,"IDR_EXE",MAKEINTRESOURCEA(IDR_IDR_EXE_EXEEXTRACTOR),MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), buff, nSize));
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
|
|
|
|
|
dear all
anyone can help me to explain code below?
m_hbmp=m_vicImg.hBitmap;
CStatic *pImgPicture=(CStatic*)GetDlgItem(IDC_staImg1);
pImgPicture->SetBitmap(m_hbmp);
i am not good in VC++, i know this is fundamental things.
thanks a lot
Li Zhiyuan
|
|
|
|
|
what don't you understand in this actually ?
this is C code in Win32...
|
|
|
|
|
toxcct wrote: this is C code in Win32...
Actually it's C++ code in MFC
|
|
|
|
|
well there's nothing to see the difference here ^^
|
|
|
|
|
CStatic is a MFC class (WIN32 doesn't have wrapper classes). And C doesn't have classes neither.
So CQFD
|
|
|
|
|
oops, i didn't watch further, and i only saw a pointer to a "user defined type"...lol
CQFD
|
|
|
|
|
li zhiyuan wrote: m_hbmp=m_vicImg.hBitmap;
Assigns to this object's (a CDialog derived class?) m_hbmp member (probably a HBITMAP, i.e. a Bitmap handle) the value of m_vicImg.hBitmap (i.e. the member hBitmap of the m_vicImg object (that you only know and probably is another member of this object).
li zhiyuan wrote: CStatic *pImgPicture=(CStatic*)GetDlgItem(IDC_staImg1);
Gets a pointer to a CStatic object representing the dialog static control having ID equal to IDC_staImg1 .
li zhiyuan wrote: pImgPicture->SetBitmap(m_hbmp);
Calls the SetBitmap method of the CStatic object. This should change the bitmap represented by the dialog static control.
BTW You can also get some information reading MSDN documentation.
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
|
|
|
|
|
You can declare a variable for static control instead make a pointer.
|
|
|
|
|
My Visual Studio Browser keeps attempting to search for items on the web instead of my pc. What can I do to disable this feature ?
I am using visual Studio 97. I tried uninstalling and reloading Visual C++ 5, made no difference.
And all I get is This Program Cannot Display the Web Page. I am running Xp Home Edition.
Thanks
|
|
|
|
|
I am not sure exactly in which place to edit.
Is you machine is connected to a Network (Lan or wan or anything)
if it so then there will be a file in which you will be giving
the host name list. there you have to go and and remove the unwanted
ip. that may solve your problem. I am sorry i cannot recollect
the file name. I m extremely sorry for my poor memory.
|
|
|
|
|
Hi all,
I have the below code:
str.Replace("\r\n", CString((unsigned char)0xB6));
Here i have a CString object 'str' with some string value. It seems '0xB6' stands for line separator or something.. Im not sure.. Well this is the existing code. But when i tried to convert the project to VC++ 2005 i am getting the compile error as:
error C2440: '<function-style-cast>' : cannot convert from 'int' to 'CString'; No constructor could take the source type, or constructor overload resolution was ambiguous.
Kindly help to resolve this error.
Thanks
Priya Sundar
modified on Monday, March 10, 2008 1:03 AM
|
|
|
|
|
just try not to enforce into unsigned char :
str.Replace("\r\n", CString((char)0xB6));
|
|
|
|
|
Yes it did resolve my error. But now i am getting a warning.
"warning C4310: cast truncates constant value"
I need to assign a value between 0 - 127 to resolve the warning. But since the val for 0xb6 is 182, will i not be able to eliminate this warning?
Any suggestions?
Priya Sundar
|
|
|
|
|
Priya_Sundar wrote: Yes it did resolve my error. But now i am getting a warning.
"warning C4310: cast truncates constant value"
I need to assign a value between 0 - 127 to resolve the warning. But since the val for 0xb6 is 182, will i not be able to eliminate this warning?
Any suggestions?
Priya Sundar
The actual range of acceptable values should be -128 to 127, and I think 0xB6 maps to -74. However, I think unsigned char is the right type for what you are doing, and CString requiring a signed character poses a problem. You may be able to use a string "\xB6" instead of a character to initialize the CString.
Nathan
|
|
|
|
|
Try some thing like this,
CString tempStr;
tempStr.Format("%d",0xB6);
str.Replace("\r\n", tempStr);
|
|
|
|
|
There are two overloads of CString::Replace: one takes two LPCTSTR parameters while the other takes two TCHAR parameters.
When converting to Visual C++ 2005 you normally run into two issues:
1. The default character type is now Unicode;
2. The new compiler is more conformant to the C++ standard
Here you have an additional complication that CString has changed significantly (it's now a template, for example).
The MFC 6.0 version would have called the CString constructor that takes a TCHAR ch and an integer nRepeat, which was defaulted to 1. This version of the constructor generated a string of nRepeat copies of ch. This still exists in MFC 8.0 but has been marked explicit , which means that the types must match exactly.
However, calling a CString constructor is unnecessary - you should instead use a string literal.
str.Replace( "\r\n", "\xb6" ); Because of the change to Unicode, you may find you need to put _T() around both string literals.
DoEvents: Generating unexpected recursion since 1991
|
|
|
|
|
Thankyou very much.
My errors are resolved.
Priya Sundar
|
|
|
|
|
I have a C++ win32 console application (built using Visual Studio 2005). I have complete code. I need to convert this console application to a dll and I want to call this DLL in a ASP.Net web service (Just because I know how to create an ASP.Net webservice). I am totally new to C++ programming but now I am getting better at it.
I have successfuly created the DLL of that console app (by changing project properties)and also imported the DLL function successfuly. I can debug the dll code when called from my C#/C++ managed console app (I have tried both C++ and C#).
The problem is when ever the code in DLL uses a std::vector, or any other STL based contianers. The code gives exception i.e.
An unhandled exception of type 'System.AccessViolationException' occurred in C++ManagedConsole.exe
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
can someone please point me to a possible solution for this problem. Though I have the code but I cant just remove all the code using the std::vector, or other containers.
Thanking in advance for any kind of hints.
|
|
|
|