Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving print settings

Status
Not open for further replies.

Sherak

Programmer
Sep 1, 2003
83
GB
Hi

I have a program which prints the contents of a RichEdit, the data it prints needs to be printed in landscape, is there a way of recording the print setting so that you dont have to alter them eveytime you start the program ?...

Regards,
 
Well, i can think of 2 ways:
1: Use the registry. Make some register values with the proper name to save it in. Look in help on TRegistry (hmmm...the spelling..).
2: Make/use a setting-file. This can be done in so many ways but i use to do a:

struct
{
int Printer_Format_Landscape; // true or false
// other settings and such
} Config;

To save the Config:
void __fastcall TForm1::Save_Configuration(char * File_Name)
{
HANDLE Config_File = CreateFile(File_Name,GENERIC_WRITE,0,0,CREATE_ALWAYS,FILE_ATTRIBUTE_ARCHIVE,0);
if(Config_File != INVALID_HANDLE_VALUE)
{
CloseHandle(Config_File);
}
}

To restore the Config:
int __fastcall TForm1::Load_Configuration(char * File_Name)
{
HANDLE Config_File = CreateFile(File_Name,GENERIC_WRITE,0,0,OPEN_EXISTING,FILE_ATTRIBUTE_ARCHIVE,0);
if(Config_File != INVALID_HANDLE_VALUE)
{
CloseHandle(Config_File);
return(true); // All's well
}
return(false); // The file does not exist
}


Totte
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top