菱形窗口.frm

来自「个人VB学习源码精选,自己学习时的一些编程小程序,希望对大家有帮助」· FRM 代码 · 共 41 行

FRM
41 行
字号
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As PointAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Type PointAPI
    x As Long
    y As Long
End Type

Private Sub Form_Load()
    Dim Ap(4) As PointAPI
    Dim Hx As Long
    Dim Hy As Long
    Dim reRgn As Long
    
    Hy = Me.Height \ (2 * Screen.TwipsPerPixelY)
    Hx = Me.Width \ (2 * Screen.TwipsPerPixelX)
    Ap(0).x = 0: Ap(0).y = Hy
    Ap(1).x = Hx: Ap(1).y = 0
    Ap(2).x = Me.Width \ Screen.TwipsPerPixelX: Ap(2).y = Hy
    Ap(3).x = Hx: Ap(3).y = Me.Height \ Screen.TwipsPerPixelY
    Ap(4) = Ap(0)
    reRgn = CreatePolygonRgn(Ap(0), 5, 1)
    SetWindowRgn Me.hWnd, reRgn, True
End Sub

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?