Skip to content

Inconsistent vertical spacing of trackbars in WinAPI HighGUI backend #22766

@dan-masek

Description

@dan-masek

Windows 10, OpenCV 4.6.0 (and many more)

Once more than 2 trackbars are added, it becomes evident that the vertical spacing between them is not consistent:
image

In more detail (further rows also have 21 pixels):
image

The culprit is an off-by-one error on line 2434:

/* Retrieve current buttons count */
int bcount = (int)SendMessage(window.toolbar.toolbar, TB_BUTTONCOUNT, 0, 0);
if (bcount > 1)
{
/* If this is not the first button then we need to
separate it from the previous one */
tbs.iBitmap = 0;
tbs.idCommand = bcount; // Set button id to it's number
tbs.iString = 0;
tbs.fsStyle = TBSTYLE_SEP;
tbs.fsState = TBSTATE_ENABLED;
SendMessage(window.toolbar.toolbar, TB_ADDBUTTONS, 1, (LPARAM)&tbs);
// Retrieve current buttons count
bcount = (int)SendMessage(window.toolbar.toolbar, TB_BUTTONCOUNT, 0, 0);
}

Once there is at least 1 button, a separator should be added, hence if (bcount > 0).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions