|
Well, take the errors one at a time:
"Undeclared identifier" - Sounds like it has something to do with the variable declaration.
For tricky errors like "unknown override specifier" it is a big help to look up the error in the documentation. If you're using Visual Studio you can hit F1 while the cursor is over the error.
If you're not using Visual Studio, you can always google it.
My guess about that error is that you have mistyped the syntax of a function call, and the compiler is misinterpreting what you mean.
Make sure you have entered the ifstream function calls correctly.
Did you write this program, or was it handed out to you?
|
|
|
|
|
Richard,
I like your style....
Rozis
|
|
|
|
|
i want to use CDialog class in API
so i set the project "shared MFC dll"
and include afxwin.h
after, i add the dialog resource and add the class named CTestDlg
finally i code in Proc
"switch(iMessage)
{
case WM_LBUTTONDOWN:
{
CTestDlg dlg;
dlg.DoModal();
}
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}"
it had no error and run well
but when i click Lbutton ,it downs.
i debuged it
and it stoped at
"_AFXWIN_INLINE HINSTANCE AFXAPI AfxGetResourceHandle()
{ ASSERT(afxCurrentResourceHandle != NULL);
return afxCurrentResourceHandle; }"
why it isn't run?
and what should i do to run it?
|
|
|
|
|
At the very least you need to make a call to AfxWinInit() in your WinMain implementation. This will initialize the necessary MFC environment and if available the CWinApp (or your derived implementation). Keep in mind that using MFC on top of a Windows API application can be tricky at times depending on how extensively you use MFC.
while(false != m_OutOfCupcakes)
{
RefuseToWork(INFINITE);
}
|
|
|
|
|
Is there an easy way to find out what type of GDI object is referenced by HGDIOBJ handle i.e. is it a pen, brush, bitmap, font or region? I can't find WINAPI that does the job. Of course, I can always go the tricky way to determine the type of HGDIOBJ hTestedObj: create a dummy hDc, hPen, hBrush, hBitmap, hFont, hRegion; select these dummy objects into hDc, then compare the handle returned by SelectObject(hDc,hTestedObj) with hPen, hBrush, etc. The following code illustrates the idea.
const CHAR* GdiType(HGDIOBJ hTestedObj){
HDC hDc=CreateCompatibleDC(GetDC(NULL));
assert(hDc!=NULL);
HGDIOBJ hPen=GetStockObject(DC_PEN);
HGDIOBJ hBrush=GetStockObject(DC_BRUSH);
HGDIOBJ hFont=GetStockObject(ANSI_FIXED_FONT);
HGDIOBJ hBitmap=CreateCompatibleBitmap(GetDC(NULL),1,1);
assert(hBitmap!=NULL);
HRGN hRegion=CreateRectRgn(0,0,1,1);
assert(hRegion);
HGDIOBJ hTemp=NULL;
hTemp=SelectObject(hDc,hPen);assert(hTemp!=NULL);
hTemp=SelectObject(hDc,hBrush);assert(hTemp!=NULL);
hTemp=SelectObject(hDc,hFont);assert(hTemp!=NULL);
hTemp=SelectObject(hDc,hBitmap);assert(hTemp!=NULL);
hTemp=SelectObject(hDc,hRegion);assert(hTemp!=HGDI_ERROR);
const CHAR *szRet="?";
hTemp=SelectObject(hDc,hTestedObj);
assert(hTemp!=NULL && hTemp!=HGDI_ERROR);
if(hTemp==hPen)szRet="PEN";
else if(hTemp==hBrush)szRet="BRUSH";
else if(hTemp==hFont)szRet="FONT";
else if(hTemp==hBitmap)szRet="BITMAP";
else if(hTemp==hRegion || hTemp==(HGDIOBJ)SIMPLEREGION ||
hTemp==(HGDIOBJ)COMPLEXREGION ||
hTemp==(HGDIOBJ)NULLREGION)szRet="REGION";
DeleteObject(hBitmap);
DeleteObject(hRegion);
DeleteDC(hDc);
return szRet;
}
But this technique seems somewhat awkward (though it works). Perhaps, there is an elegant way to do the same thing?
|
|
|
|
|
Simply make a call to GetObjectType().
|
|
|
|
|
Hi all,
In my SDI type application,on formview i m using a ListCtrl ,when i enter on item of Listctrl than i replace a view from another form view and application throw an exception.
Unhandled exception at afxcoll.inl line 306.
please help me for this.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
Hi i use the icstring (stl insensitive case string) implementation from Adapted from The C++ Standard Library - A Tutorial and Reference by Nicolai M. Josuttis, Addison-Wesley
-> http://www.josuttis.com/libbook/string/icstring.hpp.html
i try to compile it with vs2008 and i have nasty warning :
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\iosfwd(589) : warning C4996: 'std::_Traits_helper::copy_s': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\iosfwd(604) : see declaration of 'std::_Traits_helper::copy_s'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xstring(2155) : see reference to function template instantiation 'std::char_traits<char>::char_type *std::_Traits_helper::copy_s<_Traits>(std::char_traits<char>::char_type *,size_t,const std::char_traits<char>::char_type *,size_t)' being compiled
with
[
_Traits=std::ignorecase_traits
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xstring(2148) : while compiling class template member function 'void std::basic_string<_Elem,_Traits>::_Tidy(bool,unsigned int)'
with
[
_Elem=char,
_Traits=std::ignorecase_traits
]
d:\dev\projet\code\core\io\..\String\icstring(77) : see reference to class template instantiation 'std::basic_string<_Elem,_Traits>' being compiled
with
[
_Elem=char,
_Traits=std::ignorecase_traits
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\iosfwd(607) : warning C4996: 'std::char_traits<char>::copy': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\iosfwd(453) : see declaration of 'std::char_traits<char>::copy'
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\iosfwd(589) : see reference to function template instantiation 'std::char_traits<char>::char_type *std::_Traits_helper::copy_s<_Traits>(std::char_traits<char>::char_type *,size_t,const std::char_traits<char>::char_type *,size_t,std::_Unsecure_char_traits_tag)' being compiled
with
[
_Traits=std::ignorecase_traits
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xstring(2155) : see reference to function template instantiation 'std::char_traits<char>::char_type *std::_Traits_helper::copy_s<_Traits>(std::char_traits<char>::char_type *,size_t,const std::char_traits<char>::char_type *,size_t)' being compiled
with
[
_Traits=std::ignorecase_traits
]
I try a lot of things but the problem seems to be on ms header of _Traits_helper, i don't undestand ?????
...
|
|
|
|
|
Hi All.
I have a simple question...
Lets say I have a C++ DLL with one exposed fucntion.
Now, If this fucntion get called from C++ Source code OR from C# Source code, then do we any difference on the basis of calling language, as far as performace of this DLL[exposed function] is concerned?
In case you need any further information, please let me know.
Thanks
PanB
|
|
|
|
|
Your question is unclear.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Ok.
Lets say I have a Win32 C++ DLL and there is an exposed function Calculation().
Now if I call this function from C++ Source Code OR if I call this from C# Source code, then will there be any performance issue, as far as function Calculation() is concerned?
Thanks.
|
|
|
|
|
What does your profiling test results say?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I have not done any profiling OR I even dont have any setup like that.
Just want to have a view from other side? As per my understanding there should not be any difference in terms of performance. What do you say?
|
|
|
|
|
IIRC it depends on the number and type of parameters you pass to it and the return value. Short functions have significant overhead, especially if they have string arguments.
Why didn't you just test it though?
PankajB wrote: I have not done any profiling OR I even dont have any setup like that.
So which is it?
|
|
|
|
|
It seems that you did'nt get me.
Case 1:
Win32 DLL is being used by C++ application. Called an exposed function, lets say ABC().
Case 2:
Same Win32 DLL is being used now by C# application. Called an exposed function, lets say ABC().
[Previous C++ Application closed. Both of these callings C++/C# are independent to each other]
|
|
|
|
|
Managed code is slower than native, but just for calling a function in a library, I don't think there should be any difference as such. Further more, if you are talking about the execution time of the function within the DLL, that should remain the same (within the DLL), no matter what environment are you executing it from.
I recommend that you do a little profiling and test it out. You don't need any setup as such. VS 2008 has profiling features inbuilt, or you could use a high resolution counter to find out how long has the function taken to execute from within the test environment (native or managed).
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I did get you.
Case 1: nothing to see here, normal case.
Case 2: even if the C++ application was still running, it has nothing to do with it. Nothing. Why did you even bring it up? Anyway, a call from C# to a native function requires marshaling of the arguments and the return value (if it returns), which is obviously slower than not marshaling. The amount of marshaling is (equally obviously) dependent on the number of arguments and their type (so for some types, also of their size)
edit: oh and IIRC the .NET runtime also does some safety checks with regards to the stack, but I don't know what it checks
|
|
|
|
|
The native DLL is compiled. In theory, the functions within it will have the same performance regardless of what program is calling it, be it C++, C#, VBA, etc.. The theory falls down once you look at the program in question as a whole. Due to paging, the memory cache, pipelining issues, how the call is made (i.e interop) and so forth, the actual performance in real world conditions may vary.
|
|
|
|
|
Hi all,
I m working on MFC applications,i have some things by which my application detect by antivirus.
List of actions are mention as follows that is detected by antivirus.
1. Key hook of keyboad.
2. Sending an email by my application.
3. Use Shell execute to run another application.
4. Command use to put an application in startUp.
...
please tell me how can i do all these work without detecting by antivirus.
Please help me for this.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
"_$h@nky_" wrote: I m working on MFC applications,i have some things by which my application detect by antivirus.
List of actions are mention as follows that is detected by antivirus.
1. Key hook of keyboad.
2. Sending an email by my application.
3. Use Shell execute to run another application.
4. Command use to put an application in startUp.
...
please tell me how can i do all these work without detecting by antivirus.
Most of my applications do all of these, most of the time, and none of them were detected as a virus by any AV program. What else is your program doing?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
On other application not detected by any AV.
one more thing that is i m not mentioned,If i m use same code in VB.net than also its detected by AV.
Suggest me some solution for VB.net also.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
A lot of anti-virus/spyware/malware suites will alert users when an application attempts items 1, 2 and 4 on your list IF the application is not digitally signed. Once the user gives that application permission to execute those tasks the AV software is unlikely to show the alert again unless the executable is changed.
Chances are your AV software is displaying an alert every time you recompile because the executable has changed.
|
|
|
|
|
How can i digitally signed my application.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
|
Please provide me any example for apply digital signature.
thanks.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|