tstelgtk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
{$mode objfpc}
{$H+}
{$apptype gui}
 
{$ifdef win32}{$R fclel.res}
{$endif}
 
program tstelgtk;
 uses gdk,gtk,fpgtk,fpgtkext,classes,sysutils,eventlog;
 
{ ---------------------------------------------------------------------
    Main form class
  ---------------------------------------------------------------------} 
 
Type
  TMainForm = Class(TFPGtkWindow)
    FEventLog : TEventLog;    RGFrame : TFPgtkFrame;
    FHBox : TFPgtkHBox;
    RGBox,
    FVBox : TFPgtkVBox;
    BSend : TFPgtkButton;    RGMsgType : TFPgtkRadioButtonGroup;
    FLMsg : TFPGtkLabel;
    FMsg : TFPGtkEntry;
    Procedure BSendClicked(Sender : TFPgtkObject; Data : Pointer);
  Public    Constructor Create;
    Destructor Destroy; override;
    Procedure CreateWindow;
    Procedure SendEvent;
  end; 
ResourceString
  SCaption        = 'Free Pascal Event Log Demo';
  SEventlogDemo   = 'TestEventlogClass';
  SMessage        = 'Message text:';  SMsgType        = 'Message type:';
  SSend           = 'Send message';
  SInformation    = 'Information';
  SWarning        = 'Warning';
  SError          = 'Error';  SDebug          = 'Debug';
 
{ ---------------------------------------------------------------------
    Form Creation
  ---------------------------------------------------------------------} 
Constructor TMainForm.Create;
 
begin
  Inherited create (gtk_window_dialog);  Createwindow;
end;
 
Procedure TMainForm.CreateWindow;
   Procedure AddRG(C : String);
 
  Var
    RB : TFPgtkRadioButton;
   begin
    RB:= TFPgtkRadioButton.CreateWithLabel(RGmsgType,C);
    RGBox.Packstart(RB,False,False,2);
    rb.TheLabel.Justify:=GTK_JUSTIFY_LEFT;
  end; 
Var
  S : TStrings;
 
begin  BSend:=TFPGtkButton.CreateWithlabel(SSend);
  BSend.ConnectCLicked(@BSendClicked,Nil);
  RGFrame:=TFpgtkFrame.Create;
  RGFrame.Text:=SMsgType;
  RGBox:=TFPgtkVBox.Create;  RGFRame.Add(RGBox);
  S:=TstringList.Create;
  try
    With S do
      begin      Add(SInformation);
      Add(SWarning);
      Add(SError);
      Add(SDebug);
      end;     RGMsgType:=RadioButtonGroupCreateFromStrings(S,Nil);
     RGMsgType.PackInBox(RGBox,True,False,False,2);
  Finally
    S.Free;
  end;  FLMsg:=TfpGtkLabel.Create(SMessage);
  FMsg:=TfpGtkEntry.Create;
  FHBox:=TFPgtkHbox.Create;
  FHBox.PackStart(FLMsg,False,False,2);
  FHBox.PackStart(FMsg,True,True,2);  Title:=SCaption;
  FVBox:=TFPgtkVBox.Create;
  FVBox.Homogeneous:=False;
  FVBox.PackStart(FHBox,False,False,2);
  FVBox.PackStart(RGFrame,False,False,2);  FVBox.PackStart(BSend,true,false,2);
  Add(FVBox);
  FMsg.GrabFocus;
  FEventLog:=TEventlog.Create(Nil);
  FEventLog.Identification:=SEventLogDemo;  FEventLog.RegisterMessagefile('');
  FEventLog.Active:=True;
end;
 
Destructor TMainForm.Destroy; 
begin
  FEventLog.Active:=False;
  FEventLog.Free;
  Inherited;end;
 
{ ---------------------------------------------------------------------
    Callback events
  ---------------------------------------------------------------------} 
Procedure TMainForm.BSendClicked(Sender : TFPgtkObject; Data : Pointer);
 
begin
  SendEvent;end;
 
 
Procedure TMainForm.SendEvent;
 Var
  E : TEventType;
 
begin
  Case RGMsgType.ActiveButtonIndex of    0 : E:=etinfo;
    1 : E:=etWarning;
    2 : E:=etError;
    3 : E:=etDebug;
  end;  FEventLog.log(E,FMsg.Text);
end;
 
{ ---------------------------------------------------------------------
    Program.  ---------------------------------------------------------------------}
 
begin
  application := TFPgtkApplication.Create;
  application.MainWindow := TMainForm.Create;  application.Run;
  application.Free;
end.
¿Has encontrado algún error? ¿Tienes la solución? Dejame tu correción ;-)

Antes de comentar: Gran parte de los ejercicios propuestos no tienen librerías debido a que Wordpress las eliminó al verlas como etiquetas HTML. Si sabes/tienes/conoces las librerías que hacen falta, déjalo en los comentarios. Y lo mas importante: Todos los ejemplos fueron realizados por personas con únicamente conocimiento básico del lenguaje, no de programación.

Otro punto importante: Si vas a sugerir un segmento de código en algún lenguaje debes hacerlo así:

  • Si es lenguaje C <code lang="c">Código en C</code>
  • Si es lenguaje Pascal <code lang="pascal">Aquí dentro el código de Pascal</code>.

De esta manera el código coloreas el código.

Otro punto importante para muchos que crees que te he ignorado: Todos los comentarios los reviso y en su debido momento los apruebo, pero ojo con el con lo siguiente:

Me reservo el derecho de alterar, publicar o no los comentarios así como también cambiar mis condiciones en el momento que yo lo requiera.

¿Si estas de acuerdo? Adelante! que ya te he quitado bastante tiempo leyendo esta basura :)

Deja un comentario

Suscribirse a los comentarios.