Changing widget's border dynamically

Guillermo Torreiro gtlists at gmail.com
Fri Apr 6 17:56:50 PDT 2007


It is possible to change dynamically (at runtime) a widget's border,
but not all of the widget's allow it. If wxPanel is a widget, then you'll
see that it's not possible to change its border but, if you try it with a
wxStaticText then you'll see that it is possible. So, it seems that
depends on the type of widget.

An example:
m_lbl is an wxStaticText that it's placed on a panel and it has its
border set to wxSUNKEN_BORDER.

The following is executed every time a button is pressed somewhere in
that panel:
    long flag = wxSUNKEN_BORDER;
    long style = m_lbl->GetWindowStyle();

    style = style ^ flag;
    m_lbl->SetWindowStyle (style);
    m_lbl->SetLabel(wxString::Format(wxT("style<%d>"), style)); // just to check
    m_lbl->Refresh(); // as what the documentation suggest

I have tested this on MSW and Linux, on MSW it works ok, but on Linux
I can't get the wxStaticText to have any type of border ( even when
specifying it
on the ctor ).

Linux => wxGTK-2.8.0
MSW => wxMSW-2.8.3

If you can test it on Linux I'll appreciate any feedback.

Best Regards,
GT


On 4/6/07, Karol Gottan <gottan at op.pl> wrote:
> > Recall our human legacy: Trial and error =)
>
> Of course tried, but it didn't work. However
> it means nothing because it's possible I did
> mistakes in my tests or did it wrongly.
>
> > You will see that you then could make more
>  > precise questions also.
>
> Is my question really so not precise ? I doubt.
>
> In wxWidgets you can set widget's border type
> during widget's construction thru "style" param
> (see almost all wxWidgets constructors).
>
> I would like to change this border type during
> runtime in response to events, using :
>
>    wxWindow::SetWindowStyleFlag(long style)
>
> --
>
> Regards
>   Karol
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>
>




More information about the wx-users mailing list