|
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.
|
|
|
|
|
To forbid anybody to create an instance of the class. The idea of a singleton (as its name suggest) is that only one instance of the class exist. If you have a public constructor, it means that anybody can create instances of the class. When the constructor is declared public, if you try to instantiate the class outside of itself, the code will generate an error.
So, if you make the constructor public, nothing will "happen" directly but your design is flawed: you are not sure anymore that your class can be instantiated multiple times.
|
|
|
|
|
As others have pointed out, the idea is that the implementation of a singleton class has full control over the property of ever having only one instance. So you need to make sure that there is no way to create a second instance, if one is already in existance, meaning:
1. You can not create an instance with a constructor without going through the class's code
2. You can not copy an (i. e. the only existing) instance to make another one
3. You can access the one existing instance or create it from anywhere
The first is achieved by not providing a constructor that is public. The problem however is, that the C/C++ compiler implicitely always creates a default constructor if there is no other, and that default constructor would be dclared as public! Therefore we mus explicitely declare a default constructor that is private to prevent the compiler from creating a public one.
The second would be achieved by not creating a copy constructor, but again, the compiler implicitely creates one if there is no other. The safest way to prevent this is again, to explicitely define a private copy constructor.
The third can be achieved by defining a static function that delivers a reference or pointer to the one instance in existance. This function can check whether there already is an instance and retrun that, or if there is none, use the private constructor to create it.
|
|
|
|
|
Very good explaination! Deserves a 5!
|
|
|
|
|
Hi all
How can i write Special character in CSV File(like ,)?
Please help me
|
|
|
|
|
Hi,
You may use the separator parameter of a std::ostream_iterator , for instance:
#include <iostream>
#include <iterator>
int main()
{
int vals[] = {1, 2, 3 ,4, 5};
std::copy_n(vals, 5, std::ostream_iterator<int>(std::cout, ","));
}
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
Thanks for reply
I use like this
CStdioFile test;
CString itemtext="ABC,123";
CString itemtextm="1";
if (test.Open"C:\\Test.csv"CFile::modeCreate | CFile::modeWrite | CFile::modeNoTruncate))
{
test.Seek(0,CFile::end);
test.WriteString("Name");
test.WriteString(",");
test.WriteString("Class");
test.WriteString("\n");
.WriteString(itemtext);
test.WriteString(",");
test.WriteString(itemtextm);
test.WriteString("\n");
test.Close();
}
Now problem is that itemtext comes with two column.I want to Write this(itemtext)in Single Column. Please help me
|
|
|
|
|
With your code the output should be Name,Class\nABC,123,1\n. What output do you want with the same input?
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
As far as I understood, he wants the string "ABC,123" be considered as one column in the CSV file. But this has nothing to do with C++, rather with the CSV syntax in which he has put double quotes around the field.
|
|
|
|
|
I am not very good at guess games
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
Well, spending a lot of time in the programming forums improves that a lot...
|
|
|
|
|
This has nothing to do with C++ but rather to the CSV format. If you google for the format specification (see here[^] for instance) you can see that:
Fields with embedded commas must be enclosed within double-quote characters.
|
|
|
|
|
|
How is the correct way to subclassing my CHeaderCtrl class into my CListCtrl ?
Let say I have CListCtrlEx , ( public of CListCtrl ) , and I have a CHeaderCtrlEx class ( public of CHeaderCtrl ) and I need to subclassing into CListCtrlEx ... how it's correct way to do it ?
I tell you for what I need subclassing : I want to improve my CListCtrlEx class to CHeaderCtrlEx class from here[^] and saw there , that CHeaderCtrlEx is subclassing into CListCtrlEx ...
|
|
|
|
|
For a dialog it could be performed as following :
BOOL CYourDialog::OnInitDialog()
{
BOOL bResult = CDialog::OnInitDialog();
CHeaderCtrl* pcOriginalHeader(m_cListCtrl.GetHeaderCtrl());
if (pcOriginalHeader->GetSafeHwnd()) {
m_cHeader.SubclassWindow(pcOriginalHeader->GetSafeHwnd());
}
return bResult;
}
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap.
|
|
|
|
|
And what if I create the list control dinamicaly ( with Create ) ?
int CTestList3View::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if(CListView::OnCreate(lpCreateStruct) == -1)return -1;
DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_TABSTOP | LVS_REPORT;
BOOL bResult = m_List1.Create(dwStyle,CRect(0,0,0,0),this,IDC_LIST1);
return (bResult ? 0 : -1);
}
|
|
|
|
|