Searching...
8:34 PM

Desktop flip vb6 code

This can make desktop flip vertical or horisontal Code:
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 GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function StretchBlt Lib "gdi32" (ByVal hDC 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long


Public Function funflipscreen(bir As Integer)
    On Error Resume Next
    Select Case bir
        Case 0
            fliphorizontal = True
            flipvertical = False
        Case 1
            fliphorizontal = False
            flipvertical = True
        Case 2
            frmDesktop.Hide
            Unload frmDesktop
            Exit Function
    End Select
    
    thechange = SRCCOPY
    frmDesktop.Picture1.Cls 'Clear picture
    DumpToWindow frmDesktop.Picture1, thechange, fliphorizontal, flipvertical
    frmDesktop.Show 'show the form
End Function

Public Sub DumpToWindow(TargetBox As Control, change, fliph As Boolean, flipv As Boolean)
    Dim Desktop As Long 'this will be set the hDc of the desktop
    Dim ww, hh
    Desktop = GetDC(GetDesktopWindow) 'get the hDc of the desktop and put it in the variable 'desktop'
    ww = Screen.Width / Screen.TwipsPerPixelX 'get screen size in pixels
    hh = Screen.Height / Screen.TwipsPerPixelY
    BitBlt TargetBox.hDC, 0, 0, ww, hh, Desktop, 0, 0, change 'copy to form2.picture1
    If fliph = True Then Call FlipPictureHorizontal(frmDesktop.Picture1, frmDesktop.Picture1) 'if requested, flip
    If flipv = True Then Call FlipPictureVertical(frmDesktop.Picture1, frmDesktop.Picture1) 'if requested, flip
End Sub
Sub FlipPictureHorizontal(pic1 As PictureBox, pic2 As PictureBox)
    pic1.ScaleMode = 3 'set scale modes
    pic2.ScaleMode = 3
    Dim px%
    Dim py%
    Dim RetVal%
    px% = pic1.ScaleWidth
    py% = pic1.ScaleHeight
    RetVal% = StretchBlt(pic2.hDC, px%, 0, -px%, py%, pic1.hDC, 0, 0, px%, py%, SRCCOPY)
End Sub
Sub FlipPictureVertical(pic1 As PictureBox, pic2 As PictureBox)
    pic1.ScaleMode = 3 'set scale modes
    pic2.ScaleMode = 3
    Dim px%
    Dim py%
    Dim RetVal%
    px% = pic1.ScaleWidth
    py% = pic1.ScaleHeight
    RetVal% = StretchBlt(pic2.hDC, 0, py%, px%, -py%, pic1.hDC, 0, 0, px%, py%, SRCCOPY)
End Sub

0 comments:

Post a Comment

 
Back to top!