Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / wxStaticText in dialog??

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. wxStaticText in dialog??
#4775
Posted by: 2004-07-10 01:14:54
Hello,

I`m trying to have a label in a simple wxMessageDialog Box (OK).
I need to have a message box but with a label where i can control the background color, the font and the size (wxStaticText seems like the right option). Is it possible using dialogs or am I forced to use the frame where I create a panel in which I will have the label and a panel for the button.

Thank you

Mona
Message2. Re: wxStaticText in dialog??
#4782
Posted by: upCASE 2004-07-10 22:25:59
Hi!
It's possible:

#include <wx/wx.h>
#include <wx/image.h>

#ifndef MYDIALOG_H
#define MYDIALOG_H

class MyDialog: public wxDialog {
public:
    MyDialog(wxWindow* parent, int id, const wxString& title, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE);

private:
    wxStaticText* label_1;
    wxButton* button1;
};
#endif // MYDIALOG_H

#include "MyDialog.h"
MyDialog::MyDialog(wxWindow* parent, int id, const wxString& title, const wxPoint& pos, const wxSize& size, long style):
    wxDialog(parent, id, title, pos, size, wxDEFAULT_DIALOG_STYLE)
{
    label_1 = new wxStaticText(this, -1, wxT("Lovely, isn't it?"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE);
    button1 = new wxButton(this, -1, wxT("OK"));

    SetTitle(wxT("My cool dialog"));
    label_1->SetBackgroundColour(wxColour(124, 21, 255));
    label_1->SetForegroundColour(wxColour(255, 0, 0));
    label_1->SetFont(wxFont(28, wxDEFAULT, wxNORMAL, wxNORMAL, 0, ""));
    button1->SetDefault();

    wxBoxSizer* sizer_1 = new wxBoxSizer(wxVERTICAL);
    sizer_1->Add(label_1, 1, wxALL|wxEXPAND, 5);
    sizer_1->Add(button1, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
    SetAutoLayout(true);
    SetSizer(sizer_1);
    sizer_1->Fit(this);
    sizer_1->SetSizeHints(this);
    Layout();

}
upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message3. Re: wxStaticText in dialog??
#4805
Posted by: 2004-07-12 23:04:05
Thank you,

You're being of enormous help!!! I'm solving bit by bit all these problems with wxWidgets and I'm starting to get the hang of it!

Mona
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2024-3-29  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0