Preventing window move and resize

12 views
Skip to first unread message

Paul Young

unread,
Sep 16, 2021, 9:47:07 PM9/16/21
to wx-u...@googlegroups.com
I'm trying to do something a bit unusual.

I have an application which uses wxWidgets. It puts up windows which have buttons.  Often this is on a touch screen.  Sometimes the users miss the buttons and accidentally move or resize the windows.

I would like to have an option which turns off the ability to move or resize the windows.  The users could resize the windows and put them where they want them and then turn this on to keep them from changing.

Also, when my program is being used there is often another program running which the user types information into.  My program gets the window handle of this other program and when the user touches or clicks a button it puts  keyboard focus on the other program.  This works fairly well but it would be better if my program never took  keyboard focus.

I've tried to find ways to do this under Windows but so far I have not been successful.  Is it possible to do these things?  I realize they are non-standard and probably violate UI guidelines.

    Paul

Igor Korot

unread,
Sep 17, 2021, 12:49:00 AM9/17/21
to wx-u...@googlegroups.com
Hi,,

On Thu, Sep 16, 2021 at 8:47 PM Paul Young <k1...@k1xm.org> wrote:
>
> I'm trying to do something a bit unusual.
>
> I have an application which uses wxWidgets. It puts up windows which have buttons. Often this is on a touch screen. Sometimes the users miss the buttons and accidentally move or resize the windows.
>
> I would like to have an option which turns off the ability to move or resize the windows. The users could resize the windows and put them where they want them and then turn this on to keep them from changing.

Trying to create an empty EVT_SIZE handler.
Dont do anything there.

>
> Also, when my program is being used there is often another program running which the user types information into. My program gets the window handle of this other program and when the user touches or clicks a button it puts keyboard focus on the other program. This works fairly well but it would be better if my program never took keyboard focus.

Try to catch EVT_ACTIVATE on your window main frame and give the focus
to something else..

Thank you.

>
> I've tried to find ways to do this under Windows but so far I have not been successful. Is it possible to do these things? I realize they are non-standard and probably violate UI guidelines.
>
> Paul
>
> --
> Please read https://www.wxwidgets.org/support/mlhowto.htm before posting.
> ---
> You received this message because you are subscribed to the Google Groups "wx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to wx-users+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/wx-users/CAPPa5ucdEaOO-DMnTobL5CaSOnM91fsK38%3D7AiL1D6x_LwH4FQ%40mail.gmail.com.

Eric Jensen

unread,
Sep 17, 2021, 3:04:53 AM9/17/21
to Paul Young
Hello Paul,

Friday, September 17, 2021, 3:46:53 AM, you wrote:

PY> keyboard focus on the other program. This works fairly well but it would
PY> be better if my program never took keyboard focus.

PY> I've tried to find ways to do this under Windows but so far I have not been
PY> successful. Is it possible to do these things? I realize they are
PY> non-standard and probably violate UI guidelines.

Set the WS_EX_NOACTIVATE window style flag
https://docs.microsoft.com/en-us/windows/win32/winmsg/extended-window-styles

HWND hwnd = (HWND)this->GetHandle(); // this = your toplevelwindow
long oldstyle = ::GetWindowLong(hwnd, GWL_EXSTYLE);
::SetWindowLong(hwnd, GWL_EXSTYLE, oldstyle|WS_EX_NOACTIVATE );

Eric



Vadim Zeitlin

unread,
Sep 17, 2021, 9:34:37 AM9/17/21
to wx-u...@googlegroups.com
On Thu, 16 Sep 2021 21:46:53 -0400 Paul Young wrote:

PY> I have an application which uses wxWidgets. It puts up windows which have
PY> buttons. Often this is on a touch screen. Sometimes the users miss the
PY> buttons and accidentally move or resize the windows.
PY>
PY> I would like to have an option which turns off the ability to move or
PY> resize the windows.

Windows not using wxRESIZE_BORDER style can't be resized at all, so if you
don't want to allow it, the simplest is to just not use this style when
creating your frames. You probably also want to avoid using wxMAXIMIZE_BOX
in this case.

Moving can be effectively forbidden by not using wxSYSTEM_MENU style
neither, or you could just maximize the window which ensures that it can't
be moved as a side effect.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Reply all
Reply to author
Forward
0 new messages