1 parent
5ea222ad8a
commit
ea6338e9b9
9 files changed
+613
-119
No files matched your search
+17
-9
@@ -4046,26 +4046,34 @@ LONG farDialogButtonWidth(HWND button)
|
||||
return (characters+5)*cellWidth;
|
||||
}
|
||||
|
||||
LONG dialogButtonWidth(HWND dialog,int id,bool native)
|
||||
{
|
||||
if(!native) return farDialogButtonWidth(GetDlgItem(dialog,id));
|
||||
const auto bounds=dialogControlBounds(dialog,id);
|
||||
return bounds.right-bounds.left;
|
||||
}
|
||||
|
||||
LONG dialogButtonGroupWidth(HWND dialog,std::initializer_list<int> controls,bool native=false)
|
||||
{
|
||||
const auto gap=dialogColumnGap();
|
||||
LONG width=-gap;
|
||||
for(const auto id:controls) width+=dialogButtonWidth(dialog,id,native)+gap;
|
||||
return std::max(0L,width);
|
||||
}
|
||||
|
||||
void groupDialogButtons(HWND dialog,std::initializer_list<int> controls,bool native=false)
|
||||
{
|
||||
RECT client{};
|
||||
GetClientRect(dialog,&client);
|
||||
const auto gap=dialogColumnGap();
|
||||
const auto width=[&](int id)
|
||||
{
|
||||
if(!native) return farDialogButtonWidth(GetDlgItem(dialog,id));
|
||||
const auto bounds=dialogControlBounds(dialog,id);
|
||||
return bounds.right-bounds.left;
|
||||
};
|
||||
LONG rowWidth=-gap;
|
||||
for(const auto id:controls) rowWidth+=width(id)+gap;
|
||||
const auto rowWidth=dialogButtonGroupWidth(dialog,controls,native);
|
||||
if(rowWidth>client.right) return;
|
||||
auto x=native?dialogControlBounds(dialog,*(controls.end()-1)).right-rowWidth:
|
||||
(client.right-rowWidth)/2;
|
||||
for(const auto id:controls)
|
||||
{
|
||||
const auto bounds=dialogControlBounds(dialog,id);
|
||||
const auto buttonWidth=width(id);
|
||||
const auto buttonWidth=dialogButtonWidth(dialog,id,native);
|
||||
SetWindowPos(GetDlgItem(dialog,id),nullptr,x,bounds.top,buttonWidth,bounds.bottom-bounds.top,
|
||||
SWP_NOZORDER|SWP_NOACTIVATE);
|
||||
x+=buttonWidth+gap;
|
||||
|
||||
Reference in new issue
Block a user