找回密码
 加入
搜索
查看: 473|回复: 9

[网络通信] 【已解决】GUI 控件能够创建字带边框的效果吗?

[复制链接]
发表于 2023-10-14 18:31:03 | 显示全部楼层 |阅读模式
本帖最后由 chishingchan 于 2023-10-14 20:09 编辑

如图:

请教各位,谢谢!

本帖子中包含更多资源

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

×
 楼主| 发表于 2023-10-14 19:04:23 | 显示全部楼层
本帖最后由 chishingchan 于 2023-10-14 19:05 编辑

搜索论坛,看看帮助,弄了一个四不象!
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hFamily, $tLayout

    $hGUI = GUICreate("文字带边框", 240, 50)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF7F7F00)        ;字体颜色
    $hPen = _GDIPlus_PenCreate(0xFFFFFFFF, 3)        ;边框颜色

    $hPath = _GDIPlus_PathCreate()

    $hFamily = _GDIPlus_FontFamilyCreate("宋体")
    $tLayout = _GDIPlus_RectFCreate()
    _GDIPlus_PathAddString($hPath, "说:我是谁", $tLayout, $hFamily, 0, 48, 0)

    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGraphic, 0xFF30A3FE)        ;背景色
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc

本帖子中包含更多资源

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

×
发表于 2023-10-14 19:21:12 | 显示全部楼层
描边效果?
GUICreate('')
GUISetBkColor(0x55ff)
GUISetFont(30, 700)
Local $aPos1[] = [10, 10, 90, 60, '白红']
GUICtrlCreateLabel($aPos1[4], $aPos1[0] - 1, $aPos1[1] - 1, $aPos1[2], $aPos1[3])
GUICtrlSetColor(-1, 0xffffff)
GUICtrlCreateLabel($aPos1[4], $aPos1[0] + 1, $aPos1[1] + 1, $aPos1[2], $aPos1[3])
GUICtrlSetColor(-1, 0xffffff)
GUICtrlSetBkColor(-1, -2)
GUICtrlCreateLabel($aPos1[4], $aPos1[0] + 1, $aPos1[1] - 1, $aPos1[2], $aPos1[3])
GUICtrlSetColor(-1, 0xffffff)
GUICtrlSetBkColor(-1, -2)
GUICtrlCreateLabel($aPos1[4], $aPos1[0] - 1, $aPos1[1] + 1, $aPos1[2], $aPos1[3])
GUICtrlSetColor(-1, 0xffffff)
GUICtrlSetBkColor(-1, -2)
GUICtrlCreateLabel($aPos1[4], $aPos1[0], $aPos1[1], $aPos1[2], $aPos1[3])
GUICtrlSetColor(-1, 0xff2222)
GUICtrlSetBkColor(-1, -2)
GUISetState()
Do
Until GUIGetMsg() = -3
 楼主| 发表于 2023-10-14 19:21:34 | 显示全部楼层
不会调整!


本帖子中包含更多资源

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

×
 楼主| 发表于 2023-10-14 19:23:27 | 显示全部楼层

a 大,边框的大小能调吗?
发表于 2023-10-14 19:40:50 | 显示全部楼层
chishingchan 发表于 2023-10-14 19:23
a 大,边框的大小能调吗?

这种方式不宜设置宽边,要宽边需要GDI+使用路径绘制等方式。如果控件需交互,则处理较繁琐。
直接用Label 叠加处理则可以更简单灵活易懂。如有多个控件也可以直接写成函数调用。
GUICreate('')
GUISetBkColor(0x55ff)
GUISetFont(30, 700, 0, '微软雅黑')
Local $aPos1[] = [10, 10, 90, 60, 2, 0xffffff, 0xff2222, '白红']        ;x ;y ;w; h; 边宽; 边色; 字色
GUICtrlCreateLabel($aPos1[7], $aPos1[0] - $aPos1[4], $aPos1[1] - $aPos1[4], $aPos1[2], $aPos1[3])
GUICtrlSetColor(-1, $aPos1[5])
GUICtrlCreateLabel($aPos1[7], $aPos1[0] + $aPos1[4], $aPos1[1] + $aPos1[4], $aPos1[2], $aPos1[3])
GUICtrlSetColor(-1, $aPos1[5])
GUICtrlSetBkColor(-1, -2)
GUICtrlCreateLabel($aPos1[7], $aPos1[0] + $aPos1[4], $aPos1[1] - $aPos1[4], $aPos1[2], $aPos1[3])
GUICtrlSetColor(-1, $aPos1[5])
GUICtrlSetBkColor(-1, -2)
GUICtrlCreateLabel($aPos1[7], $aPos1[0] - $aPos1[4], $aPos1[1] + $aPos1[4], $aPos1[2], $aPos1[3])
GUICtrlSetColor(-1, $aPos1[5])
GUICtrlSetBkColor(-1, -2)
GUICtrlCreateLabel($aPos1[7], $aPos1[0], $aPos1[1], $aPos1[2], $aPos1[3])
GUICtrlSetColor(-1, $aPos1[6])
GUICtrlSetBkColor(-1, -2)
GUISetState()
Do
Until GUIGetMsg() = -3

评分

参与人数 1金钱 +50 收起 理由
chishingchan + 50 神马都是浮云

查看全部评分

 楼主| 发表于 2023-10-14 19:45:23 | 显示全部楼层
afan 发表于 2023-10-14 19:40
这种方式不宜设置宽边,要宽边需要GDI+使用路径绘制等方式。如果控件需交互,则处理较繁琐。
直接用Labe ...

1# 的文字是 加粗宋体,大小36像素,边框是2像素。将微软雅黑改为宋体,惨不忍睹。
发表于 2023-10-14 19:48:03 | 显示全部楼层
chishingchan 发表于 2023-10-14 19:45
1# 的文字是 加粗宋体,大小36像素,边框是2像素。将微软雅黑改为宋体,惨不忍睹。

所以我上面说了。
 楼主| 发表于 2023-10-14 20:08:29 | 显示全部楼层
afan 发表于 2023-10-14 19:48
所以我上面说了。

放弃了!程序换种方式再写。谢谢!
发表于 2023-10-16 08:45:00 | 显示全部楼层
用html思路会不会容易实现一点?
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-2 11:51 , Processed in 0.076721 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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