字体选择的返回上,还有些问题
; By 蜜獾哥 CustomColors:=[0x1010E8,0xFFFF17,0x19BFFF,0xE2CC79,0xFF7A00,0xFF9700,0x549E54,0xF0F0F0 ,0xB1F7FF,0x6DD71D,0xC073D1,0xE8E8E8,0xe05855,0xB9D497,0x0078D7,0xF8B62D] Gui,Test:Destroy Gui,Test:+HWNDhTest Gui,Test:Add, Text,w60 Right section, % "BGR:" Gui,Test:Add, Edit,ys-4 Gui,Test:Add, Text,w60 Right section xs, % "RGB:" Gui,Test:Add, Edit,ys-4 Gui,Test:Add, Text,w60 Right section xs, RRGGBB: Gui,Test:Add, Edit,ys-4 Gui,Test:Add,Text,xm w250 0x10, Gui,Test:Add, Text,w60 Right section xs, 字体名称: Gui,Test:Add, Edit,ys-4 Gui,Test:Add, Text,w60 Right section xs, 字体大小: Gui,Test:Add, Edit,ys-4 Gui,Test:Add, Text,w60 Right section xs, 字体颜色: Gui,Test:Add, Edit,ys-4 Gui,Test:Add, Checkbox,xm y+10 vcboc1,粗体 Gui,Test:Add, Checkbox,x+0 vcboc2 yp,斜体 Gui,Test:Add, Checkbox,x+0 vcboc3 yp,细体 Gui,Test:Add, Checkbox, x+0 vcboc4 yp,下划线 Gui,Test:Add, Checkbox,x+0 vcboc5 yp,删除线 Gui,Test:Add,Text,xm y+10 w250 0x10, Gui,Test:Add,Button, gbtn1,取色 Gui,Test:Add,Button,x+10 yp gbtn2,字体 Gui,Test:Show Return btn1: Dlg_Color(SelectColor,"自定义取色窗口",hTest,CustomColors*) if objCount(SelectColor){ GuiControl,test:,Edit1,% SelectColor.BGR GuiControl,test:,Edit2,% SelectColor.RGB GuiControl,test:,Edit3,% SelectColor.RRGGBB Gui,+OwnDialogs MsgBox % "BGR:" SelectColor.BGR . "`nRGB:" SelectColor.RGB . "`nRRGGBB:" SelectColor.RRGGBB } Return btn2: Dlg_Font(FntObject,"字体选择器",hTest) GuiControl,test:,Edit4,% FntObject["名称"] GuiControl,test:,Edit5,% FntObject["字号"] GuiControl,test:,Edit6,% FntObject["颜色"] GuiControl,test:, cboc1,% FntObject["粗体"]?1:0 GuiControl,test:, cboc2,% FntObject["斜体"]?1:0 GuiControl,test:, cboc3,% FntObject["细体"]?1:0 GuiControl,test:, cboc4,% FntObject["下划线"]?1:0 GuiControl,test:, cboc5,% FntObject["删除线"]?1:0 Return TestGuiClose: ExitApp Return ;-----------------------------------------字体选择---------------------------------------------------------- /*! 函数: Dlg_Font(ByRef FntObject, WinTitle:="",hwnd="",effects=1)---->显示用于选择颜色的标准窗口对话框。 参数: FntObject - 存储fontObject的变量的名称,返回结果集{"名称":"","粗体":"","斜体":"","细体":"","字号":"","下划线":"","删除线":"","颜色":""} WinTitle - 自定义窗口标题,默认标题为「字体」 hwnd - 关联对话框对象的窗口ID effects -允许选择下划线/删除线/斜体 */ Dlg_Font(ByRef FntObject, WinTitle:="",hwnd=0,effects=1){ static logfont FntObject:=Object() Style := objCount(Style) ? Style: Object() VarSetCapacity(logfont,60),LogPixels:=DllCall("GetDeviceCaps","uint",DllCall("GetDC","uint",0),"uint",90),Effects:=0x041+(Effects?0x100:0) for a,b in fontval:={16:style.bold?700:400,20:style.italic,21:style.underline,22:style.strikeout,0:style.size?Floor(style.size*logpixels/72):16} NumPut(b,logfont,a) cap:=VarSetCapacity(choosefont,A_PtrSize=8?103:60,0) NumPut(hwnd,choosefont,A_PtrSize) for index,value in [[cap,0,"Uint"],[&logfont,A_PtrSize=8?24:12,"Uptr"],[effects,A_PtrSize=8?36:20,"Uint"],[style.color,A_PtrSize=4?6*A_PtrSize:5*A_PtrSize,"Uint"]] NumPut(value.1,choosefont,value.2,value.3) SetTimer, AsynchronousWinFntWait, -1 if (A_PtrSize=8) strput(name,&logfont+28),r:=DllCall("comdlg32\ChooseFont","uptr",&CHOOSEFONT,"cdecl"),name:=strget(&logfont+28) else strput(name,&logfont+28,32,"utf-8"),r:=DllCall("comdlg32\ChooseFontA","uptr",&CHOOSEFONT,"cdecl"),name:=strget(&logfont+28,32,"utf-8") if !r return False for a,b in {bold:16,italic:20,underline:21,strikeout:22} { style[a]:=NumGet(logfont,b,"UChar") } l_Color:=NumGet(choosefont,A_PtrSize=4?6*A_PtrSize:5*A_PtrSize),FntObject["名称"]:=name FntObject["粗体"]:=style.bold<188?0:1,FntObject["斜体"]:=style.italic?1:0,FntObject["细体"]:=InStr(FntInfo,"细")?1:0 FntObject["字号"]:=NumGet(CHOOSEFONT,A_PtrSize=8?32:16,"UChar")//10?NumGet(CHOOSEFONT,A_PtrSize=8?32:16,"UChar")//10:DefaultSize FntObject["下划线"]:=style.underline?1:0,FntObject["删除线"]:=style.strikeout?1:0 FntObject["颜色"]:=Format("0x{:06X}",((l_Color&0xFF)<<16)+(l_Color&0xFF00)+((l_Color>>16)&0xFF)) ;charset:=NumGet(logfont,23,"UChr") SetTimer, AsynchronousWinFntWait, Off return DllCall("CreateFontIndirect",uptr,&logfont,"cdecl") AsynchronousWinFntWait: if WinExist("ahk_class #32770", "字体") or (n=60) Goto FontWinWait n := n="" ? 1 : ++n SetTimer AsynchronousWinFntWait, -10 Return FontWinWait: if WinTitle&&!WinExist("ahk_class ahk_class #32770",WinTitle){ WinSetTitle, ahk_class #32770,, %WinTitle% ControlGetText, DefaultSize , Edit3, ahk_class #32770 Control, Disable ,, ComboBox5, ahk_class #32770 Control, Disable ,, SysLink1, ahk_class #32770 } Return } ;-----------------------------------------配色---------------------------------------------------------- /*! 函数: Dlg_Color(ByRef r_Color,WinTitle="", hOwner:=0, Palette*)---->显示用于选择颜色的标准窗口对话框。 参数: r_Color - 初始颜色-->默认设置为黑色.返回结果集{RGB:",BGR:"",RRGGBB:"} WinTitle - 自定义窗口标题,默认标题为「颜色」 hOwner - 对话框对象的窗口ID, 如果有的话默认为0, i.e. 没有对象. 如果指定的DlgX和DlgY被忽略. Palette -最多16个BGR颜色值的数组。这些将成为对话框中的初始自定义颜色。 Remarks: 对话框中的自定义颜色在调用时被标记。如果用户选择OK,则将加载调色板阵列(如果存在)使用对话框中的自定义颜色。 Returns: 如果用户选择“确定”,返回True。否则返回False */ Dlg_Color(ByRef r_Color, WinTitle:="",hOwner:=0, Palette*){ Static CHOOSECOLOR, A_CustomColors if !VarSetCapacity(A_CustomColors){ If !objLength(Palette){ Palette:=[0x1C7399,0xEEEEEC,0x014E8B,0x444444,0x009FE8,0xDEF9FA,0xF8B62D,0x90FC0F,0x0078D7,0x0D1B0A,0xB9D497,0x00ADEF,0x1778BF,0xFDF6E3,0x002B36,0xDEDEDE] } VarSetCapacity(A_CustomColors,64,0) for Index, Value in Palette NumPut(Value, A_CustomColors, 4*(Index - 1), "UInt") } l_Color:=r_Color, l_Color:=((l_Color&0xFF)<<16)+(l_Color&0xFF00)+((l_Color>>16)&0xFF) ;-- 创建并填充CHOOSECOLOR结构 lStructSize:=VarSetCapacity(CHOOSECOLOR,(A_PtrSize=8) ? 72:36,0) NumPut(lStructSize,CHOOSECOLOR,0,"UInt") ;-- lStructSize NumPut(hOwner,CHOOSECOLOR,(A_PtrSize=8) ? 8:4,"Ptr") ;-- hwndOwner NumPut(l_Color,CHOOSECOLOR,(A_PtrSize=8) ? 24:12,"UInt") ;-- RGB结果 NumPut(&A_CustomColors,CHOOSECOLOR,(A_PtrSize=8) ? 32:16,"Ptr") ;-- lpCustColors NumPut(0x00000103,CHOOSECOLOR,(A_PtrSize=8) ? 40:20,"UInt") ;-- Flags if (WinTitle!="") SetTimer, AsynchronousWinWait, -1 RC:=DllCall("comdlg32\ChooseColor" . (A_IsUnicode ? "W":"A"),"Ptr",&CHOOSECOLOR) ;-- 按下“取消”按钮或关闭对话框 if (RC=0) Return False ;-- 收集所选颜色 l_Color:=NumGet(CHOOSECOLOR,(A_PtrSize=8) ? 24:12,"UInt") ;-- 转换为RGB TempColor:=((l_Color&0xFF)<<16)+(l_Color&0xFF00)+((l_Color>>16)&0xFF) Red:=((TempColor & 0xff0000) >> 16),Green:=((TempColor & 0x00ff00) >> 8),Blue:=(TempColor & 0xff) ;-- 用选定的颜色更新 r_Color:={RGB:Format("0x{:06X}",TempColor) ;返回16进制RGB ,BGR:Format("0x{1:02X}{2:02X}{3:02X}",[Blue,Green,Red]*) ;返回16进制BGR ,RRGGBB:Red "," Green "," Blue} ;返回10进制RGB Return True AsynchronousWinWait: if WinActive("ahk_class #32770", "颜色") or (n=60) Goto ChangeTitle n := n="" ? 1 : ++n SetTimer AsynchronousWinWait, -10 Return ChangeTitle: WinSetTitle, ahk_class #32770, 颜色, %WinTitle% Return }
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)