Click to See Complete Forum and Search --> : Urgent - How to Convert a Active Form Into a BMP File in Run Time


bala_261175
April 20th, 2001, 10:44 AM
Hi,
I need u peoples Urgent help as I want to convert a Active form into a BMP file in "RUN TIME". I tried thro giving commands

sendkeys "%(PRTSC)"
clipboard.getdata(BMP)

But it is not get copied into the Clip Board. But I did that manually by Pressing Alt and Print Screen Buttons. It is working Fine. But thro code it is not working.
What may be the probelm and please send the solution immedietly.

Regards
bala

shree
April 20th, 2001, 10:54 AM
Replace your parentheses with curly braces

sendkeys "%{PRTSC}"

That should work.

bala_261175
April 20th, 2001, 11:09 AM
Hi,
Actually i missed to put curly braces while posting that. I actually gave curly braces in my code. Still it is not copying my form into the clipboard. This is not working when we give sendkeys during run time.
Please give me the solution.

Regards
Bala

shree
April 20th, 2001, 11:38 AM
Here's the code for Method 1, that I mentioned in your earlier post. You can use the code to print any form as long as you have its hWnd. Replace Me.hWnd in this code with that hWnd.


private Declare Function GetDC Lib "user32" (byval hwnd as Long) as Long
private Declare Function GetDesktopWindow Lib "user32" () as Long
private Declare Function GetClientRect Lib "user32" (byval hwnd as Long, lpRect as RECT) as Long
private Declare Function BitBlt Lib "gdi32" (byval hDestDC as Long, byval X as Long, byval Y as Long, byval nWidth as Long, byval nHeight as Long, byval hSrcDC as Long, byval xSrc as Long, byval ySrc as Long, byval dwRop as Long) as Long
private Declare Function ClientToScreen Lib "user32" (byval hwnd as Long, lpPoint as POINTAPI) as Long
private Type RECT
Left as Long
Top as Long
Right as Long
Bottom as Long
End Type
private Type POINTAPI
X as Long
Y as Long
End Type
private Sub Command1_Click()
Dim hDCDesk as Long, aRect as RECT, topleft as POINTAPI
hDCDesk = GetDC(GetDesktopWindow)
Call GetClientRect(me.hwnd, aRect)
Call ClientToScreen(me.hwnd, topleft)
Call BitBlt(Picture1.hDC, 0, 0, aRect.Right, aRect.Bottom, hDCDesk, topleft.X, topleft.Y, &HCC0020)
Picture1.Refresh
End Sub