找回密码
 加入
搜索
查看: 3236|回复: 10

[AU3基础] 请教如何在GUI上画一条水平的横线?[已解决]

  [复制链接]
发表于 2015-3-6 22:06:21 | 显示全部楼层 |阅读模式
本帖最后由 smooth 于 2015-3-10 19:43 编辑

请教如何在GUI上画一条水平的横线?同理,竖线又如何画?谢谢!
发表于 2015-3-6 22:33:18 | 显示全部楼层
我一般是画个Lable标签高度为1,设置颜色。
 楼主| 发表于 2015-3-6 23:06:55 | 显示全部楼层
本帖最后由 smooth 于 2015-3-6 23:07 编辑
我一般是画个Lable标签高度为1,设置颜色。
lpxx 发表于 2015-3-6 22:33



    这不失为一种方法。但竖线就没法这样搞了。
发表于 2015-3-7 04:25:49 | 显示全部楼层
本帖最后由 netegg 于 2015-3-7 04:43 编辑

[au3]#include <WindowsConstants.au3>
#include <WinAPI.au3>

local $gui = GUICreate('mygui', 200, 200)
GUISetState()
ShowCross(100, 100, 20, 1, 0xFF);, 3000)

Do
        Sleep(100)
Until  GUIGetMsg() =-3
exit
Func ShowCross($start_x, $start_y, $length, $width, $color)
    Local $hDC, $hPen, $obj_orig

    $hDC = _WinAPI_GetWindowDC($gui) ; 全部屏幕的场景(桌面)
    $hPen = _WinAPI_CreatePen($PS_SOLID, $width, $color)
    $obj_orig = _WinAPI_SelectObject($hDC, $hPen)

    _WinAPI_DrawLine($hDC, $start_x - $length, $start_y, $start_x - 5, $start_y) ; 水平左
    _WinAPI_DrawLine($hDC, $start_x + $length, $start_y, $start_x + 5, $start_y) ; 水平右
    _WinAPI_DrawLine($hDC, $start_x, $start_y - $length, $start_x, $start_y - 5) ; 垂直上
    ;_WinAPI_DrawLine($hDC, $start_x, $start_y + $length, $start_x, $start_y + 5) ; 垂直下
    _WinAPI_MoveTo($hDC, $start_x, $start_y + $length)
    _WinAPI_LineTo($hDC, $start_x, $start_y + 5)

;   Sleep($time) ; 穿过屏幕几秒

    ; 刷新桌面(清扫穿过)
    _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE + $RDW_ALLCHILDREN)

    ; 清除资源
    _WinAPI_SelectObject($hDC, $obj_orig)
    _WinAPI_DeleteObject($hPen)
    _WinAPI_ReleaseDC(0, $hDC)
EndFunc[/au3]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×

评分

参与人数 1金钱 +10 收起 理由
lpxx + 10 感谢蛋蛋,学习了。

查看全部评分

发表于 2015-3-7 15:49:29 | 显示全部楼层
这不失为一种方法。但竖线就没法这样搞了。
smooth 发表于 2015-3-6 23:06


竖线的话,宽度为1,高度自定义啊。
发表于 2015-3-7 21:42:00 | 显示全部楼层
本帖最后由 shqf 于 2015-3-7 21:44 编辑

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 406, 247, 192, 124)
GUICtrlCreateLabel("", 10, 10, 10, 200, $SS_ETCHEDVERT);竖线
GUICtrlCreateLabel("", 10, 10, 200, 10, $SS_ETCHEDHORZ);横线
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd
发表于 2015-3-8 00:53:40 | 显示全部楼层
回复 6# shqf
虽说效果差不多,不过是凹陷的吧
发表于 2015-3-8 15:36:37 | 显示全部楼层
本帖最后由 shqf 于 2015-3-8 15:37 编辑

如下代码显示的线条好像不凹了,不知是否达到楼主的要求,就是没啥技术含量:

$Label1 = GUICtrlCreateLabel("", 10, 200, 400, 1)
GUICtrlSetBkColor(-1, 0xFF0000)
$Label2 = GUICtrlCreateLabel("", 210, 10, 1, 400)
GUICtrlSetBkColor(-1, 0xFF0000)
发表于 2015-3-8 17:03:58 | 显示全部楼层
回复 8# shqf

这不错
发表于 2015-3-9 13:20:34 | 显示全部楼层
本帖最后由 vigiles 于 2015-3-9 13:21 编辑

GUICtrlCreateGraphic,GUICtrlSetGraphic 也可以
发表于 2016-3-23 18:11:49 | 显示全部楼层
回复 8# shqf

简单粗暴,很好!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-29 02:13 , Processed in 0.111280 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表