|
I am currently writing an MDI app', with views based upon the CFormView. Could someone kindly let me know how I can set these formViews so that they are non -resizeable?
Thanks.
|
|
|
|
|
Add a handler to WM_GETMINMAXINFO and set the ptMinTrackSize and ptMaxTrackSize members of the MINMAXINFO structure to your desired size.
I think that's what I've used in the past, anyway.
|
|
|
|
|
I am creating an application which will read data from a smart card and send it across to a server on the network
it is an MFC dialog based application
i am a starter with VC++
whenever i compile my application it shows me error:
Assertion failure in afxwin1.inl at line 27
the code at line 27 is:
{ ASSERT(afxCurrentAppName != NULL); return afxCurrentAppName; }
if i ignore it my application runs fine
but this error is not fine.
i am using VC++ 6.0
it comes if i add
SCard SCManager;
to be a global variable in my app
SCard definition is:
class SCard : public CWnd
{
public:
SCard();
public:
LONG GetDataString(CString &DataStream, DWORD &dwRecvLength);
CString GetErrorMessage(LONG lReturn);
LONG m_SCardConnect();
void m_SCardSelectReader();
LONG m_SCardReleaseConext();
LONG m_SCardEstablishContext();
CString m_SCardListReaders();
CString m_SelectedReader; // the selected reader
SCARDHANDLE m_hCardHandle; // handle to the card
SCARDCONTEXT m_hSC; //context handle to the card
virtual ~SCard();
protected:
CString m_csReaderList; //list of available readers.
DECLARE_MESSAGE_MAP()
};
please help me
|
|
|
|
|
It's possibly trying to initialise SCManager before your CWinApp instance? Try doing this, see if it makes a difference:
- Declare SCManager as
SCard *SCManager - In your CWinApp's InitInstance, include the code
SCManager = new SCard;
That way, you're delaying the use of CWinApp in SCManager construction until the CWinApp is constructed?
[edit]Forgot to say - global variables are bad, m'kay?[/edit]
|
|
|
|
|
thanks for your interest
but now the code wont compile with 2 errors.
error 1:
error C2040: 'SCManager' : 'class SCard *' differs in levels of indirection from 'class SCard'
AT
SCard *SCManager;
error 2:
error C2582: 'SCard' : 'operator =' function is unavailable
AT
SCManager = new SCard;
-----------------------------------------------------------------------------------
for the 2nd error my opinion is that i will need to override 'operator =' as we do in turbo c++.
i also do have an initial guess
the inline assert says someting about application name
_AFXWIN_INLINE LPCTSTR AFXAPI AfxGetAppName()
{ ASSERT(afxCurrentAppName != NULL); return afxCurrentAppName; }
my idea is if i somehow set afxCurrentAppName to NULL wont it rule out??
|
|
|
|
|
Well, obviously if you change SCManager from SCard to SCard*, you need to alter the references to it - I thought that went without saying - obviously not.
|
|
|
|
|
oops
sorry didnt see that coming
sorry for the lame reply
well now i tried id again
but with more number of errors.
the previous two remain when i have changed all refrences from SCManager.function() to SCManager->function()
new error says that scard does not have an overloaded operator -> ???
what exactly to interpret from this?
in my dialog class i define variable as extern SCard SCmanager how to deal with that?
sorry for the silly questions
wont repeat that..
|
|
|
|
|
Parinay Bansal wrote: how to deal with that?
Read a good book about C++, it seems you are really lacking some fundamuntal C++ skills yet.
If you declare your variable as extern SCard SCmanager; then it means it is not a pointer, thus you have to use the dot and not the "->" to access members. If you declare it as SCard* SCmanager , then you have to use the "->" because it is a pointer.
This is basic C++ and if you can't grasp those concepts, I'm afraid nobody will be able to help you.
|
|
|
|
|
thank you gentlemen
i was missing out on the part "extern SCard SCManager" replaced with "extern SCard *SCManager"
such a fool i have been
yes sir thank you for your advice,
i really must go back to my c++ basics.
It appears that i have missed out on very basic and important lessons which i sould have taken before starting to develop a full fledged application
i will surely do that from now on.
but yes thanks to you, now my code runs with no error.
i will not forget to get back with any other problems i face in the future.
|
|
|
|
|
Hi there!!
I want to embed WMP plugin into a dialogue based MFC application..but i m not etting from where to start anyone can help me in guiding so?
|
|
|
|
|
You need to embed it as an ActiveX control - this[^] seems a good introduction.
|
|
|
|
|
but how to embedd it as an active x ctrl? and infact which file of WMP i need to add to my application?
|
|
|
|
|
alizey khan wrote: how to embedd it as an active x ctrl
Did you read the page I pointed you at? It really isn't difficult - try reading the doucmentation.
alizey khan wrote: infact which file of WMP i need to add to my application
What do you mean? The WMP active X control will be a DLL or OCX file that will have to be installed on the system for your application to work. Either you include it in your installer, or you make an assumption that it's already installed.
|
|
|
|
|
let me rephrase my question:
How can i create an activeX control for WMP 11 using WMP SDK?
can u refer me some link for the steps and WMP11 SDk ASAP...
It will be of great help!
|
|
|
|
|
|
Hi,
I am running a C app and ran into a Buffer Overrun problem
After debugging the program I Found the offending API to be a
strcpy statement
After researching the problem I deduced the that I needed to use the
corresponding string safe api for strcpy ...StringCchCopy
However when I included strsafe.h I got loads of compile errors
I have warnings a W0 -- Turn of all warnings could this be the
problem ????
Thankx
|
|
|
|
|
ForNow wrote: After researching the problem I deduced the that I needed to use the
corresponding string safe api for strcpy ...StringCchCopy
The secure version of strcpy is strcpy_s[^]
ForNow wrote: I have warnings a W0 -- Turn of all warnings
That's very bad practice. Instead of disabling the warnings, why don't you remove them by writing clean code ?
|
|
|
|
|
Thankx I'll give it a shot
|
|
|
|
|
If you've just changed the #include you will get compile errors. StringCchCopy and similar operations take an extra parameter, the length of buffer you are using. Without adding this parameter into the calls you will get errors.
|
|
|
|
|
I got compile errors from the Header strsafe.h
|
|
|
|
|
Can you post some of the errors you're getting?
Steve
|
|
|
|
|
1>hsccmd.c
Maybe its some compiler options I need to set
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(416) : error C2143: syntax error : missing ')' before 'type'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(418) : error C2059: syntax error : ')'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(422) : error C2065: 'hr' : undeclared identifier
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(422) : error C2065: 'pszDest' : undeclared identifier
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(422) : error C2065: 'cchDest' : undeclared identifier
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(424) : error C2065: 'hr' : undeclared identifier
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(426) : error C2065: 'hr' : undeclared identifier
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(426) : error C2065: 'pszDest' : undeclared identifier
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(427) : error C2065: 'cchDest' : undeclared identifier
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(429) : error C2065: 'pszSrc' : undeclared identifier
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(433) : error C2065: 'hr' : undeclared identifier
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(438) : error C2146: syntax error : missing ')' before identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(438) : error C2061: syntax error : identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(438) : error C2059: syntax error : ';'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(438) : error C2059: syntax error : ','
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(440) : error C2059: syntax error : ')'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(535) : error C2146: syntax error : missing ')' before identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(535) : error C2061: syntax error : identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(535) : error C2059: syntax error : ';'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(535) : error C2059: syntax error : ','
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(537) : error C2059: syntax error : ')'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(558) : error C2146: syntax error : missing ')' before identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(558) : error C2061: syntax error : identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(558) : error C2059: syntax error : ';'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(558) : error C2059: syntax error : ','
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(560) : error C2059: syntax error : ')'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(682) : error C2146: syntax error : missing ')' before identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(682) : error C2061: syntax error : identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(682) : error C2059: syntax error : ';'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(682) : error C2059: syntax error : ','
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(687) : error C2059: syntax error : ')'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(802) : error C2146: syntax error : missing ')' before identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(802) : error C2061: syntax error : identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(802) : error C2059: syntax error : ';'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(802) : error C2059: syntax error : ','
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(807) : error C2059: syntax error : ')'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1023) : error C2146: syntax error : missing ')' before identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1023) : error C2061: syntax error : identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1023) : error C2059: syntax error : ';'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1023) : error C2059: syntax error : ','
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1028) : error C2059: syntax error : ')'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1140) : error C2146: syntax error : missing ')' before identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1140) : error C2061: syntax error : identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1140) : error C2059: syntax error : ';'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1140) : error C2059: syntax error : ','
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1145) : error C2059: syntax error : ')'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1332) : error C2146: syntax error : missing ')' before identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1332) : error C2061: syntax error : identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1332) : error C2059: syntax error : ';'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1332) : error C2059: syntax error : ','
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1335) : error C2059: syntax error : ')'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1364) : error C2146: syntax error : missing ')' before identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1364) : error C2061: syntax error : identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1364) : error C2059: syntax error : ';'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1364) : error C2059: syntax error : ','
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1367) : error C2059: syntax error : ')'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1473) : error C2146: syntax error : missing ')' before identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1473) : error C2061: syntax error : identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1473) : error C2059: syntax error : ';'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1473) : error C2059: syntax error : ','
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1476) : error C2059: syntax error : ')'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1508) : error C2146: syntax error : missing ')' before identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1508) : error C2061: syntax error : identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1508) : error C2059: syntax error : ';'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1508) : error C2059: syntax error : ','
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1511) : error C2059: syntax error : ')'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1653) : error C2146: syntax error : missing ')' before identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1653) : error C2061: syntax error : identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1653) : error C2059: syntax error : ';'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1653) : error C2059: syntax error : ','
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1659) : error C2059: syntax error : ')'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1774) : error C2146: syntax error : missing ')' before identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1774) : error C2061: syntax error : identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1774) : error C2059: syntax error : ';'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1774) : error C2059: syntax error : ','
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(1780) : error C2059: syntax error : ')'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2003) : error C2146: syntax error : missing ')' before identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2003) : error C2061: syntax error : identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2003) : error C2059: syntax error : ';'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2003) : error C2059: syntax error : ','
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2009) : error C2059: syntax error : ')'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2122) : error C2146: syntax error : missing ')' before identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2122) : error C2061: syntax error : identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2122) : error C2059: syntax error : ';'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2122) : error C2059: syntax error : ','
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2128) : error C2059: syntax error : ')'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2307) : error C2146: syntax error : missing ')' before identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2307) : error C2061: syntax error : identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2307) : error C2059: syntax error : ';'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2307) : error C2059: syntax error : ','
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2309) : error C2059: syntax error : ')'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2330) : error C2146: syntax error : missing ')' before identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2330) : error C2061: syntax error : identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2330) : error C2059: syntax error : ';'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2330) : error C2059: syntax error : ','
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2332) : error C2059: syntax error : ')'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2421) : error C2146: syntax error : missing ')' before identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2421) : error C2061: syntax error : identifier 'pszDest'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2421) : error C2059: syntax error : ';'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2421) : error C2059: syntax error : ','
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2423) : error C2059: syntax error : ')'
1>C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\strsafe.h(2423) : fatal error C1003: error count exceeds 100; stopping compilation
1
|
|
|
|
|
For 20+yrs C/C++ programmers have been writting programs, without buffer overruns, using strcpy, i find it odd that you _need_ StringCchCopy.
strcpy is also available as an intrinsic which, if you are doing a lot of string copying, can result in a significant performance improvement over StringCchCopy.
The 'safe' versions have been added by MS because of the amount of lazy/poor programming that exists, not because they are needed.
The only legit reason, i see, for using the MS String* functions is an effort to remove all direct references to the CRT, thus removing its direct linking (however, as an intrinsic, strcpy alone does not induce a CRT dependency).
Make sure you include windows.h (winnt.h) before strsafe.h.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
SEH is exactly a good solution for exception handling, but it depends on the stack to call the user-defined exeception handler function, that means, when exception occurs, the OS catch the exception immediately, and it will call the user-defined callback to give the control to the application. If the trouble which caused the exception makes the stack broken, the calling to the user-defined callback may not success, in this situation, the application will not be notified that an exception occurred. Is there anyway to catch the exception in all the cases? whether stack is OK or NG, the mechanism should work.
Thanks.
|
|
|
|
|
Exception handling in general needs to walk the call stack to find handlers. Maybe you can find some way of using C's longjmp to do your exception handling?
|
|
|
|