0

如何在对话框的右侧排列一组按钮?

下面是示例源代码,但它不能按预期工作:

#include <stdlib.h>
#include <stdio.h>
#include <iup.h>

int main(int argc, char **argv)
{
IupOpen(&argc, &argv);

Ihandle *lbl_center = IupLabel("center label text");
IupSetAttribute(lbl_center, "ALIGNMENT", "ACENTER");
IupSetAttribute(lbl_center, "SIZE", "x20");
IupSetAttribute(lbl_center, "EXPAND", "HORIZONTAL");
Ihandle *hbx_lbl_center = IupHbox(lbl_center, NULL);

Ihandle *lbl_left = IupLabel("left label text");
IupSetAttribute(lbl_left, "ALIGNMENT", "ALEFT");
IupSetAttribute(lbl_left, "SIZE", "x20");
IupSetAttribute(lbl_left, "EXPAND", "HORIZONTAL");
Ihandle *hbx_lbl_left = IupHbox(lbl_left, NULL);

Ihandle *lbl_right = IupLabel("right label text");
IupSetAttribute(lbl_right, "ALIGNMENT", "ARIGHT");
IupSetAttribute(lbl_right, "SIZE", "x20");
IupSetAttribute(lbl_right, "EXPAND", "HORIZONTAL");
Ihandle *hbx_lbl_right = IupHbox(lbl_right, NULL);

Ihandle *btn_create = IupButton("Start", NULL);
IupSetAttribute(btn_create, "SIZE", "30");
Ihandle *btn_update = IupButton("Stop", NULL);
IupSetAttribute(btn_update, "SIZE", "30");
Ihandle *btn_delete = IupButton("Exit", NULL);
IupSetAttribute(btn_delete, "SIZE", "30");
Ihandle *hbx_btn_group = IupHbox(btn_create, btn_update, btn_delete, NULL);
IupSetAttribute(hbx_btn_group, "CMARGIN", "5x5");

Ihandle *vbx_box = IupVbox(hbx_btn_group, NULL);
IupSetAttribute(vbx_box, "ALIGNMENT", "ARIGHT"); // <- does not work

Ihandle *vbox_dlg = IupVbox(hbx_lbl_center, hbx_lbl_left, hbx_lbl_right /* + will be more boxes */, vbx_box, NULL);
Ihandle *dlg = IupDialog(vbox_dlg);
// The width of the dialog window may be vary
IupSetAttribute(dlg, "SIZE", "200x");
IupSetAttribute(dlg, "RESIZE", "NO");

IupShowXY(dlg, IUP_CENTER, IUP_CENTER);

IupMainLoop();

IupClose();
return EXIT_SUCCESS;
}

截屏:

在此处输入图像描述

4

0 回答 0