|
Hi,
in my applcation,i have graphs, trend graph like that.Each view i have this kind of diagrams..I have to print this page when i press print button in my view page.How can i do that?Till now i didnot work in printers.
Is there tutorial?Pls help me?
Anu
|
|
|
|
|
Hi,
Please use this code.
CPrintDialog printdlg( FALSE );
printdlg.DoModal();
Regards
Velayudhan
|
|
|
|
|
See PrintDlg(...)StartDoc(...)StartPage(...)
|
|
|
|
|
Hi!
I am having problem using CopyFile() function call. I am trying To copy a file which is not a read only file to a new folder created using CreateDirectory(). But Its giving me error numbered 5 saying Access Denied.
I found that whenever I create new directory It is read only by default. I cant change/remove its read only attributes.I am using XP SP2 and I am having administrative rights.
How should I do this? How can I copy file to a readonly folder?
Thx
|
|
|
|
|
sach!! wrote: How can I copy file to a readonly folder?
Did this in a console based application.
#include "windows.h"
DWORD CreateDirWithSecurity(LPCTSTR lpPath)
{
SECURITY_ATTRIBUTES mySecAttrib;
SECURITY_DESCRIPTOR mySecDesc;
PACL pAcl = NULL;
DWORD cbAcl = 0,dwNeeded = 0,dwError = 0;
HANDLE hToken;
PTOKEN_USER ptu = NULL;
if(!OpenProcessToken( GetCurrentProcess(), TOKEN_QUERY, &hToken))
return GetLastError();
GetTokenInformation( hToken, TokenUser, NULL, 0, &dwNeeded);
if(GetLastError() != ERROR_INSUFFICIENT_BUFFER)
{
dwError = GetLastError();
goto clearAll;
}
ptu = (TOKEN_USER*)malloc(dwNeeded);
if (!GetTokenInformation(hToken, TokenUser, ptu, dwNeeded, &dwNeeded))
{
dwError = GetLastError();
goto clearAll;
}
cbAcl = sizeof(ACL) + ((sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD)) + GetLengthSid(ptu->User.Sid));
pAcl = (ACL*) malloc (cbAcl);
if(!InitializeAcl(pAcl, cbAcl, ACL_REVISION))
{
dwError = GetLastError();
goto clearAll;
}
if(!AddAccessAllowedAce(pAcl,ACL_REVISION,GENERIC_ALL|STANDARD_RIGHTS_ALL|SPECIFIC_RIGHTS_ALL,ptu->User.Sid))
{
dwError = GetLastError();
goto clearAll;
}
InitializeSecurityDescriptor(&mySecDesc,SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&mySecDesc,TRUE,pAcl,FALSE);
SetSecurityDescriptorOwner(&mySecDesc,ptu->User.Sid,FALSE);
SetSecurityDescriptorGroup(&mySecDesc,NULL,FALSE);
SetSecurityDescriptorSacl(&mySecDesc, FALSE,NULL,FALSE);
mySecAttrib.nLength = sizeof(SECURITY_ATTRIBUTES);
mySecAttrib.lpSecurityDescriptor = &mySecDesc;
mySecAttrib.bInheritHandle = TRUE;
CreateDirectory(lpPath, &mySecAttrib);
dwError = GetLastError();
clearAll:
if(ptu) free(ptu);
if(pAcl) free(pAcl);
CloseHandle(hToken);
return dwError;
}
int _tmain(int argc, _TCHAR* argv[])
{
CreateDirWithSecurity ("C:\\TestDir");
FILE *fp;
fp=fopen ("C:\\TestDir\\TestMe.txt","a+");
fclose (fp);
CopyFile ("C:\\TestDir\\TestMe.txt","C:\\TestDir\\TestMe1.txt",true);
return 0;
}
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
I have a GUI which uses some of the Registry access functions. What they do is basically read some contents from the windows registry which will be used in the GUI. The problem i face is that, if USER is logged into the machine as ADMIN and then uses the GUI, the GUI is able to read registry contents. But if the USER is logged into machine as restricted USER without ADMIN privilages, then the GUI is not able to read registry contents. I was trying the GUI in DEBUG mode and found that, in restricted USER mode the registry functions are returning a error value (5 or 6). But in ADMIN mode it returns "0" which is the success return value.
Any idea why this problem occurring and any soutions?
Thanks in advance.
|
|
|
|
|
dipuks wrote: have a GUI which uses some of the Registry access functions. What they do is basically read some contents from the windows registry which will be used in the GUI. The problem i face is that,
if you opening registry only for reading, than open reg key with KEY_READ access only, you will not face any problem reading registry key
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
dipuks wrote: But if the USER is logged into machine as restricted USER without ADMIN privilages, then the GUI is not able to read registry contents.
Which indicates you are probably trying to read from the wrong hive. Settings common to all should go in HKLM, while user-specific settings should go in HKU.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello friends,
I am building an MDI application. How do you make the application, main, frame, and any and all views initially displays themselves in their maximized state? Also, how do I make it so that while the user can resize the main application, they can't resize the (child) frames containing a particular view? When I try to modify the create struct (i.e. cs.dwExStyle &= WS_MAXIMIZE) to accomplish that (in every class that has a precreate function), it doesn't work. It seems to launch maximized temporarily, then automatically make it self smaller with out any user prompt.
Any help, as always, would be greatly appreciated.
Sincerely,
BP
|
|
|
|
|
Its may be because, In initinstance, there is call to ShowWindow,comment it, instead add WS_VISIBLE to window style in precreateWindow
Instead you can do this,
Let code in InitInstance be at it is,
In precreatewindow of main frame,add this line,
AfxGetApp()->m_nCmdShow=SW_SHOWMAXIMIZED;
And in child frame precreatewindow this code would be there,
cs.style |=WS_VISIBLE | WS_MAXIMIZE;
|
|
|
|
|
Thank you so much, you answered my question completely.
BP
|
|
|
|
|
Hello
In PPC, I wnat to open a picture viewer in my dialog. I call
pimg.exe and it open the picture viewer in \\My Documents\\My Pictures.
How could I open picture viewer in other path??
Thanks a lot!!
Any suggestion is useful!! Thanks!!
|
|
|
|
|
sdhtyjnniutnbjnhbghb wrote: open the picture viewer in \\My Documents\\My Pictures.
That should be the default path set somewhere in the application.
You can use a file dialog that the user sees on the click of the Browse button. Let the user select the path from the file dialog and then open the image.
See:CFileDialog
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Thanks a lot.
In PPC picture viewer, it already support a browser list to let user select the path. I want to auto select the path in the picture viewer in different condition. So I want to find a method to do it.
Any suggestion is useful!! Thanks!!
|
|
|
|
|
Can you be more specific.
|
|
|
|
|
Now I design a camera UI in PPC. when I press down the album button, it will go to the picture viewer. If the SD Card inserted, I wish the path in the picture viewer will change from \\My Documents\\My Pictures to \\SD Card. So I must find a method to change the path.
Thanks in advance;).
Any suggestion is useful!! Thanks!!
|
|
|
|
|
sdhtyjnniutnbjnhbghb wrote: I call
pimg.exe and it open the picture viewer in \\My Documents\\My Pictures.
How could I open picture viewer in other path??
Does pimg.exe support command-line arguments?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I search the megneto document.
One topic is as below:
Setting the Default Browse Directory
The command line executable pimg is used to specify the default browse directory. This is done by using the option -directory: followed by the name of the desired default directory:
pimg -directory:<directory_path>
But how can use that when the appilcation is running in O.S.??
Any suggestion is useful!! Thanks!!
|
|
|
|
|
sdhtyjnniutnbjnhbghb wrote: But how can use that...
Use either ShellExecute() or CreateProcess() .
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
How can I do that? I tried the function replace, but it doesn't work and I also tried to add \0 to a string before i Added \r\n to the text, but it's not working(Not sure why). I'm starting to run out of idea.
|
|
|
|
|
"This is a null terminated string\0"
You can use the strtok() functions to find \r\n, though it would help if we knew how you are creating the string
char *str = new char [10];
strcpy(str,"hello\r\n");
int x = strlen(str);
str[x-2] = '\0';
x = strlen(str);
delete[] str;
Works for me.
-- modified at 17:46 Sunday 27th August, 2006
|
|
|
|
|
I'm reading the string from a binary file and i replace the null at the end of each lines by \r\n for display purpose in an editbox. After I'm taking the text from the editbox and I want to put it back into the binary file.
here is what i currently have to write it.
The vars:
CFile fVampFile;
String * strInfo = "";
char * cInfo = "";
int iEnd;
The code:
strInfo = eSpeech->Text;
strInfo->Replace("\r\n","\0");
cInfo = (char*)Marshal::StringToHGlobalAnsi(strInfo).ToPointer();
iEnd = strlen(cInfo);
fVampFile.Write(cInfo,iEnd);
-- modified at 17:58 Sunday 27th August, 2006
I forgot to mention this, but the string can have 3 /r/n in it at different places, because each string can have up to 3 sentences in it and all 3 need to end with null.
and the code you gave me removes the /r/n but null isn't added.
|
|
|
|
|
Is thst String a CString or a basic_string ? The CString class has a TrimRight() member that you might want to try.
|
|
|
|
|
It won't work, because i can have up to 3 /r/n in the string.
Also do you know if CFile.write will write the null to the file? I was wondering if it could be the reason why I can't add a null to a string.
|
|
|
|
|
This function should write everything, but the terminating '\0' is not included in string length.
So try fVampFile.Write(cInfo,iEnd + 1);
|
|
|
|