#SingleInstance, Force #NoEnv SetBatchLines, -1 OnExit, Exit CustomTrayTip("消息通知:","仿win10 TrayTip通知样式,可用在win7或托盘图标隐藏的脚本上!",1,True) Sleep,4000 ExitApp Return ;;;================================================================================================ /* ; By 蜜獾哥 仿win10 TrayTip通知,可用在win7或托盘图标隐藏的脚本上! title:标题 text:内容 Mode:1消息,2警告,3错误 Dark:true深色模式,False浅色模式 Transparent:透明度[0-255],0透明,255不透明 Timeout:显示时长 */ CustomTrayTip(title,text:="",Mode=1,Dark:=True,Transparent:=225,Timeout:=3500){ ;;Critical Global CTToken,hCTT,CTTimer Static Index if (title=""&&text=""){ Return } Gosub FormatString TitleFntSize:=22,TextFntSize:=20,Transparent:=Transparent>255?255:Transparent<0?0:Transparent NumPut(VarSetCapacity(info, A_IsUnicode ? 504 : 344, 0), info, 0, "UInt") DllCall("SystemParametersInfo", "UInt", 0x29, "UInt", 0, "Ptr", &info, "UInt", 0) SystemFontName:=StrGet(&info + 52)?StrGet(&info + 52):"宋体" if !DllCall("GetModuleHandle", "str", "gdiplus", "UPtr") DllCall("LoadLibrary", "str", "gdiplus") VarSetCapacity(si, A_PtrSize = 8 ? 24 : 16, 0), si := Chr(1) DllCall("gdiplus\GdiplusStartup", "UPtr*", CTToken, "UPtr", &si, "UPtr", 0) If !CTToken { MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system ExitApp } Gui, TT: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs +HWNDhCTT -DPIScale Gui, TT: Show, NA VarSetCapacity(bi, 40, 0),NumPut(40, bi, 0, "uint"),NumPut(1, bi, 4, "uint") NumPut(1, bi, 8, "uint"),NumPut(1, bi, 12, "ushort"),NumPut(32, bi, 14, "ushort"),NumPut(0, bi, 16, "uInt") hbm := DllCall("CreateDIBSection", "UPtr", DllCall("GetDC", "UPtr", 0), "UPtr", &bi, "uint", 0, "UPtr*", 0, "UPtr", 0, "uint", 0, "UPtr") hdc := DllCall("CreateCompatibleDC", "UPtr", 0) obm := DllCall("SelectObject", "UPtr", hdc, "UPtr", hbm), DllCall("gdiplus\GdipCreateFromHDC", "UPtr", hdc, "UPtr*", G) DllCall("gdiplus\GdipCreateFontFamilyFromName", "WStr", SystemFontName, "uint", 0, "UPtr*", hFamily) If !hFamily DllCall("gdiplus\GdipGetGenericFontFamilySansSerif", "UPtr*", hFamily) DllCall("gdiplus\GdipCreateFont", "UPtr", hFamily, "float", TitleFntSize, "int", text=""&&title<>""?0:1, "int", 0, "UPtr*", tFont) DllCall("gdiplus\GdipCreateFont", "UPtr", hFamily, "float", TextFntSize, "int", 0, "int", 0, "UPtr*", hFont) DllCall("gdiplus\GdipStringFormatGetGenericDefault", "UPtr*", tFormat) DllCall("gdiplus\GdipStringFormatGetGenericDefault", "UPtr*", hFormat) VarSetCapacity(TempRC, 16) DllCall("gdiplus\GdipMeasureString", "UPtr", G, "WStr", title, "int", -1, "UPtr" , tFont, "UPtr", &RC, "UPtr", hStringFormat, "UPtr", &TempRC, "uint*", 0, "uint*", 0) TitleRC:=[NumGet(TempRC, 0, "float"),NumGet(TempRC, 4, "float"),NumGet(TempRC, 8, "float"),NumGet(TempRC, 12, "float")] VarSetCapacity(TempRC, 16) DllCall("gdiplus\GdipMeasureString", "UPtr", G, "WStr", Text, "int", -1, "UPtr" , hFont, "UPtr", &RC, "UPtr", hStringFormat, "UPtr", &TempRC, "uint*", 0, "uint*", 0) TextRC:=[NumGet(TempRC, 0, "float"),NumGet(TempRC, 4, "float"),NumGet(TempRC, 8, "float"),NumGet(TempRC, 12, "float")] base64_1= (join`r`n LTrim iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAABMVJREFUeF7tm02IHEUUx/+vdyN+BrZHo h4Mxp3uJQGPJnrQQ7KKB00O4kEURPBjtyYnAyqKHhTFCHrK1q4fIIKoJyGJAdHVgx408ZiD7PRsIuZgEu1e8DPETT/puGN2Z7qnq7urqxtmF/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9ABnA3r0iM58n97JAo8ehTRm/sIFU69zZMIhJaiVeNcSKyiAUANAz57JAo83Q9bWAi3Wga4cmHC1 JdYKNrprio5+EDT+0WTxJ05EZ/7cOdOZT3pMpessbdwE3rPHdry2A4TAKAO8jH8XcNsWp4kTQA/cn1jUHycha9cBZ 886LjblSvC6LW5U5/bDCBUPBBnfBmLH6dPRmT9zxrH42MD2Jsily4BjLu7bqT6MRFBX/z+uPo1FWuL3DQVO/A7e8w Nw3vqeN3OJhg8HjRgO+dEW4NQps8sznm8JXe4aQ20TP45m66XIVbmeD16oBLV47y3BgAj3C2G0yK8R+uq52HYB6aw QXNSWL04iRFr5X+NL0Y13EFe254pTIjLhCrU+Xzhgr2bB4IlFsPqhpEdtqgQGDK1I7PcqeR7ECYd1GpYKpk6LyeUx FG3bTwampIOoM4KS1wMcbeaGGTxtjspeT5B0ezcsQNOmBhgx/9ewdMzU6wuaNoek46/ZZnuo7fnrBJ7OCEdbegxmM qUVol6djxxxJig6nSZL94D2gw2Y2q9gab7wxAYHLAkzU8HQZivckQHx+0KEKxavXUO01oAdF7Tnf81Etz3vygAjUJ QvjhAmuUVsiRZfZH1JW+7XjnBHN8FMCSKora9DTv51VoQ7r46hrk5Ee7oCUhXQCl4aX5sMvtUtfmcgfNulRJ0BNro V7PopYLcAA8PzkW84EUoNFFcA/dIhOQayIiV+I0FNzHqj4vfvpuXLs4qK/AeKSvykB5xOVgAAAABJRU5ErkJggg== ) Base64:=Mode=3?base64_3:Mode=2?base64_2:base64_1 DllCall("crypt32\CryptStringToBinary", "UPtr", &Base64, "UInt", 0, "UInt", 0x01, "UPtr", 0, "UIntP", DecLen, "UPtr", 0, "UPtr", 0) VarSetCapacity(Dec, DecLen, 0) DllCall("crypt32\CryptStringToBinary", "UPtr", &Base64, "UInt", 0, "UInt", 0x01, "UPtr", &Dec, "UIntP", DecLen, "UPtr", 0, "UPtr", 0) DllCall("gdiplus\GdipCreateBitmapFromStreamICM", "UPtr", DllCall("shlwapi\SHCreateMemStream", "UPtr", &Dec, "UInt", DecLen, "UPtr"), "PtrP", pBitmap) ;;78感叹号,155问号,110 ;;pBitmap := Gdip_CreateBitmapFromFile("shell32.dll" ,Mode=3?110:Mode=2?78:278,40) DllCall("gdiplus\GdipGetImageWidth", "UPtr", pBitmap, "uint*", ImageWidth) DllCall("gdiplus\GdipGetImageHeight", "UPtr", pBitmap, "uint*", ImageHeight) Width := Max(Width:=320,ImageWidth+Max(TitleRC[3]+15,TextRC[3]+15)+40), Height := Max(Height:=120,Max(ImageHeight+50,TitleRC[4]+TextRC[4]+50)) VarSetCapacity(bi, 40, 0),NumPut(40, bi, 0, "uint"),NumPut(Width, bi, 4, "uint") NumPut(Height, bi, 8, "uint"),NumPut(1, bi, 12, "ushort"),NumPut(32, bi, 14, "ushort"),NumPut(0, bi, 16, "uInt") hbm := DllCall("CreateDIBSection", "UPtr", DllCall("GetDC", "UPtr", 0), "UPtr", &bi, "uint", 0, "UPtr*", 0, "UPtr", 0, "uint", 0, "UPtr") hdc := DllCall("CreateCompatibleDC", "UPtr", 0) obm := DllCall("SelectObject", "UPtr", hdc, "UPtr", hbm) DllCall("Gdiplus\GdipCreateFromHDC2", "UPtr", hDC, "UPtr", "", "UPtr*", G) DllCall("gdiplus\GdipSetSmoothingMode", "UPtr", G, "int", 2) ;绘背景色 DllCall("gdiplus\GdipCreateSolidFill", "UInt", "0x" Format("{:02x}",Transparent) (Dark?"000000":"f0f0f0"), "UPtr*", pBrush) DllCall("gdiplus\GdipCreateRegion", "UInt*", Region) DllCall("gdiplus\GdipGetClip", "UPtr", G, "UInt", Region) DllCall("gdiplus\GdipSetClipRect", "UPtr", G, "float", 0, "float", 0, "float", 0, "float", 0, "int", 4) DllCall("gdiplus\GdipSetClipRect", "UPtr", G, "float", Width, "float", 0, "float", 0, "float", 0, "int", 4) DllCall("gdiplus\GdipSetClipRect", "UPtr", G, "float", 0, "float", Height, "float", 0, "float", 0, "int", 4) DllCall("gdiplus\GdipSetClipRect", "UPtr", G, "float", Width, "float", Height, "float", 0, "float", 0, "int", 4) DllCall("gdiplus\GdipFillRectangle", "UPtr", G, "UPtr", pBrush, "float", 0, "float", 0, "float", Width, "float", Height) DllCall("gdiplus\GdipSetClipRegion", "UPtr", G, "UPtr", Region, "int", 0) DllCall("gdiplus\GdipSetClipRect", "UPtr", G, "float", 0, "float", 0, "float", Width, "float", Height, "int", 4) DllCall("gdiplus\GdipSetClipRect", "UPtr", G, "float", 0, "float", 0, "float", Width, "float", Height, "int", 4) DllCall("gdiplus\GdipFillEllipse", "UPtr", G, "UPtr", pBrush, "float", 0, "float", 0, "float", 0, "float", 0) DllCall("gdiplus\GdipFillEllipse", "UPtr", G, "UPtr", pBrush, "float", Width, "float", 0, "float", 0, "float", 0) DllCall("gdiplus\GdipFillEllipse", "UPtr", G, "UPtr", pBrush, "float", 0, "float", Height, "float", 0, "float", 0) DllCall("gdiplus\GdipFillEllipse", "UPtr", G, "UPtr", pBrush, "float", Width, "float", Height, "float", 0, "float", 0) DllCall("gdiplus\GdipSetClipRegion", "UPtr", G, "UPtr", Region, "int", 0) DllCall("gdiplus\GdipDeleteRegion", "UPtr", Region) DllCall("gdiplus\GdipGetImageDimension", "UPtr", pBitmap, "float*", ImageWidth:=Width, "float*", ImageHeight:=Height) ImageWidth := Round(ImageWidth),ImageHeight := Round(ImageHeight) DllCall("gdiplus\GdipDrawImageRectRect", "UPtr", G, "UPtr", pBitmap, "float", 15, "float", Abs(Height-ImageHeight)/2 , "float", Width, "float", Height, "float", 0, "float", 0, "float", Width, "float", Height, "int", 2 , "UPtr", 0, "UPtr", 0, "UPtr", 0) ;;绘文字 TitleRC:=StrSplit(TextToGraphics_Gdip(G,title, "x" ImageWidth+30 " y" Abs(Height-TitleRC[4]-TextRC[4]-10)/2 " cff" (Dark?"f0f0f0":"333333") " s" TitleFntSize (text=""&&title<>""?"":" Bold "), SystemFontName, TitleRC[3]+30, TitleRC[4]),"|") TextRC:=StrSplit(TextToGraphics_Gdip(G,Text, "x" TitleRC[1] " y" TitleRC[2]+TitleRC[4]+5 " cff" (Dark?"e3e3e3":"454545") " s" TextFntSize " ", SystemFontName, TextRC[3]+15, TextRC[4]),"|") DllCall("gdiplus\GdipDeleteBrush", "UPtr", pBrush) WinGetPos,TrayWndX,TrayWndY,TrayWndW,TrayWndH,ahk_class Shell_TrayWnd Loop,% Width { xpos:=TrayWndW>TrayWndH?A_ScreenWidth-A_Index-15:TrayWndX>0?A_Index+30-Width:A_ScreenWidth-A_Index-30 ypos:=TrayWndW>TrayWndH?TrayWndY>0?A_ScreenHeight-TrayWndH-Height-15:TrayWndH+15:A_ScreenHeight-TrayWndW-Height-15 if ((xpos != "") && (ypos != "")) VarSetCapacity(pt, 8), NumPut(xpos, pt, 0, "UInt"), NumPut(ypos, pt, 4, "UInt") if (Width = "") || (Height = ""){ size := VarSetCapacity(rect, 16, 0) er := DllCall("dwmapi\DwmGetWindowAttribute" , "UPtr", hCTT, "UInt", 9, "UPtr", &rect, "UInt", size, "UInt") If er DllCall("GetWindowRect", "UPtr", hCTT, "UPtr", &rect, "UInt") r := [] r.x1 := NumGet(rect, 0, "Int"), r.y1 := NumGet(rect, 4, "Int") r.x2 := NumGet(rect, 8, "Int"), r.y2 := NumGet(rect, 12, "Int") r.w := Abs(max(r.x1, r.x2) - min(r.x1, r.x2)) r.h := Abs(max(r.y1, r.y2) - min(r.y1, r.y2)) Width := r.w Height := r.h } DllCall("UpdateLayeredWindow", "UPtr", hCTT, "UPtr", 0, "UPtr", ((xpos = "") && (ypos = "")) ? 0 : &pt , "int64*", Width|Height<<32, "UPtr", hdc, "int64*", 0, "uint", 0, "UInt*", 255<<16|1<<24, "uint", 2) } DllCall("SelectObject", "UPtr", hdc, "UPtr", obm),DllCall("DeleteObject", "UPtr", hbm) DllCall("DeleteDC", "UPtr", hdc),DllCall("gdiplus\GdipDeleteGraphics", "UPtr", G) OnMessage(0x201, "CloseCustomTrayTip") if timeout { CTTimer := Func("DllCall").Bind("DestroyWindow", "Ptr", hCTT) SetTimer, % CTTimer, % "-" . timeout } Return WinExist("ahk_id " hCTT)?{HWND:hCTT,x:xpos,y:ypos,w:Width,h:Height}:False ;;格式化字符串自动换行,以免过长 FormatString: loopString:=text=""&&title<>""?title:text if !InStr(loopString,"`n"){ Index:=0,String:="" Loop,Parse,loopString { Index:=A_LoopField~="[\x00-\xff]"?Index+1:Index+2 String:=Mod(Index,44)=0||Mod(Index,44)=1?String "`n" A_LoopField:String A_LoopField String:=RegExReplace(String,"(\n.)[\r\n]","$1") } if (text=""&&title<>"") title:= String<>""?String:title Else{ Text:= String<>""?String:Text } } Return } CloseCustomTrayTip(wParam, lParam, uMsg, hWnd){ Global hCTT,CTTimer DetectHiddenWindows,Off if (A_Gui="TT"&&wParam){ Try { SetTimer, % CTTimer,Off DllCall("DestroyWindow","ptr",hWnd) ;;DllCall("user32.dll\PostMessage", "ptr", hWnd, "uint", 0x00A1, "ptr", 2, "ptr", 0) } } DetectHiddenWindows,On } TextToGraphics_Gdip(pGraphics, Text, Options, Font:="Arial", Width:="", Height:="", Measure:=0, userBrush:=0, Unit:=0) { Static Styles := "Regular|Bold|Italic|BoldItalic|Underline|Strikeout" , Alignments := "Near|Left|Centre|Center|Far|Right" OWidth := Width,IWidth := Width, IHeight:= Height pattern_opts := (A_AhkVersion < "2") ? "iO)" : "i)" RegExMatch(Options, pattern_opts "X([\-\d\.]+)(p*)", xpos) RegExMatch(Options, pattern_opts "Y([\-\d\.]+)(p*)", ypos) RegExMatch(Options, pattern_opts "W([\-\d\.]+)(p*)", PWidth) RegExMatch(Options, pattern_opts "H([\-\d\.]+)(p*)", Height) RegExMatch(Options, pattern_opts "C(?!(entre|enter))([a-f\d]+)", Colour) RegExMatch(Options, pattern_opts "Top|Up|Bottom|Down|vCentre|vCenter", vPos) RegExMatch(Options, pattern_opts "NoWrap", NoWrap) RegExMatch(Options, pattern_opts "R(\d)", Rendering) RegExMatch(Options, pattern_opts "S(\d+)(p*)", Size) Width := PWidth DllCall("gdiplus\GdipCloneBrush", "UPtr", Colour[2], "UPtr*", pBrushClone) if Colour && !DllCall("gdiplus\GdipDeleteBrush", "UPtr", pBrushClone){ Static Integer := "Integer" if Colour[2] is Integer PassBrush := 1,pBrush := Colour[2] } if !(IWidth && IHeight) && ((xpos && xpos[2]) || (ypos && ypos[2]) || (Width && Width[2]) || (Height && Height[2]) || (Size && Size[2])) return -1 Style := 0 For eachStyle, valStyle in StrSplit(Styles, "|") { if RegExMatch(Options, "\b" valStyle) Style |= (valStyle != "StrikeOut") ? (A_Index-1) : 8 } Align := 0 For eachAlignment, valAlignment in StrSplit(Alignments, "|") { if RegExMatch(Options, "\b" valAlignment) Align |= A_Index//2.1 ; 0|0|1|1|2|2 } xpos := (xpos && (xpos[1] != "")) ? xpos[2] ? IWidth*(xpos[1]/100) : xpos[1] : 0 ypos := (ypos && (ypos[1] != "")) ? ypos[2] ? IHeight*(ypos[1]/100) : ypos[1] : 0 Width := (Width && Width[1]) ? Width[2] ? IWidth*(Width[1]/100) : Width[1] : IWidth Height := (Height && Height[1]) ? Height[2] ? IHeight*(Height[1]/100) : Height[1] : IHeight If !PassBrush Colour := "0x" (Colour && Colour[2] ? Colour[2] : "ff000000") Rendering := (Rendering && (Rendering[1] >= 0) && (Rendering[1] <= 5)) ? Rendering[1] : 4 Size := (Size && (Size[1] > 0)) ? Size[2] ? IHeight*(Size[1]/100) : Size[1] : 12 If RegExMatch(Font, "^(.\:\\.)") { DllCall("gdiplus\GdipNewPrivateFontCollection", "ptr*", hFontCollection) hFontFamily := 0 E := DllCall("gdiplus\GdipPrivateAddFontFile", "ptr", hFontCollection, "str", Font) if !E { VarSetCapacity(pFontFamily, 10, 0) DllCall("gdiplus\GdipGetFontCollectionFamilyList", "ptr", hFontCollection, "int", 1, "ptr", &pFontFamily, "int*", found) VarSetCapacity(FontName, 100) DllCall("gdiplus\GdipGetFamilyName", "ptr", NumGet(pFontFamily, 0, "ptr"), "str", FontName, "ushort", 1033) } } Else DllCall("gdiplus\GdipCreateFontFamilyFromName", "WStr", Font, "uint", 0, "UPtr*", hFontFamily) If !hFontFamily DllCall("gdiplus\GdipGetGenericFontFamilySansSerif", "UPtr*", hFontFamily) DllCall("gdiplus\GdipCreateFont", "UPtr", hFontFamily, "float", Size, "int", Style, "int", Unit, "UPtr*", hFont) DllCall("gdiplus\GdipCreateStringFormat", "int", NoWrap ? 0x4000 | 0x1000 : 0x4000, "int", 0, "UPtr*", hStringFormat) If !hStringFormat DllCall("gdiplus\GdipStringFormatGetGenericTypographic", "UPtr*", hStringFormat) if !PassBrush DllCall("gdiplus\GdipCreateSolidFill", "UInt", Colour, "UPtr*", pBrush) if !(hFontFamily && hFont && hStringFormat && pBrush && pGraphics) { E := !pGraphics ? -2 : !hFontFamily ? -3 : !hFont ? -4 : !hStringFormat ? -5 : !pBrush ? -6 : 0 If pBrush DllCall("gdiplus\GdipDeleteBrush", "UPtr", pBrush) If hStringFormat DllCall("gdiplus\GdipDeleteStringFormat", "UPtr", hStringFormat) If hFont DllCall("gdiplus\GdipDeleteFont", "UPtr", hFont) If hFontFamily DllCall("gdiplus\GdipDeleteFontFamily", "UPtr", hFontFamily) If hFontCollection DllCall("gdiplus\GdipDeletePrivateFontCollection", "ptr*", hFontCollection) return E } VarSetCapacity(RC, 16) NumPut(xpos, RC, 0, "float"), NumPut(ypos, RC, 4, "float") NumPut(Width, RC, 8, "float"), NumPut(Height, RC, 12, "float") DllCall("gdiplus\GdipSetStringFormatAlign", "UPtr", hStringFormat, "int", Align) If InStr(Options, "autotrim") DllCall("gdiplus\GdipSetStringFormatTrimming", "UPtr", hStringFormat, "int", 3) DllCall("gdiplus\GdipSetTextRenderingHint", "UPtr", pGraphics, "int", Rendering) VarSetCapacity(TempRC, 16) DllCall("gdiplus\GdipMeasureString", "UPtr", pGraphics, "WStr", Text, "int", -1 , "UPtr", hFont, "UPtr", &RC, "UPtr", hStringFormat, "UPtr", &TempRC, "uint*", 0, "uint*", 0) ReturnRC := &TempRC ? NumGet(TempRC, 0, "float") "|" NumGet(TempRC, 4, "float") "|" NumGet(TempRC, 8, "float") "|" NumGet(TempRC, 12, "float") "|" 0 "|" 0 : 0 ReturnRCtest := StrSplit(ReturnRC, "|") testX := Floor(ReturnRCtest[1]) - 2 If (testX>xpos && NoWrap && (PWidth>2 || OWidth>2)) { nxpos := Floor(xpos - (testX - xpos)) VarSetCapacity(RC, 16) NumPut(xpos, RC, 0, "float"), NumPut(ypos, RC, 4, "float") NumPut(Width, RC, 8, "float"), NumPut(Height, RC, 12, "float") VarSetCapacity(TempRC, 16) DllCall("gdiplus\GdipMeasureString", "UPtr", pGraphics, "WStr", Text, "int", -1 , "UPtr", hFont, "UPtr", &RC, "UPtr", hStringFormat, "UPtr", &TempRC, "uint*", 0, "uint*", 0) ReturnRC := &TempRC ? NumGet(TempRC, 0, "float") "|" NumGet(TempRC, 4, "float") "|" NumGet(TempRC, 8, "float") "|" NumGet(TempRC, 12, "float") "|" 0 "|" 0 : 0 } If vPos { ReturnRC := StrSplit(ReturnRC, "|") if (vPos[0] = "vCentre") || (vPos[0] = "vCenter") ypos += (Height-ReturnRC[4])//2 else if (vPos[0] = "Top") || (vPos[0] = "Up") ypos += 0 else if (vPos[0] = "Bottom") || (vPos[0] = "Down") ypos += Height-ReturnRC[4] VarSetCapacity(RC, 16) NumPut(xpos, RC, 0, "float"), NumPut(ypos, RC, 4, "float") NumPut(Width, RC, 8, "float"), NumPut(ReturnRC[4], RC, 12, "float") VarSetCapacity(TempRC, 16) DllCall("gdiplus\GdipMeasureString", "UPtr", pGraphics, "WStr", Text, "int", -1 , "UPtr", hFont, "UPtr", &RC, "UPtr", hStringFormat, "UPtr", &TempRC, "uint*", 0, "uint*", 0) ReturnRC := &TempRC ? NumGet(TempRC, 0, "float") "|" NumGet(TempRC, 4, "float") "|" NumGet(TempRC, 8, "float") "|" NumGet(TempRC, 12, "float") "|" 0 "|" 0 : 0 } thisBrush := userBrush ? userBrush : pBrush if !Measure _E := DllCall("gdiplus\GdipDrawString", "UPtr", pGraphics, "WStr", Text, "int", -1 , "UPtr", hFont, "UPtr", &RC, "UPtr", hStringFormat, "UPtr", thisBrush) if !PassBrush DllCall("gdiplus\GdipDeleteBrush", "UPtr", pBrush) DllCall("gdiplus\GdipDeleteStringFormat", "UPtr", hStringFormat) DllCall("gdiplus\GdipDeleteFont", "UPtr", hFont) DllCall("gdiplus\GdipDeleteFontFamily", "UPtr", hFontFamily) If hFontCollection DllCall("gdiplus\GdipDeletePrivateFontCollection", "ptr*", hFontCollection) return _E ? _E : ReturnRC } Exit: DllCall("gdiplus\GdiplusShutdown", "UPtr", CTToken) if hModule := DllCall("GetModuleHandle", "str", "gdiplus", "UPtr") DllCall("FreeLibrary", "UPtr", hModule) ExitApp Return
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)