CODE
LRESULT playlists_dropdown::on_message(HWND wnd, UINT msg, WPARAM wp, LPARAM lp)
{
switch (msg) {
.
.
case WM_CREATE:
{
m_tracker.initialize(this);
g_notify_list.add_item(wnd);
RECT rc;
GetClientRect(wnd, &rc);
m_hWnd = CreateWindowEx(WS_EX_CLIENTEDGE, WC_COMBOBOX,
0, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | WS_VSCROLL | WS_CHILD | WS_VISIBLE | WS_TABSTOP,
0, 0, rc.right, rc.bottom, wnd, HMENU(0), core_api::get_my_instance(), NULL);
g_update_all_sizes();
}
break;
.
.
case WM_GETMINMAXINFO:
{
MINMAXINFO * mmi;
mmi = (MINMAXINFO *) lp;
RECT rc;
GetWindowRect(m_hWnd, &rc);
/* DEBUG */
/* */ char buf[256];
/* */ sprintf(buf, "(%dx%d)", rc.right - rc.left, rc.bottom - rc.top);
/* */ console::info(buf);
/* DEBUG */
mmi->ptMinTrackSize.y = rc.bottom - rc.top;
}
break;
}
}
{
switch (msg) {
.
.
case WM_CREATE:
{
m_tracker.initialize(this);
g_notify_list.add_item(wnd);
RECT rc;
GetClientRect(wnd, &rc);
m_hWnd = CreateWindowEx(WS_EX_CLIENTEDGE, WC_COMBOBOX,
0, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | WS_VSCROLL | WS_CHILD | WS_VISIBLE | WS_TABSTOP,
0, 0, rc.right, rc.bottom, wnd, HMENU(0), core_api::get_my_instance(), NULL);
g_update_all_sizes();
}
break;
.
.
case WM_GETMINMAXINFO:
{
MINMAXINFO * mmi;
mmi = (MINMAXINFO *) lp;
RECT rc;
GetWindowRect(m_hWnd, &rc);
/* DEBUG */
/* */ char buf[256];
/* */ sprintf(buf, "(%dx%d)", rc.right - rc.left, rc.bottom - rc.top);
/* */ console::info(buf);
/* DEBUG */
mmi->ptMinTrackSize.y = rc.bottom - rc.top;
}
break;
}
}
CODE
void playlists_dropdown::g_update_all_sizes()
{
unsigned n;
unsigned count = g_instances.get_count();
unsigned font_height = uGetFontHeight(g_font);
for (n = 0; n < count; n++) {
HWND wnd = g_instances[n]->m_hWnd;
if (wnd) {
SendMessage(wnd, CB_SETITEMHEIGHT, -1, font_height + cfg_padding);
SendMessage(wnd, CB_SETITEMHEIGHT, 0, font_height + cfg_padding);
}
/* DEBUG */
/* */ RECT rc;
/* */ GetWindowRect(wnd, &rc);
/* */ char buf[256];
/* */ sprintf(buf, "%d: (%dx%d)", n, rc.right - rc.left, rc.bottom - rc.top);
/* */ console::info(buf);
/* DEBUG */
g_instances[n]->get_host()->on_size_limit_change(g_notify_list[n], uie::size_limit_flag_t::size_limit_minimum_height);
}
}
{
unsigned n;
unsigned count = g_instances.get_count();
unsigned font_height = uGetFontHeight(g_font);
for (n = 0; n < count; n++) {
HWND wnd = g_instances[n]->m_hWnd;
if (wnd) {
SendMessage(wnd, CB_SETITEMHEIGHT, -1, font_height + cfg_padding);
SendMessage(wnd, CB_SETITEMHEIGHT, 0, font_height + cfg_padding);
}
/* DEBUG */
/* */ RECT rc;
/* */ GetWindowRect(wnd, &rc);
/* */ char buf[256];
/* */ sprintf(buf, "%d: (%dx%d)", n, rc.right - rc.left, rc.bottom - rc.top);
/* */ console::info(buf);
/* DEBUG */
g_instances[n]->get_host()->on_size_limit_change(g_notify_list[n], uie::size_limit_flag_t::size_limit_minimum_height);
}
}
Where:
- m_hWnd is the window of my ComboBox.
- g_instances (global variable) is the list of instances of my plugin (-> m_tracker is instance_tracker_client_t<playlists_dropdown,g_instances>).
- g_notify_list (static field) is the list of of active windows.
The weird thing is that inside g_update_all_sizes, dimensions of my ComboBox are reported right (for example "248x41"). But when the WM_GETMINMAXINFO message is processed (after calling on_size_limit_change()), the dimensions of the same m_hWnd are reported to be "0x0"! How is this possible?
When I call g_update_all_sizes() some time *after* the window is created, for example from my Preferences Page, everything works OK.
EDIT: I forgot to mesnion, that I'm writing Columns UI extension, based on Console UIE example from Columns UI SDK.