Page 1 of 1

Copy window to bmp file

Posted: Tue Jan 17, 2006 3:16 pm
by Jeff Barnes
Hi,

Is there any way to copy a window (or part of a window) to a bmp file?


Thanks,

Jeff

Re: Copy window to bmp file

Posted: Tue Jan 17, 2006 3:29 pm
by Enrico Maria Giordano
For the entire window you can use TWindow:SaveToBmp() method.

EMG

Posted: Tue Jan 17, 2006 5:06 pm
by Jeff Barnes
Thanks for the fast reply Enrico but it does not seem to work.

I get a run time error: Message not found: TWINDOW:SAVETOBMP



Jeff

Posted: Tue Jan 17, 2006 5:10 pm
by Enrico Maria Giordano
This is the method:

Code: Select all

SaveToBmp( cBmpFile ) CLASS TWindow

   local hBmp := WndBitmap( ::hWnd )
   local hDib := DibFromBitmap( hBmp )

   DibWrite( cBmpFile, hDib )
   GloBalFree( hDib )
   DeleteObject( hBmp )

return ( File( cBmpFile ) )
EMG

Posted: Tue Jan 17, 2006 5:24 pm
by Jeff Barnes
Thanks, I've got it working now :-))

Jeff

Posted: Wed Jan 18, 2006 10:07 am
by RAMESHBABU
Mr.EMG

Similar to the above, is there any method to save a dialog to BMP ?

Note : Tried to save a dialog using your above solution. But could not save it.

- Ramesh Babu P

Posted: Wed Jan 18, 2006 10:33 am
by Enrico Maria Giordano
This is a working sample:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    DEFINE DIALOG oDlg

    @ 0,  1 BUTTON "Save BMP" ACTION oDlg:SaveToBmp( "SAVED.BMP" )

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL
EMG

Posted: Wed Jan 18, 2006 6:50 pm
by RAMESHBABU
Mr.Enrico

Thank you very much for your quick answer.

I tried the funciton SaveToBmp("SavedBmp") in association with INIT clause. It did not work. But it is working coolly with ON PAINT clause to save a Dialog to BMP.

Thank you very much for your attendtion.

- Ramesh Babu P

Posted: Wed Jan 18, 2006 7:00 pm
by Enrico Maria Giordano
Try with oDlg:bStart codeblock instead of ON INIT clause. During ON INIT (initialization) the dialog is not painted yet.

EMG

Posted: Thu Jan 19, 2006 3:21 am
by RAMESHBABU
Mr.Enrico,

Good alternative suggestion.

Regards,

- Ramesh Babu P

Posted: Sun Jul 29, 2007 5:11 pm
by RAMESHBABU
Hi all

oDlg:SaveToBmp( "SAVED.BMP" ) was working earlier. Now it is not
working !.

Has any body succeeded with oDlg:SaveToBmp( "SAVED.BMP" ) ?

I am using FWH 2.8 (September 2006) Version + xHarbour 0.99.71 (Simplex)

Thanks

- Ramesh Babu P

Posted: Sun Jul 29, 2007 7:27 pm
by Antonio Linares
Ramesh,

Its working fine with FWH 7.07