自定义定制一个确认框

MsgBox % ColorMsgBox("展示一下自定义确认框,是否关闭窗口?")
ExitApp



/*
	Text:显示提示字段
	splitLine:是否显示分割线
	BackColor:背景色
	TextColor:提示字段字体颜色
	ButtonBGColor:按钮背景色
	ButtonTextColor:按钮字体色
	MaxWidth:窗口宽度
*/
ColorMsgBox(Text,splitLine=0,BackColor:=0x333333,TextColor:=0xf0f0f0,ButtonBGColor:=0xf0f0f0,ButtonTextColor:=0xe81010,MaxWidth=300){
	Static picbc,pic1,pic2,pic3,tip,GuiControl_yes,GuiControl_no
	if (Text="")
		Return
	HWND:= WinActive("A")
	NumPut(VarSetCapacity(info, A_IsUnicode ? 504 : 344, 0), info, 0, "UInt")
	DllCall("SystemParametersInfo", "UInt", 0x29, "UInt", 0, "Ptr", &info, "UInt", 0)
	FontName:= StrGet(&info + 52)?StrGet(&info + 52):"宋体"
	Gui,MSG:Destroy
	MaxWidth:=MaxWidth>250?MaxWidth:300,PicHeight:=100
	Owner:=A_Gui<>""?" Owner" A_Gui:" AlwaysOnTop "
	Gui,MSG:-Caption %Owner% +HWNDMsgBOX -DPIScale
	Gui,MSG:Add,Pic,x0 y0 w%MaxWidth% h%PicHeight% vpicbc AltSubmit,% "HBITMAP:" . CreateColoredBitmap(MaxWidth, PicHeight,BackColor)
	Gui,MSG:Font,% "c" RegExReplace(Format("0x{:x}",TextColor),"i)0x") " s10",% FontName
	Gui,MSG:Add,Text,% "x20 y20 w" MaxWidth-40 " BackgroundTrans vtip",%Text%
	if splitLine
		Gui,MSG:Add,Text,% "xm-2 y+10 w" MaxWidth-20 " 0x10"
	GuiControlGet,tippos,MSG:Pos,tip
	GuiControl,MSG:Move, picbc,% "h" (PicHeight:=splitLine?tipposH+130:tipposH+110)
	GuiControl,MSG:, picbc,% "HBITMAP:" CreateColoredBitmap(MaxWidth, PicHeight, BackColor)
	Gui,MSG:Add,Pic,% "x" (MaxWidth-230-5)/2 " y" PicHeight-65 " w100 h40 Border AltSubmit vpic2",% "HBITMAP:" . CreateColoredBitmap(100, 50,ButtonBGColor)
	GuiControlGet,pic2pos,MSG:Pos,pic2
	Gui,MSG:Add,Pic,% "x+30 yp w100 h40 Border AltSubmit vpic3",% "HBITMAP:" . CreateColoredBitmap(100, 50,ButtonBGColor)
	GuiControlGet,pic3pos,MSG:Pos,pic3
	Gui,MSG:Font,% "c" RegExReplace(Format("0x{:x}",ButtonTextColor),"i)0x") " s11 bold",% FontName
	Gui,MSG:Add,Text,% "x" pic2posX+1 " y" pic2posY-1 " w100 Center gGuiControl_yes vGuiControl_yes",是(Yes)
	Gui,MSG:Add,Text,% "x" pic3posX+1 " yp w100 Center gGuiControl_no vGuiControl_no",否(No)
	GuiControlGet,yespos,MSG:Pos,GuiControl_yes
	GuiControl,MSG:Move, GuiControl_yes,% "y" yesposY+(40-yesposH)/2
	GuiControl,MSG:Move, GuiControl_no,% "y" yesposY+(40-yesposH)/2
	if splitLine
		Gui,MSG:Add,GroupBox,% "x10 y0 w" MaxWidth-20 " h" PicHeight-10
	Gui,MSG:Show,% "NA w" MaxWidth " h" PicHeight,
	OnMessage(0x201, "WM_LBUTTONDOWN")
	while !(ButtonCancel||ButtonOK){
		if (!WinExist("ahk_id " HWND)&&HWND){
			Gui, MSG:Destroy
			return False
		}Else{
			continue
		}
	}
	if (ButtonCancel) {
		return False
	}
	Gui, MSG: Submit, NoHide
	Gui, MSG:Destroy
	return ButtonOK

	pic2:
	GuiControl_yes:
		ButtonOK:= true
	Return

	pic3:
	GuiControl_no:
		ButtonCancel:= true
		Gui, MSG:Destroy
	Return

}

WM_LBUTTONDOWN(wParam, lParam, uMsg, hWnd){
	PostMessage, 0xA1, 2
}

CreateColoredBitmap(width, height, color) {
	hBitmap := CreateDIBSections(width, -height,, pBits)
	Loop % height {
		i := A_Index - 1
		Loop % width
			NumPut(color, pBits + width*4*i + (A_Index - 1)*4, "UInt")
	}
	Return hBitmap
}

CreateDIBSections(w, h, bpp := 32, ByRef ppvBits := 0)
{
	hdc := DllCall("GetDC", "Ptr", 0, "Ptr")
	VarSetCapacity(bi, 40, 0)
	NumPut( 40, bi,  0, "UInt")
	NumPut(  w, bi,  4, "UInt")
	NumPut(  h, bi,  8, "UInt")
	NumPut(  1, bi, 12, "UShort")
	NumPut(  0, bi, 16, "UInt")
	NumPut(bpp, bi, 14, "UShort")
	hbm := DllCall("CreateDIBSection", "Ptr", hdc, "Ptr", &bi, "UInt", 0, "PtrP", ppvBits, "Ptr", 0, "UInt", 0, "Ptr")
	DllCall("ReleaseDC", "Ptr", 0, "Ptr", hdc)
	return hbm
}

给TA捐赠
共{{data.count}}人
人已捐赠
其他应用

【库 IMGUI】imgui界面库AutoHotKey语言绑定

2021-12-5 21:59:21

其他

【基础】单击双击三击,三套方案

2021-12-7 15:00:48

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
有新私信 私信列表
搜索