TextBox Styles (numeric, uppercase and lowercase): Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Corrected link to System plug-in.)
 
Line 2: Line 2:


== Description ==
== Description ==
'''Requires:''' [[System plug-in]].  
'''Requires:''' [[InstallOptions plug-in|InstallOptions]] or [[InstallOptionsEx]] and [[System plug-in|System]] plug-ins.


Change how your textbox behaves by applying different styles. This works with standard and IO dialogs.
Change how your textbox behaves by applying different styles. This works with standard and IO dialogs.

Latest revision as of 06:11, 3 December 2005

Author: dselkirk (talk, contrib)


Description

Requires: InstallOptions or InstallOptionsEx and System plug-ins.

Change how your textbox behaves by applying different styles. This works with standard and IO dialogs.

The Script

name "TextBox Styles"
outfile "test.exe"
 
Page custom test
 
!define NUMERIC 0x2000
!define LOWERCASE 0x10
!define UPPERCASE 0x8
 
!macro STYLE HWND STYLE
  ;retrieve current style
  System::Call 'user32::GetWindowLongA(i ${HWND},i -16) i .r1'
  ;append provided style
  IntOp $1 $1 | ${STYLE}
  ;apply new style
  System::Call 'user32::SetWindowLongA(i ${HWND},i -16,i r1) n'
!macroend
 
;EXAMPLE
 
!macro ADDFIELD TYPE LEFT RIGHT TOP BOTTOM TEXT
  Push $R0
  ReadINIStr $R0 "$PLUGINSDIR\test.ini" "Settings" "NumFields"
  IntOp $R0 $R0 + 1
  WriteINIStr "$PLUGINSDIR\test.ini" "Settings" "NumFields" $R0
  WriteINIStr "$PLUGINSDIR\test.ini" "Field $R0" "Type" "${TYPE}"
  WriteINIStr "$PLUGINSDIR\test.ini" "Field $R0" "Left" ${LEFT}
  WriteINIStr "$PLUGINSDIR\test.ini" "Field $R0" "Right" ${RIGHT}
  WriteINIStr "$PLUGINSDIR\test.ini" "Field $R0" "Top" ${TOP}
  WriteINIStr "$PLUGINSDIR\test.ini" "Field $R0" "Bottom" ${BOTTOM}
  WriteINIStr "$PLUGINSDIR\test.ini" "Field $R0" "Text" "${TEXT}"
  Pop $R0
!macroend
 
Function test
  InitPluginsDir
  !insertmacro ADDFIELD "Label" 0 35 0 12 "Numeric"
  !insertmacro ADDFIELD "Text" 40 100 0 12 ""
  !insertmacro ADDFIELD "Label" 0 35 20 32 "Lowercase"
  !insertmacro ADDFIELD "Text" 40 100 20 32 ""
  !insertmacro ADDFIELD "Label" 0 35 40 52 "Uppercase"
  !insertmacro ADDFIELD "Text" 40 100 40 52 ""
  InstallOptions::initDialog /NOUNLOAD "$PLUGINSDIR\test.ini"
  Pop $R0
  GetDlgItem $R1 $R0 1201 ;1200 + Field number - 1
  !insertmacro STYLE $R1 ${NUMERIC}
  GetDlgItem $R1 $R0 1203 ;1200 + Field number - 1
  !insertmacro STYLE $R1 ${LOWERCASE}
  GetDlgItem $R1 $R0 1205 ;1200 + Field number - 1
  !insertmacro STYLE $R1 ${UPPERCASE}
  InstallOptions::show
  Pop $R0
FunctionEnd
 
Section ""
SectionEnd