MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / if

Function if

source/script_gui.cpp:3926–3943  ·  view source on GitHub ↗

Set font unconditionally to simplify calculations, which help ensure that at least one item in the DropDownList/Combo is visible when the list drops down:

Source from the content-addressed store, hash-verified

3924 // Set font unconditionally to simplify calculations, which help ensure that at least one item
3925 // in the DropDownList/Combo is visible when the list drops down:
3926 GUI_SETFONT // Set font in preparation for asking it how tall each item is.
3927 if (calc_control_height_from_row_count)
3928 {
3929 item_height = (int)SendMessage(control.hwnd, CB_GETITEMHEIGHT, 0, 0);
3930 // Note that at this stage, height should contain a explicitly-specified height or height
3931 // estimate from the above, even if row_count is greater than 0.
3932 // The below calculation may need some fine tuning:
3933 int cbs_extra_height = ((style & CBS_SIMPLE) && !(style & CBS_DROPDOWN)) ? 4 : 2;
3934 min_list_height = (2 * item_height) + GUI_CTL_VERTICAL_DEADSPACE + cbs_extra_height;
3935 if (opt.height < min_list_height) // Adjust so that at least 1 item can be shown.
3936 opt.height = min_list_height;
3937 else if (opt.row_count > 0)
3938 // Now that we know the true item height (since the control has been created and we asked
3939 // it), resize the control to try to get it to the match the specified number of rows.
3940 // +2 seems to be the exact amount needed to prevent partial rows from showing
3941 // on all font sizes and themes when NOINTEGRALHEIGHT is in effect:
3942 opt.height = (int)(opt.row_count * item_height) + GUI_CTL_VERTICAL_DEADSPACE + cbs_extra_height;
3943 }
3944 MoveWindow(control.hwnd, opt.x, opt.y, opt.width, opt.height, TRUE); // Repaint, since it might be visible.
3945 // Since combo's size is created to accommodate its drop-down height, adjust our true height
3946 // to its actual collapsed size. This true height is used for auto-positioning the next

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected