Page 2 of 2

Posted: Wed Sep 06, 2006 2:48 am
by Intrigued
Trond wrote:Just replace GetWindowDC_( with GetDC_(.
Ah, I missed that the first time. Thanks Trond. Can I do a mindmeld with you for $100?

:wink:

Posted: Fri Sep 08, 2006 2:20 am
by Intrigued
All was going well until I tried my program that prints out a form on my client's printer.

The printer was a HP LaserJet 2010.

It prints fine for everything else but my program (in another language).

Now, the program prints fine at my house on a couple computers.

But, my client's computer is a 64bit (32 bit processor though) mainboard (motherboard). Would that be the culprit as to the blank page that is printed?

I tried uninstalling the driver-only (they were waiting for the download of the full CD software package and I had to go) and reinstalling, to no avail. I do not see any other screencapture programs loaded or any other programs I am familiar with that could even possible create a problem.

This is a show-stopper for me. If you have any ideas, and I do very much appreciate your help, they would most definitely be appreciated.

Till a response bounces back I will keep thinking on this. I will take a printer over to their shop too and try that out.

TIA

Posted: Fri Sep 08, 2006 9:16 am
by Derek
I tried trond's first program and it works fine but if you change it so that it prints just the client area then you get some garbage at the right and bottom of the page.

When I say garbage I mean part of the screen that your window is on, I guess it has something to do with getting the rectangle size of the window you want to print and then trying to only print the client area.

Extra pixels get added on to the print to make it the same size as the original rectangle.

Posted: Fri Sep 08, 2006 10:59 am
by Derek
Just figured it out.

To print the client area, do like trond said

Just replace GetWindowDC_( with GetDC_

and also replace GetWindowRect_ with GetClientRect_

Posted: Fri Sep 08, 2006 12:41 pm
by Trond
Intrigued wrote:All was going well until I tried my program that prints out a form on my client's printer.
Try this program:

Code: Select all

hActiveWnd = GetForegroundWindow_()
hDC = GetWindowDC_(hActiveWnd)
GetWindowRect_(hActiveWnd, @R.RECT)
With R
  \right - \left
  \bottom - \top
  CreateImage(0, \right, \bottom)
  hPrinterDC = StartDrawing(ImageOutput(0))  
    BitBlt_(hPrinterDC, 0, 0, \right, \bottom, hDC, 0, 0, #SRCCOPY)
  StopDrawing()
EndWith
ReleaseDC_(hActiveWnd, hDC)

OpenWindow(0, 0, 0, 500, 500, "")
CreateGadgetList(WindowID(0))
ImageGadget(0, 0, 0, 0, 0, ImageID(0))

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
If it displays a screenshot of the active window, then the problem is in the printer library or with the printer.

Posted: Fri Sep 08, 2006 3:27 pm
by Intrigued
Okay, I'll have to try that out on the client's system (on my system it showed up fine).

I also had the client try the other version posted here in the thread. I'm waiting for feedback. It's the version that shows the Print dialog box.

Thanks Trond (and others).

I'll post my findings as soon as I get the feedback.

Posted: Sat Sep 09, 2006 1:25 am
by Intrigued
Update:

This morning my client tried out the new .exe with netmaestro's example and that did the trick. Now he can print. It has the printer dialog which in the end is probably best (and what he decided he wanted).

The only setback I see with that approach is that pre-NTFS OSes are left in the cold. Maybe it's time not to worry about Win98/ME? Or should I?

TIA

ps. I also did not have luck netmaestro with your direction with concerns to printing just the Client Area. Maybe I misunderstood. But here is the only thing I changed:

Code: Select all

CallFunction(0,"PrintWindow",win,hdc,0) 
to...

Code: Select all

CallFunction(0,"PrintWindow",win,hdc,1)
Is that correct?

Posted: Sat Sep 09, 2006 3:36 pm
by Derek
If you were to open an invisible window and draw to it so that your client could not see it, how would you go about printing it?

I tried opening a visible window off of the screen but that gets printed as a black rectangle and if you use an invisible window and the code above then all you get is whatever is on the screen under where your invisible window is.

I hope that all makes sense!

basically all I want to do is print a window which is not shown anywhere.

Posted: Sat Sep 09, 2006 4:35 pm
by Trond
Derek wrote: basically all I want to do is print a window which is not shown anywhere.
If it's not shown the way it looks is not stored anywhere.

Posted: Sat Sep 09, 2006 5:01 pm
by Derek
Yeah, I thought as much. I just wondered why you can open an invisible window if its not actually usable for anything and then I thought about trying this, ah well, back to the drawing board.