|
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
|
|
|
|
|
Hi,
i am beginner of vc++ MFC. I don't know MFC with graph development.
I have one text file. It contain one by one inter values like
44
-12
80
32
66
-99
.
.
.
I try MFC dialog use draw x and y axis.(only background based on dialog box width and height). when i press button read the text file and draw a line graph.
pls help me. Any idea or sample code pls share with me.
Regards,
M.Mathivanan
|
|
|
|
|
Read the file with CStdioFile[^] and then, well, plot the graph. I presume you're using some kind of graph control?
It was ever thus, the Neophiles will always rush out and get 'The Latest Thing' at a high price and with all the inherent faults - Dalek Dave.
|
|
|
|
|
mathivanaan wrote: I try MFC dialog use draw x and y axis.(only background based on dialog box width and height).
Your question is not really clear: are you drawing the chart yourself ? If yes, I suggest you use an existing chart control: there are some articles about chart controls on codeproject, and you can have a look at my sig for a link to a chart control I developed.
|
|
|
|
|
Hello Friends
I am using GDIplus to save an Image.I am getting the Graphics reference from Image not from Device.And then m drawing another image of same size (White background with one Red Rectangle) by using DrawImage method of Graphics.
Here is the code below:
CString FileName = "c:\\temp.TIF";
LPCSTR cstr=FileName;
int maxlen=FileName.GetLength()*2;
WCHAR *str=new WCHAR[maxlen];
MultiByteToWideChar(CP_ACP,0,cstr,-1,str,maxlen);
Image image(cstr, FALSE);
Graphics g(&image);
CString str = "c:\\rectangle.TIF";
Bitmap bmp(str);
ImageAttributes attr;
Gdiplus::ColorMatrix cm =
{
1.0f, 0.0f, 0.0f, 0, 0,
0.0f, 1.0f, 0.0f, 0, 0,
0.0f, 0.0f, 1.0f, 0, 0,
0.0f, 0.0f, 0.0f, 0.6f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f, 1.0f
};
attr.SetColorMatrix(&cm, Gdiplus::ColorMatrixFlagsDefault,Gdiplus::ColorAdjustTypeBitmap);
g.DrawImage(&bmp,Gdiplus::Rect(0, 0, bmp.GetWidth(), bmp.GetHeight()), 0,0, bmp.GetWidth(), bmp.GetHeight(),UnitPixel,&attr);
bmp.Save(str,pClsid,NULL);
I used ImageAttributes for Transparency but by using setColorMatrix,It sets transparency for whole image.
Now,I have two problems:
1)I want to set transparency for White pixels so that when I draw rectangle.tif on temp.tif file I can see background.I want to use as layer.
2)When I draw rectangle with ImageAttribute on temp file and then its not saving with transparency info even.
Any Ideas
Thanks In Advance.
Regards
Yogesh
|
|
|
|
|
I hope i understand your questions clearly. Im not using GDIplus (but GDI) and Im not using your program language, but maybe this helps a little:
- to get transparency on the pixellevel every pixel in your bitmap must be 4 bytes (RGBA) and not 3 bytes (RGB). See MSDN for exact info. In the A byte (called alpha channel) you may set the transparency level between 0 and 255. You should use the winapi function Alphablend() (or the gdiplus equevalent) to copy the bitmap to the screen.
- One of the problems with transparent bitmaps is that when you put them on screen the transparency is visible but this information is lost (on the screen). Let me explain this: Suppose you want to fade in a bitmap. Then for every step you must first repaint the background (that what wad on the screen before the bitmap was painted on it) and then copy the transparent bitmap on it, decreasing transparency in every step. If you don't repaint the background first you will not get the desired result (but a transparent bitmap on a tranparent bitmap).
The screen has no transparency set (it is a RGB-surface) so saving it will result in a bitmap that only shows 'what was on screen'. Transparency is a property of a bitmap not of the screen that displays it (the screen shows the result only).
Hope this helps a bit...
Good luck,
Rozis
|
|
|
|
|
Thanks Rozis and It helps a lot and am looking further.
|
|
|
|
|
Hi!
Can anybody explain me why the constructor of a singleton class is declared as private? What would happen if it is not declared as private?
|
|
|
|
|
pix_programmer wrote: why the constructor of a singleton class is declared as private?
because out of the class, object could not be instantiated
pix_programmer wrote: What would happen if it is not declared as private?
If you leave its constructor as public, the class won't be singleton anymore!
Navigate the Given link to know about singleton in Details
Singleton pattern
[^]
Hope It will works for you.
|
|
|
|
|