Menu

WidgetTextBox problem

2004-09-28
2013-04-08
  • Jugoslav Stojanov

    Hi,

    I must say it's a excellent code library. Im impressed how is easy to make win application using SmartWin.

    But, I have a problem with WidgetTextBox... I was try to modify Notepad example to change EDIT control and set ES_MULTILINE and ES_WANTRETURN.
    textField->addRemoveStyle() are inacessible from main window. Even more, I was try to change WidgetTextBox ctor or create method, but with no luck. So, how to do this?

    yooyo

     
    • Thomas Hansen

      Thomas Hansen - 2004-09-29

      Hi there, and thank you for the flattering words...
      :)

      The Windows API was actually very unclear regarding the ES_MULTILINE and many of the other styles to editcontrols (and other controls) when I first figured it out myself...

      And that very example you're describing was actually the reason I had all the createxxx functions in WidgetFactory take a "CreationalStruct" which defaulted to "SmartWin::private_::defaultCreationalStruct"

      The problem is that some of the styles to e.g. the editcontrol (which the WidgetTextBox internally is represented as) CAN NOT be set after you create the control.
      You therefor need to set them while creating the Widget.
      This is quite easy, just pass in your own instance of a SmartWin::CreationalStruct to your createTextBox call and you can set any styles you wish (almost, you CAN'T remove the WS_CHILD or the WS_VISIBLE since they're added internally anyway)

      If you take a look at the WidgetTextBox project in the Main.cpp file (obviously since it's the only file i the project ;) ) you can see and example of how to do this at line 44 where there is a call to "createRichTextBox" with a CreationalStruct which has added the "ES_PASSWORD" style...

      Just do something similar (pass in your own CreationalStruct to createTextBox) and add e.g. the ES_MULTILINE to the style member of of your cs and you should be able to have a multiline WidgetTextBox...

      BTW!
      ALL Widgets takes a CreationalStruct object in their createxxx functions and here you can set the style (member "style") the extended style (exStyle) and even the size of your widget (member rect)

      Thomas

       
      • Nobody/Anonymous

        I had the same problem, addRemoveStyle apparently did nothing:). I think there should be a warning about this in the documentation. Actually, I wonder why this function is even made accesible.

         
    • Jugoslav Stojanov

      10x.. It works...

      yooyo

       

Log in to post a comment.