|
Any C++ project will do fine.
No need for ATL.
you just have to include necessary headers in stdafx.h.
Watched code never compiles.
|
|
|
|
|
STL is the C++ Standard Template Library and it offers a number of useful facilities for coding in C++. It has no connection with either MFC or ATL, both of which are concerned with Windows Programming. Spend some time learning STL and how to apply it to your applications, whether they are console, ATL Windows, Win32 Windows or MFC Windows.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
All good answers. I will spend some time learning STL.
|
|
|
|
|
Other than CString (and not std::string) I use STL for everything else.
std::string is terribly bad!
For non-MFC project, you just need to include atlstr.h for CString (no DLL required).
|
|
|
|
|
Ajay Vijayvargiya wrote: std::string is terribly bad!
I'd be interested to know why, especially as I do not have access to MFC.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Richard MacCutchan wrote: I'd be interested to know why, especially as I do not have access to MFC.
For one, it does not support direct conversion to plain C-style strings. You must call set of methods. It does not support Format/sprintf type of functions, not methods to convert to upper/lower, methods to trim, convert from Unicode/ANSI string and things that should be part of a good "string manipulation class". See wxString, which I prefer over CString!
|
|
|
|
|
Ajay Vijayvargiya wrote: For one, it does not support direct conversion to plain C-style strings
Which is good, because it saves you from a whole class of subtle bugs. Explicit conversion is always better than implicit.
Having said that, I don't like std::string either - it is an example of monolithic design[^]. But that does not mean CString is any better.
|
|
|
|
|
Nemanja Trifunovic wrote: an example of monolithic design[^]
Excellent article, thanks,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
Nemanja Trifunovic wrote: Which is good, because it saves you from a whole class of subtle bugs. Explicit conversion is always better than implicit. Heard of this umpteen number of times, but doesn't appease me at all. I am using a string-class for string, a text, and in C/C++ code it is supposed to mix with C-Style strings. The conversion is implicit to C-string and not from a C-string. You cannot assign a CString to char*/ wchar_t* , the compiler wont be happy. If you say you can put into const char*, and then do forceful conversion, then my friend, you are placing the so called "bug" by yourself.
I mean, what a vector<char> would be called other than std::string ? A good string-class must have string operations. Even in case, I wont have access to CString, I would write my own string-class, or download code written by some expert, instead of using this absurd std::string !
Nemanja Trifunovic wrote: But that does not mean CString is any better. Any better, compared to what?
|
|
|
|
|
I tend to use the console application template and start by removing everything I don't want, so CLR support, stdafx.h etc...
|
|
|
|
|
if you want to use std::string, the best way to get into that is to redefine your string type with something like this:
typedef std::basic_string<tchar, std::char_traits<tchar="">, std::allocator<tchar> > tstring;
typedef std::basic_stringstream<tchar, std::char_traits<tchar="">, std::allocator<tchar> > tstringstream;
using it you dont have to worry if using unicode or ansy character sets
it's really useful!
Saludos!!
____Juan
|
|
|
|
|
Beware useing <and > in messages, since HTML mess them up!
I try to rewrite your message properly. Correct me if I misinterpret.
"
if you want to use std::string , the best way to get into that is to redefine your string type with something like this:
typedef std::basic_string<TCHAR,std::allocator<TCHAR> >tstring;
typedef std::basic_stringstream<TCHAR, std::allocator<TCHAR> > tstringstream;
using it you dont have to worry if using unicode or ansy character sets
"
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
Visual Studio 2010, Windows 7 645 bit.
Objective: Create a CMap Object, store info and retrieve later.
We have (out of context):
typedef CMap<int, int, DWORD*, DWORD*> map_OpenObj;
........................................................................................
map_OpenObj* p_mapObj = NULL;
p_map = new p_mapObj;
........................................................................................
nIdx = some integer;
p_dwObj = (DWORD*)(pointer to some object);
m_pOpenObjMap->SetAt(nIdx, p_dwObj);
.......................................................................................
The above compiles, links and executes without incident with one exception. Later in the application I have:
int nCount = 0;
POSITION posPos = NULL;
nCount = m_pOpenObjMap->GetCount();
posPOS = m_pOpenObjMap->GetStartPosition();
I get nCount = 1, which I would have expected, however posPOS comes back = 0xffffffff, which it shouldn't. This has worked before under Visual Studio 2008. Note: In the application, m_pOpenObjMap will never see ARG or ARG_KEY contain the same values.
The question is what am I doing incorrectly? Any thoughts?
Thanks, Barry
|
|
|
|
|
These words in the documentation[^]
The iteration sequence is not predictable; therefore, the "first element in the map" has no special significance.
look interesting.
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]
|
|
|
|
|
Please allow me to take this to the next level. The map is used to hold class pointers cast to (DWORD)*. When retrieved (CMap->Lookup(...)), they are cast back to theit original type and used. The number of elements at any given point in time in the map varies depending upon how many classes have been created or destroyed. When the application closes, the remaining map entries are cast back to their original pointers then deleted; the map is then destroyed. Obviously, if I just destroy the map, I am left with memory leaks of varying classes.
The question occurs when I am down to just one map entry and it is time to close the application and destroy the last pointer cast DWORD*. How do I retrieve the last remaining item in the map?
|
|
|
|
|
|
What do you mean by proxy aware?
What can your applications not do now that it used to do before?
|
|
|
|
|
by proxy aware i meant to say that the application should detect proxy setting from computer.
I'll try CInternetSession . The third parameter i.e., Access Type Parameter Value INTERNET_OPEN_TYPE_PRECONFIG should do the work.
Future Lies in Present.
Manmohan Bishnoi
|
|
|
|
|
Hello
Iam developing VC++ application in "Visual studio .NET 2005". Application had some problem in windows7, when ever i start the appliction it prompts to the pop window as following "Do you want to allow the following program to make changes your computer".
Some one please help me how to start my application without popup window.
Thanks in advance,
Regards,
bhanu.
|
|
|
|
|
Hi,
You should take a look here.
Regards.
|
|
|
|
|
It sounds like this is a UAC intervention.
What is the name of your program (some names will trigger UAC) and does your program attempt to modify any system information (HEY_LOCAL_MACHINE registry, add files to the Program Files directory or sub-directories, etc)?
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
hello,
Yes, my application access and modifies regestries(HKLM) and also my application was installed in Program files directory.
please advice how to get rid of this problem
Regards,
bhanu.
|
|
|
|
|
bhanu_8509 wrote: Yes, my application access and modifies regestries(HKLM) and also my application was installed in Program files directory.
Two things you are really not supposed to do with Windows 7. Yes, there are exceptions to the rule, but the days of applications having full access to all of Windows are gone.
bhanu_8509 wrote: please advice how to get rid of this problem
Be specific with what you are wanting. A better solution likely exists.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
It is not recommended to modify HKLM and Program Files and many other locations.
These recommendations where true from a very long time.
But since users in XP and earlier OSs where true administrators, this did not pose a problem.
From Vista onwards, a program by default runs without admin privileges.
That is the reason for the prompt.
|
|
|
|
|
Since you are writing to HKEY_LOCAL_MACHINE, I don't think you can prevent the prompt - writing there REQUIRES administrative privilege.
Having your application in the Program Files directory is OK, but modifying or creating files in that directory is a problem also requiring admin privilege.
Even if you create a manifest containing the RequestedExecutionLevel set to "requiresAdministrator" (as some will probably suggest) will not solve it - all that does is when your program starts the user is prompted to enter the administrator password or approve the operation anyway.
As DavidCrow indicated, there is probably a better way to accomplish what you need - perhaps using HKEY_CURRENT_USER instead.
Good luck.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|