zoukankan      html  css  js  c++  java
  • 应用API函数在用户窗体中画圆

    Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
    Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long                    '
    Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
    Private Declare Function Ellipse Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long


    Sub MyCircle(MyObject As Object, pX As Long, pY As Long, pR As Long, lcColor As Long, lcFill As Long)
    'MyObject 指定圆所在的对象
    '
    'pX 圆心在对象体上X轴
    '
    'pY 圆心在对象体上Y轴
    '
    'pR 圆的半径
    '
    'lcColor 圆的轮廓颜色
    '
    'lcFill 圆的填充色

    Dim hdc As Long, hpen As Long, hcolor As Long
    hdc = GetDC(FindWindow(vbNullString, MyObject.Caption))
    hpen = CreatePen(0, 1, lcColor)
    hcolor = CreateSolidBrush(lcFill)
    SelectObject hdc, hpen
    SelectObject hdc, hcolor
    Ellipse hdc, pX - pR, pY - pR, pX + pR, pY + pR
    DeleteObject hpen
    DeleteObject hcolor
    End Sub
    '

    Private Sub UserForm_Click()
    MyCircle UserForm1, 100, 100, 50, vbRed, vbBlue
    End Sub

  • 相关阅读:
    es6语法快速上手(转载)
    width百分比
    利用switch case 来运行咱们结婚吧
    利用if else来运行咱们结婚吧
    利用if else 来计算车费
    利用switch case判断是今天的第多少天
    利用if else判断是否及格
    利用if,else判断输入的是不是一个正整数
    再练一遍猜拳
    用if else 判断是不是7的倍数等
  • 原文地址:https://www.cnblogs.com/fengju/p/6336285.html
Copyright © 2011-2022 走看看