找回密码
 加入
搜索
查看: 3879|回复: 12

[系统综合] 【已解决】文字提示后台显示问题求解

  [复制链接]
发表于 2010-10-17 10:48:53 | 显示全部楼层 |阅读模式
本帖最后由 touch_xu 于 2010-10-18 10:07 编辑
While 1
      ToolTip("这儿是可变的文本内容",@DesktopWidth-305,@DesktopHeight-125,"重要提示:",2)
        Sleep(1000)
WEnd
如是面代码,我想让显示的内容,一直存在,但是要在后台显示,不要挡住新的窗口,不要告诉我用壁纸,怎么做,谢谢!

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2010-10-17 10:52:54 | 显示全部楼层
这种提示好像是顶层的吧,不明了
 楼主| 发表于 2010-10-17 10:57:38 | 显示全部楼层
想要的就是不置顶,有没有什么方法,请教一下
发表于 2010-10-17 12:59:52 | 显示全部楼层
#include <array.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WINAPI.au3>
#include <sendmessage.au3>
#Region ### START Koda GUI section ### Form=

#NoTrayIcon

HotKeySet("ESC", "_Exit")
Local $String='这里是可变内容'&@CRLF&'这里是第二行'&@CRLF&'这里是第三行'&@CRLF&'这里是第四行'
$a=_stringSize($String,18,800,6,'宋体');待测试字符串,字体大小,字体重量(400 =缺省值),字体属性,字体名字
 
$form1 = GUICreate("form1",  $a[2],$a[3] ,@DesktopWidth-$a[2],@DesktopHeight-$a[3]-30,BitOR($WS_POPUP, $WS_EX_TOPMOST),$WS_EX_LAYERED,WinGetHandle(AutoItWinGetTitle()))
GUIctrlSetBkColor(-1,0xABCDEF)
 
GUICtrlCreateLabel($String,0,0,$a[2],$a[3])
GUICtrlSetFont(-1,18,800,6,'宋体');这里参数和_stringsize()参数保持一致
GUIctrlSetBkColor(-1,0xABCDEF)

_WinAPI_SetLayeredWindowAttributes($form1, 0xABCDEF)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
WinSetOnTop($form1,"form1",1)
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_PRIMARYDOWN
            _SendMessage($form1, $WM_SYSCOMMAND, 0xF012, 0)
    EndSwitch
WEnd
GUIDelete($form1)
Exit
 
Func _Exit()
    Exit
EndFunc

#include-once
Func _StringSize($sText, $iSize = Default, $iWeight = Default, $iAttrib = Default, $sName = Default, $iWidth = 0)
 
    Local $avSize_Info[4], $aRet, $iLine_Width = 0, $iLast_Word, $iWrap_Count
    Local $hLabel_Handle, $hFont, $hDC, $oFont, $tSize = DllStructCreate("int X;int Y")
    If Number($sName) = -1 Then $sName=""
    If Not IsString($sText) Then Return SetError(1, 1, 0)
    If Not IsNumber($iSize) And $iSize <> Default   Then Return SetError(1, 2, 0)
    If Not IsInt($iWeight)  And $iWeight <> Default Then Return SetError(1, 3, 0)
    If Not IsInt($iAttrib)  And $iAttrib <> Default Then Return SetError(1, 4, 0)
    If Not IsString($sName) And $sName <> Default   Then Return SetError(1, 5, 0)
    If Not IsNumber($iWidth) Then Return SetError(1, 6, 0)
    Local $hGUI = GUICreate("", 1200, 500, 10, 10)
        If $hGUI = 0 Then Return SetError(2, 0, 0)
        GUISetFont($iSize, $iWeight, $iAttrib, $sName)
    $avSize_Info[0] = $sText
    If StringInStr($sText, @CRLF) = 0 Then StringRegExpReplace($sText, "[\x0a|\x0d]", @CRLF)
    Local $asLines = StringSplit($sText, @CRLF, 1)
    Local $hText_Label = GUICtrlCreateLabel($sText, 10, 10)
    Local $aiPos = ControlGetPos($hGUI, "", $hText_Label)
    GUISetState(@SW_HIDE)
    GUICtrlDelete($hText_Label)
    $avSize_Info[1] = ($aiPos[3] - 8)/ $asLines[0]
    $avSize_Info[2] = $aiPos[2]
    $avSize_Info[3] = $aiPos[3] - 4
 
    If $aiPos[2] > $iWidth And $iWidth > 0 Then
        $avSize_Info[0] = ""
        $avSize_Info[2] = $iWidth
        Local $iLine_Count = 0
        For $j = 1 To $asLines[0]
            $hText_Label = GUICtrlCreateLabel($asLines[$j], 10, 10)
            $aiPos = ControlGetPos($hGUI, "", $hText_Label)
            GUICtrlDelete($hText_Label)
            If $aiPos[2] < $iWidth Then
                $iLine_Count += 1
                $avSize_Info[0] &= $asLines[$j] & @CRLF
            Else
                $hText_Label = GUICtrlCreateLabel("", 0, 0)
                $hLabel_Handle = ControlGetHandle($hGui, "", $hText_Label)
                $aRet = DllCall("User32.dll", "hwnd", "GetDC", "hwnd", $hLabel_Handle)
                If @error Then _StringSize_Error(3, 1, $hLabel_Handle, 0, $hGUI)
                $hDC = $aRet[0]
                $aRet = DllCall("user32.dll", "lparam", "SendMessage", "hwnd", $hLabel_Handle, "int", 0x0031, "wparam", 0, "lparam", 0) ; $WM_GetFont
                If @error Then _StringSize_Error(3, 2, $hLabel_Handle, $hDC, $hGUI)
                $hFont = $aRet[0]
                $aRet = DllCall("GDI32.dll", "hwnd", "SelectObject", "hwnd", $hDC, "hwnd", $hFont)
                If @error Then _StringSize_Error(3, 3, $hLabel_Handle, $hDC, $hGUI)
                $oFont = $aRet[0]
                If $oFont = 0 Then _StringSize_Error(3, 4, $hLabel_Handle, $hDC, $hGUI)
                $iWrap_Count = 0
 
                While 1
                    $iLine_Width = 0
                    $iLast_Word = 0
 
                    For $i = 1 To StringLen($asLines[$j])
                        If StringMid($asLines[$j], $i, 1) = " " Then $iLast_Word = $i - 1
                        Local $sTest_Line = StringMid($asLines[$j], 1, $i)
                        GUICtrlSetData($hText_Label, $sTest_Line)
                        $iSize = StringLen($sTest_Line)
                        DllCall("GDI32.dll", "int", "GetTextExtentPoint32", "hwnd", $hDC, "str", $sTest_Line, "int", $iSize, "ptr", DllStructGetPtr($tSize))
                        If @error Then _StringSize_Error(3, 5, $hLabel_Handle, $hDC, $hGUI)
                        $iLine_Width = DllStructGetData($tSize, "X")
                        If $iLine_Width >= $iWidth - Int($iSize / 2) Then ExitLoop
                    Next
                    If $i > StringLen($asLines[$j]) Then
                        $iWrap_Count += 1
                        $avSize_Info[0] &= $sTest_Line & @CRLF
                        ExitLoop
                    Else
                        $iWrap_Count += 1
                        If $iLast_Word = 0 Then
                            _StringSize_Error(4, 0, $hLabel_Handle, $hDC, $hGUI)
                        EndIf
                        $avSize_Info[0] &= StringLeft($sTest_Line, $iLast_Word) & @CRLF
                        $asLines[$j] = StringTrimLeft($asLines[$j], $iLast_Word)
                        $asLines[$j] = StringStripWS($asLines[$j], 1)
                    EndIf
 
                WEnd
 
                $iLine_Count += $iWrap_Count
                DllCall("User32.dll", "int", "ReleaseDC", "hwnd", $hLabel_Handle, "hwnd", $hDC)
                If @error Then _StringSize_Error(3, 6, $hLabel_Handle, $hDC, $hGUI)
                GUICtrlDelete($hText_Label)
            EndIf
        Next
 
                $avSize_Info[3] = ($iLine_Count * $avSize_Info[1]) + 4
    EndIf
 
    GUIDelete($hGUI)
    Return $avSize_Info
 
EndFunc ; => _StringSize
 
Func _StringSize_Error($iError, $iExtended, $hLabel_Handle, $hDC, $hGUI)
    DllCall("User32.dll", "int", "ReleaseDC", "hwnd", $hLabel_Handle, "hwnd", $hDC)
    GUIDelete($hGUI)
    Return SetError($iError, $iExtended, 0)
EndFunc ; => _StringSize_Error

评分

参与人数 1金钱 +30 收起 理由
afan + 30

查看全部评分

发表于 2010-10-17 18:15:59 | 显示全部楼层
膜拜楼上  效率真高啊!
发表于 2010-10-17 20:45:20 | 显示全部楼层
4楼是偶像
10bitpatch。exe
 楼主| 发表于 2010-10-18 10:05:56 | 显示全部楼层
谢谢,已经解决.如果能加过边框就更好看了.
发表于 2010-10-18 11:52:51 | 显示全部楼层
回复 5# 蜘蛛抱蛋
可别这么说,我还是只小小小菜鸟。
发表于 2010-10-18 11:54:54 | 显示全部楼层
回复 6# cxlater
呵呵,我的偶像可不少啊。
像P大,Afan大人,C.L兄。。。。多得数不过来啊。
发表于 2011-1-26 21:34:57 | 显示全部楼层
高啊。佩服之至
发表于 2011-1-27 21:19:41 | 显示全部楼层
佩服啊 真是有才 !!
发表于 2011-1-27 21:19:50 | 显示全部楼层
佩服啊 真是有才 !!
发表于 2011-2-17 19:49:24 | 显示全部楼层
厉害哦,学习了。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-19 23:28 , Processed in 0.092538 second(s), 29 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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