Forum: Compiler & IDEs wxWidgets text setzen


von phreak (Gast)


Lesenswert?

Hallo, ich habe eine kleine GUI und will das wenn ich auf den Butten 
klicke eine Fehlermeldung erschein:
code des dialogs:
1
/***************************************************************
2
 * Name:      rs232_plotterMain.cpp
3
 * Purpose:   Code for Application Frame
4
 * Author:    goaran (baer@dyyyh.de)
5
 * Created:   2009-07-21
6
 * Copyright: goaran (robotik.dyyyh.de)
7
 * License:
8
 **************************************************************/
9
10
#include "rs232_plotterMain.h"
11
#include "rs232.c"
12
#include <wx/msgdlg.h>
13
//(*InternalHeaders(rs232_plotterDialog)
14
#include <wx/string.h>
15
#include <wx/intl.h>
16
//*)
17
18
//helper functions
19
enum wxbuildinfoformat {
20
    short_f, long_f };
21
22
wxString wxbuildinfo(wxbuildinfoformat format)
23
{
24
    wxString wxbuild(wxVERSION_STRING);
25
26
    if (format == long_f )
27
    {
28
#if defined(__WXMSW__)
29
        wxbuild << _T("-Windows");
30
#elif defined(__UNIX__)
31
        wxbuild << _T("-Linux");
32
#endif
33
34
#if wxUSE_UNICODE
35
        wxbuild << _T("-Unicode build");
36
#else
37
        wxbuild << _T("-ANSI build");
38
#endif // wxUSE_UNICODE
39
    }
40
41
    return wxbuild;
42
}
43
44
//(*IdInit(rs232_plotterDialog)
45
const long rs232_plotterDialog::ID_BUTTON1 = wxNewId();
46
const long rs232_plotterDialog::ID_TEXTCTRL1 = wxNewId();
47
const long rs232_plotterDialog::text1 = wxNewId();
48
//*)
49
50
BEGIN_EVENT_TABLE(rs232_plotterDialog,wxDialog)
51
    //(*EventTable(rs232_plotterDialog)
52
    //*)
53
END_EVENT_TABLE()
54
55
rs232_plotterDialog::rs232_plotterDialog(wxWindow* parent,wxWindowID id)
56
{
57
    //(*Initialize(rs232_plotterDialog)
58
    wxGridSizer* GridSizer1;
59
60
    Create(parent, wxID_ANY, _("wxWidgets app"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("wxID_ANY"));
61
    GridSizer1 = new wxGridSizer(0, 3, 0, 0);
62
    Button1 = new wxButton(this, ID_BUTTON1, _("Open Port"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1"));
63
    GridSizer1->Add(Button1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
64
    TextCtrl1 = new wxTextCtrl(this, ID_TEXTCTRL1, _("Text"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
65
    GridSizer1->Add(TextCtrl1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
66
    StaticText1 = new wxStaticText(this, text1, _("Label"), wxDefaultPosition, wxDefaultSize, 0, _T("text1"));
67
    GridSizer1->Add(StaticText1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
68
    SetSizer(GridSizer1);
69
    GridSizer1->Fit(this);
70
    GridSizer1->SetSizeHints(this);
71
72
    Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&rs232_plotterDialog::OnButton1Click);
73
    //*)
74
}
75
76
rs232_plotterDialog::~rs232_plotterDialog()
77
{
78
    //(*Destroy(rs232_plotterDialog)
79
    //*)
80
}
81
82
void rs232_plotterDialog::OnQuit(wxCommandEvent& event)
83
{
84
    Close();
85
}
86
87
void rs232_plotterDialog::OnAbout(wxCommandEvent& event)
88
{
89
    wxString msg = wxbuildinfo(long_f);
90
    wxMessageBox(msg, _("Welcome to..."));
91
}
92
93
void rs232_plotterDialog::OnButton1Click(wxCommandEvent& event)
94
{
95
open_port();
96
}

und der code der den text seten soll ( ist n serieller port öffner)
1
#include <stdio.h>   /* Standard input/output definitions */
2
#include <string.h>  /* String function definitions */
3
#include <unistd.h>  /* UNIX standard function definitions */
4
#include <fcntl.h>   /* File control definitions */
5
#include <errno.h>   /* Error number definitions */
6
#include <termios.h> /* POSIX terminal control definitions */
7
8
9
 int open_port(void)
10
    {
11
      int fd; /* File descriptor for the port */
12
13
14
      fd = open("/dev/ttyS3", O_RDWR | O_NOCTTY | O_NDELAY);
15
      if (fd == -1)
16
      {
17
        
18
        
19
        ?????????????????????????
20
21
      }
22
      else
23
  fcntl(fd, F_SETFL, 0);
24
25
      return (fd);
26
    }

da wo ???????? steht weis ich nicht wie ich den text setzen kann 
(StaticText1 text1 )

Kann mir bitte jemand helfen, habe noch nicht so die Ahnung von C++

Danke schon mal..

von Rufus Τ. F. (rufus) Benutzerseite


Lesenswert?

Was sagt denn die Dokumentation zur Klasse wxStaticText? Was hat 
wxStaticText für Memberfunktionen?

von Mark B. (markbrandis)


Lesenswert?

Ohne jetzt wxWidgets tatsächlich zu kennen (muss ich mir demnächst 
definitiv mal anschauen, scheint ne interessante Alternative zu Qt zu 
sein):

1
StaticText1->SetLabel("Fehlermeldung");

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.