This is my first time ever asking something here, so I apologize if I do anything wrong.
I have a problem with a program I am trying to write. What I want to do is have the user pick a folder and the program prints all the documents (mostly a mix of pdf and word files) without any more user interaction.
And to make matters worse, the system I am working in is severely restricted, so my testing possibilities are limited.
Basically, what I want is to do some sort of equivalent of right-click printing in code. Or copy a file to the printer queue.
If anyone could point me in the right direction I would be very grateful. Google isn't much help. I tried executing the print command, but it doesn't do what I want it to.
My current attempt:
void folderFrame::onOpen(wxCommandEvent &event)
{
int listLength;
wxArrayString fileList;
wxString pFolder, pCommand;
chooseFolder = new wxDirDialog(this, _("Please choose folder from which to print:"), "", wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST, wxDefaultPosition, wxDefaultSize,"");
if (chooseFolder->ShowModal() == wxID_OK) //User chooses folder
{
int pResult;
pFolder = chooseFolder->GetPath();
wxDir::GetAllFiles(pFolder, &fileList, "", wxDIR_FILES); //Get all files in folder
listLength = fileList.GetCount(); //Get number of files
for(int i = 0; i < listLength; i++) //For each file...
{
pCommand = _T("print /d:\\\\app065\\300408_P18 "); //Make command to execute
pCommand.append(fileList[i]);
theText->AppendText(fileList[i]); //The text ctrl is to check what commands I actually execute
theText->AppendText("\n"); //And to check if the system return errors
theText->AppendText(pCommand);
theText->AppendText("\n");
pResult = wxExecute(pCommand, wxEXEC_SYNC | wxEXEC_SHOW_CONSOLE | wxEXEC_NOEVENTS, NULL, NULL); //Print!!!!
theText->AppendText(wxString::Format(wxT("%i\n"), pResult));
}
}
}
print .... prints only one file.
copy only returns 0 (success error code, but nothing happens)
So, here I am stuck. Any help getting forward would be greatly appreciated.
/Mike
This actually isn't really hard, since your path hints at Windows. The second parameter of ShellExecute
can be "print"
.