Window helpers

These classes can be used to make implementing panels easier.

Container window

struct container_window_v3_config

Window and window class styles, names and other parameters for a container_window_v3.

Public Functions

inline container_window_v3_config(const wchar_t *class_name, bool use_transparent_background = true, unsigned class_styles = 0)

Public Members

const wchar_t *class_name = {}
bool use_transparent_background = {true}

Whether to use the parent window’s background for this window.

If true, on_message() will not be called when the WM_ERASEBKGND message is received. The window (but not its children) will also be invalidated on resize or move.

You can also set this to false and use uie::win32::paint_background_using_parent() in your on_message() implementation for more flexibility.

If set to false, you should ensure a background is painted for this window.

bool invalidate_children_on_move_or_resize = {}
bool forward_wm_settingchange = {true}

Whether to forward WM_SETTINGCHANGE messages to direct child windows.

This should be set to false if a toolbar control is a direct child window, as they can misbehave when handling WM_SETTINGCHANGE.

unsigned window_styles = {WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS}
unsigned extended_window_styles = {WS_EX_CONTROLPARENT}
unsigned class_styles = {}
LPWSTR class_cursor = {IDC_ARROW}
HBRUSH class_background = {}
const wchar_t * window_title   = {L""}
int class_extra_wnd_bytes = {}
class container_window_v3

Implements a window that serves either as an empty container for other windows, or as window for a custom control.

Public Functions

inline container_window_v3(container_window_v3_config config, std::function<LRESULT(HWND wnd, UINT msg, WPARAM wp, LPARAM lp)> on_message = nullptr)
container_window_v3(const container_window_v3 &p_source) = delete
container_window_v3 &operator=(const container_window_v3 &p_source) = delete
HWND create(HWND wnd_parent, int x, int y, int cx, int cy)
HWND create(HWND wnd_parent)
void destroy() const

Destroy the window.

If this is the last instance of this window class, the window class will also be deregistered.

inline HWND get_wnd() const
void deregister_class() const

Deregister the window class.

If not using destroy() to destryoy the window, call this to deregister the window class when all windows belonging to the class have ben destroyed.

template<class Base = window>
class container_uie_window_v3_t : public uie::window

A base implementation of uie::window using uie::container_window_v3

Public Functions

virtual container_window_v3_config get_window_config() = 0

Get window and window class styles, names and other parameters.

virtual LRESULT on_message(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) = 0
inline virtual bool is_available(const window_host_ptr &p) const override

Get availability of the extension.

This method is called before create_or_transfer() to test, if this call will be legal. If this instance is already hosted, it should check whether the given host’s GUID equals its current host’s GUID, and should return false, if it does. This is mostly important for single instance extensions.

Extensions that support multiple instances can generally return true.

Returns:

whether this instance can be created in or moved to the given host

inline const window_host_ptr &get_host() const
inline virtual HWND get_wnd() const final

Gets extension window handle.

Pre:

May only be called on hosted extensions.

Returns:

Window handle of the extension window

inline virtual HWND create_or_transfer_window(HWND parent, const window_host_ptr &host, const ui_helpers::window_position_t &position) final

Create or transfer extension window.

Create your window here.

In the case of single instance panels, if your window is already created, you must (in the same order):

  • Hide your window. i.e:

    ShowWindow(wnd, SW_HIDE) 
    

  • Set the parent window to to wnd_parent. I.e.

    SetParent(get_wnd(), wnd_parent) 
    

  • Move your window to the new window position. I.e.:

    SetWindowPos(get_wnd(), NULL, p_position.x, p_position.y, p_position.cx, p_position.cy, SWP_NOZORDER);
    

  • Call relinquish_ownership() on your current host.

Other rules you should follow are:

  • Ensure you are using the correct window styles. The window MUST have the WS_CHILD window style. It MUST NOT have the WS_POPUP, WS_CAPTION styles.

  • The window must be created hidden.

  • Use WS_EX_CONTROLPARENT if you have child windows that receive keyboard input, and you want them to be included in tab operations in the host window.

  • Do not directly create a common control as your window. You must create a window to contain any common controls, and any other controls that communicate to the parent window via WM_COMMAND and WM_NOTIFY window messages.

  • Under NO CIRCUMSTANCES may you subclass the host window.

  • If you are not hosting any panels yourself, you may dialog manage your window if you wish.

  • The window MUST have a dialog item ID of 0.

Parameters:
  • wnd_parent[in] Handle to the window to use as the parent for your window

  • p_host[in] Pointer to the host that creates the extension. This parameter may not be NULL.

  • p_position[in] Initial position of the window

Pre:

May only be called if is_available() returned true.

Returns:

Window handle of the panel window

inline virtual void destroy_window() final

Destroys the extension window.

using uie::container_uie_window_v3 = container_uie_window_v3_t<>

Functions

LRESULT uie::win32::paint_background_using_parent(HWND wnd, HDC dc, bool use_wm_printclient)