How to fill content of textbox dynamically

Please let our ADS show!

This sites offers only FREE software and it's supported by a few advertisement boxes (no intrusive popups).
Please:

  • disable your AdBlocker by adding CoolSoft website to whitelist
  • give the proper cookie consent
  • enable JavaScript for this website

This seconds wait is to let you update your browser configuration...

Ok, I've done the required changes... now show me your content!
!!! Please enable JavaScript !!!
Anonymous user
How to fill content of textbox dynamically

I tried your designer, and generate texbox on custom page. I am able dynamically show or hide custom page, but no content is in textobjects shown.

Can you help me?

Thanks, Mark

Page custom DisplayErrors_creator
 
; handle variables
Var hCtl_displayerrors
Var hCtl_displayerrors_lblInfo
Var hCtl_displayerrors_txtErrors
Var hCtl_displayerrors_txtCount
Var hCtl_displayerrors_Font1
 
; dialog create function
Function fnc_displayerrors_Create
 
  ; custom font definitions
  CreateFont $hCtl_displayerrors_Font1 "Microsoft Sans Serif" "9.75" "400"
 
  ; === displayerrors (type: Dialog) ===
  nsDialogs::Create 1018
  Pop $hCtl_displayerrors
  ${If} $hCtl_displayerrors == error
    Abort
  ${EndIf}
 
  ; === lblInfo (type: Label) ===
  ${NSD_CreateLabel} 8u 13u 148u 11u "During installation was found such errors :"
  Pop $hCtl_displayerrors_lblInfo
  SendMessage $hCtl_displayerrors_lblInfo ${WM_SETFONT} $hCtl_displayerrors_Font1 0
 
  ; === txtErrors (type: TextMultiline) ===
  nsDialogs::CreateControl EDIT ${DEFAULT_STYLES}|${ES_AUTOHSCROLL}|${ES_AUTOVSCROLL}|${ES_MULTILINE}|${ES_WANTRETURN}|${WS_HSCROLL}|${WS_VSCROLL} ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE} 8u 26u 280u 95u ""
  Pop $hCtl_displayerrors_txtErrors
  SendMessage $hCtl_displayerrors_txtErrors ${ES_MULTILINE} 0 0
 
  ; === txtCount (type: Text) ===
  ${NSD_CreateText} 160u 13u 127u 11u ""
  Pop $hCtl_displayerrors_txtCount
 
FunctionEnd
 
Function fnc_displayerrors_Show
  Call fnc_displayerrors_Create
  nsDialogs::Show $hCtl_displayerrors
FunctionEnd
 
Function DisplayErrors_creator
; ============================
    ${If} giMSI_EXEC_ERRORS != 0
    ${AndIf} $giREGSVR32_ERRORS != 0
        Abort
    ${EndIf}
 
;
    Call fnc_displayerrors_Show
;
    SendMessage $hCtl_displayerrors_txtErrors ${WM_SETTEXT} 0 "STR:Hello!"
    SendMessage $hCtl_displayerrors_txtCount ${WM_SETTEXT} 0 "STR:(2 errors)"
FunctionEnd

 

Posts: 1972
Joined: 25 Mar 2012 - 01:19
You're calling fnc

You're calling fnc_displayerrors_Show, but this function won't return till the dialog is shown (modal).
So your next 2 calls to SendMessage will be too late.

NSISDialogDesigner allows you to only create the dialog, customize it and then show it to the user.
Your function should be like this:

Function DisplayErrors_creator
 
  ${If} giMSI_EXEC_ERRORS != 0
    ${AndIf} $giREGSVR32_ERRORS != 0
        Abort
    ${EndIf}
 
    ; create the dialog and customize it
    Call fnc_displayerrors_Create
    SendMessage $hCtl_displayerrors_txtErrors ${WM_SETTEXT} 0 "STR:Hello!"
    SendMessage $hCtl_displayerrors_txtCount ${WM_SETTEXT} 0 "STR:(2 errors)"
 
    ; dialog show (modal)
    nsDialogs::Show $hCtl_displayerrors
 
FunctionEnd

I suppose your customization is more complex than this and you're not going to add static text to your controls, so I suggest you to take a look at ControlCustomScript property of Textbox control and also to CreateFunctionCustomScript property of dialog.
These properties allows you to customize the generated script as you like (changes appear immediately into script preview): you could move your SendMessage calls over there and clean up your script.