B4J Code Snippet Tweak the HTMLEditor toolbars AFTER loading a modal

Discussion in 'B4J Code Snippets' started by Crock, Jan 31, 2019.

  1. Crock

    Crock Member Licensed User

    Somebody might find this workaround handy.

    I needed to edit some HTML text with a few basic commands (bold, underline etc) with the HTMLEditor in a modal window on top of the main form. I can simplify the HTMLEditor's toolbar by hiding the top row and all the ComboBoxes in the lower one with custom routines (not shown below).

    It makes sense that the HTMLEditor must be displayed before you can change its toolbar elements but ShowAndWait prevents us from auto-executing code after it shows the modal form. Luckily, in my case, it seems that the HTMLEditor_Resize event is fired when it displays and we can call the toolbar changes from there. Do let me know if there is a simpler or better way to do this.

    Code in the MainForm:
    Sub btnReviseTopic_Click
    Dim frmModal As Form     
       HTMLEditor1.HtmlText = txtTopic.Text
    'No good calling the toolbar hacks here
    'code here gets called after the modal form closes
    End Sub

    Sub HTMLEditor1_Resize (Width As Double, Height As Double)
    'This event happens AFTER ShowAndWait
       SetToolbar(HTMLEditor1,0,False'hides the top (0) toolbar
       HideToolbarCombos(HTMLEditor1,1'hide Paragraph, Font etc on lower toolbar (1)
    End Sub
  2. Erel

    Erel Administrator Staff Member Licensed User

    I don't recommend using modal dialogs.

    You should do something like:
    Do Until <a condition is met, I'm not sure which condition>
    'continue here
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice