From: Jeroen v. d. Z. <je...@fo...> - 2009-08-11 20:16:56
|
On Tuesday 11 August 2009, Feng Feng wrote: > Hello all, > > Is there a workaround that I can use for creating a dialog with only yes and cancel buttons? > > For now, there is not such a option MBOX_YES_CANCEL Feng, Would OK_CANCEL do the trick, perhaps? OK practically means the same thing as YES. If not, message box is mostly a convenience for common cases; its not all that much work to create more specialized dialogs for unenvisioned scenarios. The following 9 lines of code create a dialog with Yes/Cancel. You can eliminate a few lines if you have no icon or simpler layout requirements: MyMessageBox::MyMessageBox(FXWindow* own,const FXString& caption,const FXString& text,FXIcon* icn,FXuint opts,FXint x,FXint y):FXDialogBox(own,caption,opts|DECOR_TITLE|DECOR_BORDER,x,y,0,0, 0,0,0,0, 4,4){ FXVerticalFrame* content=new FXVerticalFrame(this,LAYOUT_FILL_X|LAYOUT_FILL_Y); FXHorizontalFrame* info=new FXHorizontalFrame(content,LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y,0,0,0,0,10,10,10,10); new FXLabel(info,FXString::null,icn,ICON_BEFORE_TEXT|LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y); new FXLabel(info,text,NULL,JUSTIFY_LEFT|ICON_BEFORE_TEXT|LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y); new FXHorizontalSeparator(content,SEPARATOR_GROOVE|LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FILL_X); FXHorizontalFrame* buttons=new FXHorizontalFrame(content,LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH,0,0,0,0,10,10,5,5); FXButton * initial=new FXButton(buttons,tr("&YES"),NULL,this,ID_CLICKED_OK,BUTTON_INITIAL|BUTTON_DEFAULT|FRAME_RAISED|FRAME_THICK|LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_CENTER_X,0,0,0,0,HORZ_PAD,HORZ_PAD,VERT_PAD,VERT_PAD); new FXButton(buttons,tr("&Cancel"),NULL,this,ID_CLICKED_CANCEL,BUTTON_DEFAULT|FRAME_RAISED|FRAME_THICK|LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_CENTER_X,0,0,0,0,HORZ_PAD,HORZ_PAD,VERT_PAD,VERT_PAD); initial->setFocus(); } Hope this helps, - Jeroen |