最新消息:

实现输入框文字居中

nsis 永恒心锁 2716浏览 0评论

实现输入框文字居中

!include nsDialogs.nsh

################################################################################
 ################################################################################
 ################################################################################
 !macro _MISCFUNC_DEFINE_IFNDEF _m _v
 !ifndef ${_m}
 !define ${_m} `${_v}`
 !endif
 !macroend

!macro _MISCFUNC_DEFINE_IFNDEF_EX _m _a _o _b
 !ifndef ${_m}
 !define /math ${_m} ${_a} ${_o} ${_b}
 !endif
 !macroend

!macro _MISCFUNC_DEFINE_IFNDEF_AW _m
 !ifndef ${_m}
 !ifndef NSIS_UNICODE
 !ifndef ${_m}A
 !error "${_m}A not defined!"
 !else
 !define ${_m} "${${_m}A}"
 !endif
 !else
 !ifndef ${_m}W
 !error "${_m}W not defined!"
 !else
 !define ${_m} "${${_m}W}"
 !endif
 !endif
 !endif
 !macroend

!ifndef _MISCFUNC_DEFINE
 !define _MISCFUNC_DEFINE "!insertmacro _MISCFUNC_DEFINE_IFNDEF"
 !endif

!ifndef _MISCFUNC_DEFINE_EX
 !define _MISCFUNC_DEFINE_EX "!insertmacro _MISCFUNC_DEFINE_IFNDEF_EX"
 !endif

!ifndef _MISCFUNC_DEFINE_AW
 !define _MISCFUNC_DEFINE_AW "!insertmacro _MISCFUNC_DEFINE_IFNDEF_AW"
 !endif

/* Common window Styles */
 ${_MISCFUNC_DEFINE} WS_TABSTOP 0x00010000
 ${_MISCFUNC_DEFINE} WS_GROUP 0x00020000
 ${_MISCFUNC_DEFINE} WS_SIZEBOX 0x00040000
 ${_MISCFUNC_DEFINE} WS_SYSMENU 0x00080000
 ${_MISCFUNC_DEFINE} WS_HSCROLL 0x00100000
 ${_MISCFUNC_DEFINE} WS_VSCROLL 0x00200000
 ${_MISCFUNC_DEFINE} WS_DLGFRAME 0x00400000
 ${_MISCFUNC_DEFINE} WS_BORDER 0x00800000
 ${_MISCFUNC_DEFINE} WS_CAPTION 0x00C00000
 ${_MISCFUNC_DEFINE} WS_MAXIMIZE 0x01000000
 ${_MISCFUNC_DEFINE} WS_CLIPCHILDREN 0x02000000
 ${_MISCFUNC_DEFINE} WS_CLIPSIBLINGS 0x04000000
 ${_MISCFUNC_DEFINE} WS_DISABLED 0x08000000
 ${_MISCFUNC_DEFINE} WS_VISIBLE 0x10000000
 ${_MISCFUNC_DEFINE} WS_ICONIC 0x20000000
 ${_MISCFUNC_DEFINE} WS_CHILD 0x40000000
 ${_MISCFUNC_DEFINE} WS_POPUP 0x80000000

/* Common window extended styles */
 ${_MISCFUNC_DEFINE} WS_EX_DLGMODALFRAME 0x00000001
 ${_MISCFUNC_DEFINE} WS_EX_NOPARENTNOTIFY 0x00000004
 ${_MISCFUNC_DEFINE} WS_EX_TOPMOST 0x00000008
 ${_MISCFUNC_DEFINE} WS_EX_ACCEPTFILES 0x00000010
 ${_MISCFUNC_DEFINE} WS_EX_TRANSPARENT 0x00000020
 ${_MISCFUNC_DEFINE} WS_EX_MDICHILD 0x00000040
 ${_MISCFUNC_DEFINE} WS_EX_TOOLWINDOW 0x00000080
 ${_MISCFUNC_DEFINE} WS_EX_WINDOWEDGE 0x00000100
 ${_MISCFUNC_DEFINE} WS_EX_CLIENTEDGE 0x00000200
 ${_MISCFUNC_DEFINE} WS_EX_CONTEXTHELP 0x00000400
 ${_MISCFUNC_DEFINE} WS_EX_RIGHT 0x00001000
 ${_MISCFUNC_DEFINE} WS_EX_RTLREADING 0x00002000
 ${_MISCFUNC_DEFINE} WS_EX_LEFTSCROLLBAR 0x00004000
 ${_MISCFUNC_DEFINE} WS_EX_CONTROLPARENT 0x00010000
 ${_MISCFUNC_DEFINE} WS_EX_STATICEDGE 0x00020000
 ${_MISCFUNC_DEFINE} WS_EX_APPWINDOW 0x00040000
 ${_MISCFUNC_DEFINE} WS_EX_LAYERED 0x00080000

!define __NSD_ReadText_CLASS Edit
 !define __NSD_ReadText_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}|${ES_READONLY}
 !define __NSD_ReadText_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
 !insertmacro __NSD_DefineControl ReadText

!define __NSD_NoBorderEdit_CLASS Edit
 !define __NSD_NoBorderEdit_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}
 !define __NSD_NoBorderEdit_EXSTYLE 0
 !insertmacro __NSD_DefineControl NoBorderEdit

!define __NSD_WhiteFrame_CLASS Static
 !define __NSD_WhiteFrame_STYLE ${DEFAULT_STYLES}|${SS_WHITEFRAME}
 !define __NSD_WhiteFrame_EXSTYLE ${WS_EX_TRANSPARENT}
 !insertmacro __NSD_DefineControl WhiteFrame

!define __NSD_WhiteRect_CLASS Static
 !define __NSD_WhiteRect_STYLE ${DEFAULT_STYLES}|${WS_BORDER}|${SS_WHITERECT}
 !define __NSD_WhiteRect_EXSTYLE ${WS_EX_TRANSPARENT}
 !insertmacro __NSD_DefineControl WhiteRect

!define __NSD_GrayFrame_CLASS Static
 !define __NSD_GrayFrame_STYLE ${DEFAULT_STYLES}|${SS_GRAYFRAME}
 !define __NSD_GrayFrame_EXSTYLE ${WS_EX_TRANSPARENT}
 !insertmacro __NSD_DefineControl GrayFrame

!define __NSD_GrayRect_CLASS Static
 !define __NSD_GrayRect_STYLE ${DEFAULT_STYLES}|${WS_BORDER}|${SS_GRAYRECT}
 !define __NSD_GrayRect_EXSTYLE ${WS_EX_TRANSPARENT}
 !insertmacro __NSD_DefineControl GrayRect

!define __NSD_BlackFrame_CLASS Static
 !define __NSD_BlackFrame_STYLE ${DEFAULT_STYLES}|${SS_BLACKFRAME}
 !define __NSD_BlackFrame_EXSTYLE ${WS_EX_TRANSPARENT}
 !insertmacro __NSD_DefineControl BlackFrame

!define __NSD_BlackRect_CLASS Static
 !define __NSD_BlackRect_STYLE ${DEFAULT_STYLES}|${WS_BORDER}|${SS_BLACKRECT}
 !define __NSD_BlackRect_EXSTYLE ${WS_EX_TRANSPARENT}
 !insertmacro __NSD_DefineControl BlackRect
 ################################################################################
 ################################################################################
 ################################################################################

Name EditVC
 OutFile EditVC.exe
 InstallDir $TEMP

XPStyle on
 InstallColors /windows
 ShowInstDetails show
 RequestExecutionLevel admin
 ;SetFont /LANG=2052 SimSun 10

LoadLanguageFile "${NSISDIR}ContribLanguage filesSimpChinese.nlf"
 Page custom dirPage.Create
 Page instfiles

Section -Main
 DetailPrint "$$INSTDIR = $INSTDIR"
 SectionEnd

Function dirPage.Create
 nsDialogs::Create 1018
 Pop $0

############################################################################
 ${NSD_CreateNoBorderEdit} 4u 6u 212u 8u "Edit"
 Pop $1
 GetFunctionAddress $R0 onDirEditChange
 nsDialogs::OnChange $1 $R0

System::Call "shlwapi::SHAutoComplete(ir0,i0x20)"

SendMessage $1 ${WM_SETTEXT} 0 "STR:$INSTDIR"

${NSD_CreateButton} 226u 0u 40u 20u "$(^BrowseBtn)"
 Pop $2
 nsDialogs::SetUserData $2 $1

GetFunctionAddress $R0 onDirBrowseClick
 nsDialogs::OnClick $2 $R0

${NSD_CreateWhiteRect} 0u 0u 220u 20u "Frame"
 Pop $3

nsDialogs::Show
 FunctionEnd

Function onDirEditChange
 Exch $R0
 System::Call "user32::SendMessage(iR0,i${WM_GETTEXT},i${NSIS_MAX_STRLEN},t.d)"
 Pop $R0
 FunctionEnd

Function onDirBrowseClick
 Exch $R0
 Push $R1
 nsDialogs::GetUserData $R0
 Pop $R1
 nsDialogs::SelectFolderDialog "$(^DirBrowseText)" "$INSTDIR"
 Pop $R0
 StrCmp $R0 error +2
 SendMessage $R1 ${WM_SETTEXT} 0 "STR:$R0"
 Pop $R1
 Pop $R0
 FunctionEnd

 

永恒心锁,版权所有丨如未注明,均为转载丨本网站采用BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » 实现输入框文字居中

您必须 登录 才能发表评论!