CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2000
    Location
    chennai,India
    Posts
    33

    Urgent - How to Convert a Active Form Into a BMP File in Run Time

    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


  2. #2
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: Urgent - How to Convert a Active Form Into a BMP File in Run Time

    Replace your parentheses with curly braces

    sendkeys "%{PRTSC}"

    That should work.


  3. #3
    Join Date
    Dec 2000
    Location
    chennai,India
    Posts
    33

    Re: Urgent - How to Convert a Active Form Into a BMP File in Run Time

    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


  4. #4
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: Urgent - How to Convert a Active Form Into a BMP File in Run Time

    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





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured