《顾名思义》 《顾名思义》
关注数: 3 粉丝数: 271 发帖数: 16,601 关注贴吧数: 16
刚刚看到有个绘图的学生 背锯的是我不会用Circle只会用API这就是那个图的API的画法。。。 Private Declare Function AngleArc Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal dwRadius As Long, ByVal eStartAngle As Single, ByVal eSweepAngle As Single) As Long Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As Any) As Long Private Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long Private Declare Function BeginPath Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function EndPath Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function FillPath Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function StrokePath Lib "gdi32" (ByVal hdc As Long) As Long Private Sub Form_Load() Me.AutoRedraw = True Me.FillStyle = 3 '设置成阴影线填充样式 BeginPath Me.hdc MoveToEx Me.hdc, 100, 200, 0 LineTo Me.hdc, 500, 200 MoveToEx Me.hdc, 300, 10, 0 LineTo Me.hdc, 300, 400 MoveToEx Me.hdc, 300, 200, 0 AngleArc Me.hdc, 300, 200, 180, 110, 45 LineTo Me.hdc, 300, 200 AngleArc Me.hdc, 300, 200, 180, 20, 45 LineTo Me.hdc, 300, 200 AngleArc Me.hdc, 300, 200, 180, 200, 45 LineTo Me.hdc, 300, 200 AngleArc Me.hdc, 300, 200, 180, 290, 45 LineTo Me.hdc, 300, 200 EndPath Me.hdc StrokePath Me.hdc '描边 BeginPath Me.hdc MoveToEx Me.hdc, 300, 200, 0 AngleArc Me.hdc, 300, 200, 180, 110, 45 LineTo Me.hdc, 300, 200 AngleArc Me.hdc, 300, 200, 180, 20, 45 LineTo Me.hdc, 300, 200 AngleArc Me.hdc, 300, 200, 180, 200, 45 LineTo Me.hdc, 300, 200 AngleArc Me.hdc, 300, 200, 180, 290, 45 LineTo Me.hdc, 300, 200 EndPath Me.hdc FillPath Me.hdc End Sub
Windows侧边栏的一个空壳 这是效果图。。。以下是代码。。。 Const DI_MASK = &H1 Const DI_IMAGE = &H2 Const DI_NORMAL = DI_MASK Or DI_IMAGE Private Declare Function ExtractAssociatedIcon Lib "shell32.dll" Alias "ExtractAssociatedIconA" (ByVal hInst As Long, ByVal lpIconPath As String, lpiIcon As Long) As Long Private Declare Function DrawIconEx Lib "user32" (ByVal hdc As Long, ByVal xLeft As Long, ByVal yTop As Long, ByVal hIcon As Long, ByVal cxWidth As Long, ByVal cyWidth As Long, ByVal istepIfAniCur As Long, ByVal hbrFlickerFreeDraw As Long, ByVal diFlags As Long) As Long Private Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long Private Sub Form_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single) Dim I As Long Dim hIcon As Long Dim A() As String Me.Cls For I = 1 To Data.Files.Count If (I + 1) * 32 + (I + 1) * 12 * 3 > Me.ScaleHeight Then Me.Height = ((I + 1) * 32 + (I + 1) * 12 * 3) * 15 hIcon = ExtractAssociatedIcon(App.hInstance, Data.Files.Item(I), 0) DrawIconEx Me.hdc, Me.ScaleWidth * 0.5 - 16, (I - 1) * 32 + (I - 1) * 12 * 3, hIcon, 0, 0, 0, 0, DI_NORMAL DestroyIcon hIcon A = Split(Data.Files.Item(I), "\") If A(UBound(A)) = "\" Then Label1.Caption = Data.Files.Item(I) Else Label1.Caption = A(UBound(A)) End If CurrentX = (Me.ScaleWidth - Label1.Width) * 0.5 CurrentY = I * 32 + I * (12 * 3) - 24 Print Label1.Caption Erase A Next DrawStyle = 2 Line (Me.ScaleWidth * 0.5 - 16, (I - 1) * 32 + (I - 1) * 12 * 3)-(Me.ScaleWidth * 0.5 + 16, (I - 1) * 32 + (I - 1) * 12 * 3 + 32), , B DrawStyle = 0 Line (Me.ScaleWidth * 0.5 - 9, (I - 1) * 32 + (I - 1) * 12 * 3 + 16)-(Me.ScaleWidth * 0.5 + 11, (I - 1) * 32 + (I - 1) * 12 * 3 + 16) Line (Me.ScaleWidth * 0.5, (I - 1) * 32 + (I - 1) * 12 * 3 + 5)-(Me.ScaleWidth * 0.5, (I - 1) * 32 + (I - 1) * 12 * 3 + 27) I = Data.Files.Count Me.Height = ((I + 1) * 32 + (I + 1) * 12 * 3 + 24) * 15 Label1.Caption = "请拖放添加" CurrentX = (Me.ScaleWidth - Label1.Width) * 0.5 CurrentY = (I + 1) * 32 + (I + 1) * (12 * 3) - 24 Print Label1.Caption End Sub 画个图还是小意思的,没心情做下去了我的电脑是XP用不到这个玩意。。
关于用数子计算标志 标志确实可以省掉不少的变量。 说到标志很多人都会想到十六进制位运算。。这是微软想到的。 其实我们也可以完全用十进制位 就好比如下: 一个人物时:1表示向上走,2表示向下走,3表示向左走,4表向左走,5表示向左上,6表示向右上,7表示右下,8表示左下 当两个人物时也可以用21表示一个人向上走,一个人向下走 有人会说十进制没有十六方便,可以用Or Xor And 但是事实上都要用到判断语句去查 例如: 要用十六进制表示人物状态 1表示向上走,2表示向下走,4表示向左走,8表向左走 上面看上去确实很方便只用四个标志就能表示8个方向,但是实际上判断起来就麻烦了比如 要检察一个复合标制 10 就要做如下判断 a=10 if (a and 8)=8 then '吐血从这里开始,你还要加上一个IF IF (a and 2)=2 then msgbox "向左下走" Else msgbox "向左下走" endif endif 你一定会说也可以定义8个方向,这样确实可以少做判断,但是复合标志就没有意义了。 当然十进制也不是最好的,比如 一个翻方块游戏,只有两种颜色 黑 白 0,1 这时的十进制就有点背锯同样是一个变量表示3*3的正方形 当所有块为白时,十六进制表示&H1FF就可以了也就是一个Integer变量 而十进确要这样做111111111这个要Long形才可以。。 到底该用十六进制,还是该用十进制,我也有点说不清 还有那个好像是二进制位。。。 你们又是怎么用的?
首页 1 2 3 4 下一页