none
将桌面倒置过来 RRS feed

  • 常规讨论

  • 将窗体覆盖在屏幕上


      Me.Left = 0
      Me.Top = 0
      Me.Height = Screen.Height
      Me.Width = Screen.Width
      Select Case KeyCode
    Case vbKeyLeft 按左方向键屏幕左右对调

       PaintPicture Picture1, Picture1.Width, 0, -Picture1.Width, Picture1.Height, 0, 0, Picture1.Width, Picture1.Height, SRCCOPY

       Case vbKeyRight 按右方向键屏幕上下对调

       PaintPicture Picture1, 0, Picture1.Height, Picture1.Width, -Picture1.Height, 0, 0, Picture1.Width, Picture1.Height, SRCCOPY

       Case vbKeyUp 按上方向键屏幕复原

       PaintPicture Picture1, 0, 0, Picture1.Width, Picture1.Height, 0, 0, Picture1.Width, Picture1.Height, SRCCOPY

       Case vbKeyDown 按下方向键屏幕上下,左右都对调

       PaintPicture Picture1, Picture1.Width, Picture1.Height, -Picture1.Width, -Picture1.Height, 0, 0, Picture1.Width, Picture1.Height, SRCCOPY
       Case vbKeyEscape 按ESC键退出
       Unload Me

       Case Else 按其他键显示出错信息


       MsgBox “无效键", vbOKOnly
       End Select
      End Sub
      Private Sub Form_Load()
      Dim throw As Long

      最小化窗体


      Me.Top = 40
      Me.Width = 40

      得到屏幕图像


      scrndc = GetDC(0)
      Picture1.Width = Screen.Width
      Picture1.Height = Screen.Height
      throw = BitBlt(Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, scrndc, 0, 0, SRCCOPY)
      SavePicture Picture1.Image, “c:\temp.bmp"
      Set Picture1.Picture = LoadPicture(“c:\temp.bmp")
      End Sub
      Private Sub Form_Unload(Cancel As Integer)
      DeleteDC scrndc
      Kill “c:\temp.bmp"
      End Sub

      运行程序用方向键就能控制屏幕翻转,ESC键退出。

      以上程序在我的机子上运行有一点停顿,各位看官的机子一定不比我的差,运行起来自然流畅。其实如果要提高运行速度可以全部用API来做,这样的话就会复杂一点,但还可以实现许多特殊效果,有机会我们下回分解。
    2009年5月27日 8:25