Added more RichEdit NSD macros and a WM_NOTIFY example

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6912 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2017-09-29 18:56:30 +00:00
parent bd12125d7a
commit f34fd48105
4 changed files with 73 additions and 2 deletions

View file

@ -63,6 +63,11 @@ blockquote pre { background-color: #fcfcfc; font-family: monospace; }
<a href="#mref-edsetro">NSD_Edit_SetReadOnly</a>,
<a href="#mref-edsetcuebanner">NSD_Edit_SetCueBannerText</a>
</li>
<li>RichEdit:
<a href="#mref-richsettextlimit">NSD_RichEd_SetTextLimit</a>,
<a href="#mref-richseteventmask">NSD_RichEd_SetEventMask</a>,
<a href="#mref-richsetbkclr">NSD_RichEd_SetCustomBackgroundColor</a>
</li>
<li>CheckBox &amp; RadioButton:
<a href="#mref-getstate">NSD_GetState</a>,
<a href="#mref-setstate">NSD_SetState</a>,
@ -494,7 +499,7 @@ SectionEnd</pre></blockquote>
<h3><a name="ref-onnotify"></a>OnNotify</h3>
<p><code>nsDialogs::OnNotify <i>control_HWND</i> <i>function_address</i></code></p>
<p>Sets a notification callback function for the given control. Whenever the control receives the WM_NOTIFY message, the function will be called and the control's HWND, notification code and a pointer to the MNHDR structure will be waiting on its stack.</p>
<p>Sets a notification callback function for the given control. Whenever the control receives the WM_NOTIFY message, the function will be called and the control's HWND, notification code and a pointer to the NMHDR structure will be waiting on its stack.</p>
<p>Use GetFunctionAddress to get the address of the desired callback function.</p>
<p>Returns nothing.</p>
@ -611,6 +616,16 @@ SectionEnd</pre></blockquote>
<p><code>${NSD_Edit_SetCueBannerText} <i>control_HWND</i> <i>displaywhenfocused</i> <i>text</i></code></p>
<p>Set a text hint displayed when the control is empty. The text is only visible on WinXP and later. Requires <i>XPStyle on</i>.</p>
<h3><a name="mref-richsettextlimit"></a>NSD_RichEd_SetTextLimit</h3>
<p><code>${NSD_RichEd_SetTextLimit} <i>control_HWND</i> <i>limit</i></code></p>
<p>Sets the input length limit.</p>
<h3><a name="mref-richseteventmask"></a>NSD_RichEd_SetEventMask</h3>
<p><code>${NSD_RichEd_SetEventMask} <i>control_HWND</i> <i>eventmask</i></code></p>
<h3><a name="mref-richsetbkclr"></a>NSD_RichEd_SetCustomBackgroundColor</h3>
<p><code>${NSD_RichEd_SetCustomBackgroundColor} <i>control_HWND</i> <i>COLORREF</i></code></p>
<h3><a name="mref-getstate"></a>NSD_GetState</h3>
<p><code>${NSD_GetState} <i>control_HWND</i> <i>$output_variable</i></code></p>
<p>Retrieves the state of a check box or a radio button control. Possible outputs are ${BST_CHECKED} and ${BST_UNCHECKED}.</p>

View file

@ -1,5 +1,6 @@
!include nsDialogs.nsh
!include LogicLib.nsh
!include Util.nsh ; IntPtrOp
!include WinCore.nsh ; MAKELONG
Name "nsDialogs Example"
@ -16,6 +17,7 @@ Page license
Page custom nsDialogsPage
Page custom LBPage
Page custom RangesPage
Page custom NotifyPage
!pragma warning disable 8000 ; "Page instfiles not used, no sections will be executed!"
Var BUTTON
@ -171,5 +173,38 @@ Function RangesTimer
FunctionEnd
Function NotifyPage
!insertmacro BeginControlsTestPage "WM_NOTIFY"
${NSD_CreateRichEdit} 1 1 -2 -2 ""
Pop $9
${NSD_OnNotify} $9 OnNotify
${NSD_RichEd_SetEventMask} $9 ${ENM_LINK}
SendMessage $9 ${EM_AUTOURLDETECT} 1 0
${NSD_SetText} $9 "{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0\pard http://nsis.sf.net\par {\b Click the link}...} "
nsDialogs::Show
FunctionEnd
Function OnNotify
Pop $1 ; HWND
Pop $2 ; Code
Pop $3 ; NMHDR*
${IfThen} $2 <> ${EN_LINK} ${|} Return ${|}
System::Call '*$3(p,p,p,p.r2,p,p,i.r4,i.r5)' ; Extract from ENLINK*
${IfThen} $2 <> ${WM_LBUTTONDOWN} ${|} Return ${|}
IntOp $2 $5 - $4
System::Call '*(ir4,ir5,l,&t$2,i)p.r2' ; Create TEXTRANGE and a text buffer
${If} $2 P<> 0
${IntPtrOp} $3 $2 + 16 ; Find buffer
System::Call '*$2(i,i,p$3)' ; Set buffer in TEXTRANGE
SendMessage $1 ${EM_GETTEXTRANGE} "" $2 $4
${If} $4 <> 0
System::Call 'SHELL32::ShellExecute(p$hWndParent, p0, pr3, p0, p0, i 1)'
${EndIf}
System::Free $2
${EndIf}
FunctionEnd
Section
SectionEnd

View file

@ -533,6 +533,9 @@ IntOp ${RET} ${RET} & ${BIT}
### RichEdit ###
!define NSD_RichEd_SetTextLimit `${__NSD_MkCtlCmd_LP} EM_EXLIMITTEXT 0 `
!define NSD_RichEd_GetEventMask `${__NSD_MkCtlCmd_RV} EM_GETEVENTMASK 0 0 `
!define NSD_RichEd_SetEventMask `${__NSD_MkCtlCmd_LP} EM_SETEVENTMASK 0 ` ; LP:ENM_*
!define NSD_RichEd_SetSystemBackgroundColor `${__NSD_MkCtlCmd} EM_SETBKGNDCOLOR 1 0 ` ; COLOR_WINDOW
!define NSD_RichEd_SetCustomBackgroundColor `${__NSD_MkCtlCmd_LP} EM_SETBKGNDCOLOR 0 ` ; LP:COLORREF
!define NSD_RichEd_SetHideSelection `${__NSD_MkCtlCmd_WP} EM_HIDESELECTION 0 ` ; WP(BOOL):HideSelWithoutFocus (Toggles ES_NOHIDESEL & TXTBIT_HIDESELECTION)

View file

@ -226,16 +226,34 @@ TVM Tree-view control
!define /math EM_EXGETSEL ${WM_USER} + 52
!define /math EM_EXLIMITTEXT ${WM_USER} + 53
!define /math EM_EXLINEFROMCHAR ${WM_USER} + 54
!define /math EM_GETEVENTMASK ${WM_USER} + 59
!define /math EM_GETOLEINTERFACE ${WM_USER} + 60
!define /math EM_HIDESELECTION ${WM_USER} + 63
!define /math EM_SETBKGNDCOLOR ${WM_USER} + 67
!define /math EM_SETEVENTMASK ${WM_USER} + 69
!define /math EM_STREAMIN ${WM_USER} + 73
!define /math EM_STREAMOUT ${WM_USER} + 74
!define /math EM_GETTEXTRANGE ${WM_USER} + 75
!define /math EM_SETOPTIONS ${WM_USER} + 77
!define /math EM_GETOPTIONS ${WM_USER} + 78
!define /math EM_SETUNDOLIMIT ${WM_USER} + 82 ; v2+
!define /math EM_AUTOURLDETECT ${WM_USER} + 91
!define /math EM_SETFONTSIZE ${WM_USER} + 223 ; v3+
!define /math EM_SETEDITSTYLE ${WM_USER} + 204 ; v3+
!define /math EM_SETFONTSIZE ${WM_USER} + 223
!define EN_MSGFILTER 0x0700
!define EN_SELCHANGE 0x0702
!define EN_LINK 0x070b
!define ENM_NONE 0x00000000
!define ENM_CHANGE 0x00000001
!define ENM_UPDATE 0x00000002
!define ENM_SCROLL 0x00000004
!define ENM_SCROLLEVENTS 0x00000008
!define ENM_KEYEVENTS 0x00010000
!define ENM_MOUSEEVENTS 0x00020000
!define ENM_SELCHANGE 0x00080000
!define ENM_LINK 0x04000000 ; v2+
#Listbox Messages#
!define LB_ADDFILE 0x0196