|
Hi guys,
I need to print a file (maybe a .doc or 'jpg or whatever), which is identical in functionality to what we do by right clicking the document and giving the print command in the windows explorer.
Is there any way which I can give the document path through the programme and print it irrespective of the exact type (if it is printable)?
I can have the functionality through any event. But, I want to know how to implement the print function once the path is given.
Regards,
A
|
|
|
|
|
I think you should use Process and ProcessStartInfo classes to accomplish this. Use verb property of ProcessStartInfo to specify print command
|
|
|
|
|
Here is the code from There is always the way to do it, but I don't know one of the members
I used it and it worked well
private static void doPrint(string executable, string fileFullPath, string printerName)
{
System.Diagnostics.ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.Arguments = "/h /t \"" + fileFullPath + "\" \"" + printerName + "\"";
startInfo.FileName = executable;
startInfo.UseShellExecute = true;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
System.Diagnostics .Process process = new Process() ;
try {
process = Process.Start(startInfo);
}
catch (Exception ex)
{
}
finally
{
process.WaitForExit(20000);
if (process.HasExited == false)
{
process.Kill();
}
}
}
good luck
|
|
|
|
|
nice. you got 5 from me.
Hessam Jalali wrote: There is always the way to do it, but I don't know
haha. cool name..
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Do you have any ideas on going further than this get the print job to print legal size. I have a varation of this code and I have tried setting the paper source and paper size to be the correct tray and paper kind but Adobe Reader appears to override and still print on letter size all of the time.
GG
|
|
|
|
|
Is it possible to link any dll file with a c# program without knowing any details about it and to get details of the data and functions of it.I tried with explicit linking but i could not.If any could please...
Thanks in advance
kandy
|
|
|
|
|
Do you mean .NET dll or Native one? I guess the answer is yes in both cases but solutions are very different.
|
|
|
|
|
ya..Native dll's.Mostly the driver dlls created by different vendors
|
|
|
|
|
Then you need to use PInvoke with late binding. Search for the keywords.
P.S. If you don't know about the functions that reside in that dll it can be impossible or quite difficult. Why would you need to invoke function from a dll about which you have no information?
|
|
|
|
|
HI,
Use Object Browser for getting the schema definition of the dll file.
Naresh Patel
|
|
|
|
|
Which works if it's a .Net DLL
You could also try dumpbin, but that will only give you the name of the function, not the parameters (unless it exports decorated names, then you can use 'undname' to undecorate the names to retrieve the parameters)
-- modified at 1:29 Wednesday 15th August, 2007
I have no blog...
|
|
|
|
|
Sorry for the delay answering. Actually I was trying for .Net Dlls.
It worked fine.
Let me tell you a scenario where in the user has to choose any kind of dll he wants, rather be .Net Dll or Native Dll for a connection to his server.
In that he knows the function to Invoke.
I need to write a common user interface to invoke any kind of dll, based on the choice of the user. Is that possible ?. If so help me regarding the stratergy that i have to use or any examples of such accomplishment.
FYI
I know one software which is doing to most of the Dll's.
Thanks in Advance
|
|
|
|
|
I am using 400 text box in my Form. Updating Text property of all the 400 Text boxes in the Form takes more than 30 milliseconds. Is there any way to reduce this time in c# .net.
//Sample code
//t2 is the array of 400 Text boxes.
DateTime dt = DateTime.Now;
for (int i = 0; i < 400; i++)
t2[i].Text = i.ToString();
MessageBox.Show(((TimeSpan)(DateTime.Now - dt)).Milliseconds.ToString());
Nanda
|
|
|
|
|
Stop the visual update of the components using the BeginUpdate(), EndUpdate() methods. More importantly though, why do you have so many textboxes on a form? This doesn't sound like a good design to me.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
There is no BeginUpdate() and EndUpdate() methods associated with either the Form or the TextBox.
Thanks for the reply
Nanda
|
|
|
|
|
Hello,
I think Pete meant,
SuspendLayout();
ResumeLayout();
All the best,
Martin
|
|
|
|
|
I have tried those SuspendLayout() and ResumeLayout(). But no improvement.
Thanks for reply
Nanda
|
|
|
|
|
Yes,
I also don't think that the graphic refresh is the bottleneck here.
I don't think there is a bottleneck at all.
I would go with Pete, as he suggested to think of a redesign!
All the best,
Martin
|
|
|
|
|
I did. It's a shame that my only involvement with coding at the moment is writing a design in Word. When you get to my age, the old memory goes and you forget thi..... What was I saying?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Pete O`Hanlon wrote: When you get to my age,
Just wanted to look it up at your profile, but it seems that you also forgot it.
All the best,
Martin
|
|
|
|
|
try this:
Application.DoEvents();
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
Hello,
Tamimi - Code wrote: Application.DoEvents();
Why?
I think this will make it even worse!
All the best,
Martin
|
|
|
|
|
I tried all the options you people have told. Still no improvement.
The scenario is like this,
The application requires updation of 400 - 500 controls. This application is visualization of the hardware circuit(say with 100s of resistors, capacitors and sensors), updation of the values with millisecond accuracy is required. So I don't have any other ways of designing. If any of you can suggest a way to do then it will be helpful.
Thanks in advance
Nanda
|
|
|
|
|
So updating 400 textboxes takes 30 milliseconds.... well lets see... thats more than 13 textboxes updated in 1 thousandth of a second. I'd say that was pretty reasonable performance wouldn't you?
|
|
|
|
|
I know a language labVIEW doing this operation less than a millisecond. The reason am going for .Net is its multilingual capability.
I tried updating 400 textboxes without adding them to the Form.Controls. The same operation takes less than a millisecond. So I suspect the updation of the UI is causing the delay.
Thanks in advance
Nanda
|
|
|
|