Initial revision
[citadel.git] / wincit / readmsg.frm
1 VERSION 4.00
2 Begin VB.Form ReadMessages 
3    BorderStyle     =   0  'None
4    ClientHeight    =   6915
5    ClientLeft      =   1650
6    ClientTop       =   1980
7    ClientWidth     =   9600
8    ControlBox      =   0   'False
9    BeginProperty Font 
10       name            =   "MS Serif"
11       charset         =   0
12       weight          =   700
13       size            =   6.75
14       underline       =   0   'False
15       italic          =   0   'False
16       strikethrough   =   0   'False
17    EndProperty
18    ForeColor       =   &H80000008&
19    Height          =   7320
20    Left            =   1590
21    LinkTopic       =   "Form1"
22    MaxButton       =   0   'False
23    MDIChild        =   -1  'True
24    MinButton       =   0   'False
25    ScaleHeight     =   6915
26    ScaleWidth      =   9600
27    ShowInTaskbar   =   0   'False
28    Top             =   1635
29    Width           =   9720
30    Begin VB.CommandButton print_button 
31       Appearance      =   0  'Flat
32       BackColor       =   &H80000005&
33       Caption         =   "&Print"
34       BeginProperty Font 
35          name            =   "MS Sans Serif"
36          charset         =   0
37          weight          =   700
38          size            =   8.25
39          underline       =   0   'False
40          italic          =   0   'False
41          strikethrough   =   0   'False
42       EndProperty
43       Height          =   375
44       Left            =   2880
45       TabIndex        =   19
46       Top             =   6480
47       Width           =   735
48    End
49    Begin VB.CommandButton quote_button 
50       Appearance      =   0  'Flat
51       BackColor       =   &H80000005&
52       Caption         =   "&Quote"
53       BeginProperty Font 
54          name            =   "MS Sans Serif"
55          charset         =   0
56          weight          =   700
57          size            =   8.25
58          underline       =   0   'False
59          italic          =   0   'False
60          strikethrough   =   0   'False
61       EndProperty
62       Height          =   375
63       Left            =   3720
64       TabIndex        =   18
65       Top             =   6480
66       Width           =   735
67    End
68    Begin VB.CommandButton Move_Button 
69       Appearance      =   0  'Flat
70       BackColor       =   &H80000005&
71       Caption         =   "&Move"
72       Enabled         =   0   'False
73       BeginProperty Font 
74          name            =   "MS Sans Serif"
75          charset         =   0
76          weight          =   700
77          size            =   8.25
78          underline       =   0   'False
79          italic          =   0   'False
80          strikethrough   =   0   'False
81       EndProperty
82       Height          =   375
83       Left            =   1200
84       TabIndex        =   17
85       Top             =   6480
86       Width           =   735
87    End
88    Begin VB.CommandButton Delete_Button 
89       Appearance      =   0  'Flat
90       BackColor       =   &H80000005&
91       Caption         =   "&Delete"
92       Enabled         =   0   'False
93       BeginProperty Font 
94          name            =   "MS Sans Serif"
95          charset         =   0
96          weight          =   700
97          size            =   8.25
98          underline       =   0   'False
99          italic          =   0   'False
100          strikethrough   =   0   'False
101       EndProperty
102       Height          =   375
103       Left            =   2040
104       TabIndex        =   16
105       Top             =   6480
106       Width           =   735
107    End
108    Begin Threed.SSPanel msg_num 
109       Height          =   375
110       Left            =   120
111       TabIndex        =   15
112       Top             =   6480
113       Width           =   975
114       _Version        =   65536
115       _ExtentX        =   1720
116       _ExtentY        =   661
117       _StockProps     =   15
118       BackColor       =   12632256
119       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
120          name            =   "MS Sans Serif"
121          charset         =   0
122          weight          =   400
123          size            =   8.25
124          underline       =   0   'False
125          italic          =   0   'False
126          strikethrough   =   0   'False
127       EndProperty
128       BevelWidth      =   3
129       BorderWidth     =   4
130       BevelOuter      =   1
131    End
132    Begin Threed.SSPanel message_panel 
133       Height          =   5535
134       Left            =   0
135       TabIndex        =   14
136       Top             =   840
137       Width           =   10455
138       _Version        =   65536
139       _ExtentX        =   18441
140       _ExtentY        =   9763
141       _StockProps     =   15
142       BackColor       =   12632256
143       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
144          name            =   "MS Sans Serif"
145          charset         =   0
146          weight          =   700
147          size            =   8.25
148          underline       =   0   'False
149          italic          =   0   'False
150          strikethrough   =   0   'False
151       EndProperty
152       BevelWidth      =   9
153       BorderWidth     =   0
154       BevelOuter      =   1
155       Begin VB.TextBox message_text 
156          Appearance      =   0  'Flat
157          BackColor       =   &H00C0C0C0&
158          BorderStyle     =   0  'None
159          BeginProperty Font 
160             name            =   "Courier New"
161             charset         =   0
162             weight          =   700
163             size            =   12
164             underline       =   0   'False
165             italic          =   0   'False
166             strikethrough   =   0   'False
167          EndProperty
168          Height          =   5295
169          Left            =   120
170          Locked          =   -1  'True
171          MultiLine       =   -1  'True
172          ScrollBars      =   2  'Vertical
173          TabIndex        =   3
174          Top             =   120
175          Width           =   10215
176       End
177    End
178    Begin VB.CommandButton first_button 
179       Appearance      =   0  'Flat
180       BackColor       =   &H80000005&
181       Caption         =   "<<- &First"
182       BeginProperty Font 
183          name            =   "MS Sans Serif"
184          charset         =   0
185          weight          =   700
186          size            =   8.25
187          underline       =   0   'False
188          italic          =   0   'False
189          strikethrough   =   0   'False
190       EndProperty
191       Height          =   375
192       Left            =   4560
193       TabIndex        =   13
194       Top             =   6480
195       Width           =   855
196    End
197    Begin VB.CommandButton last_button 
198       Appearance      =   0  'Flat
199       BackColor       =   &H80000005&
200       Caption         =   "&Last ->>"
201       BeginProperty Font 
202          name            =   "MS Sans Serif"
203          charset         =   0
204          weight          =   700
205          size            =   8.25
206          underline       =   0   'False
207          italic          =   0   'False
208          strikethrough   =   0   'False
209       EndProperty
210       Height          =   375
211       Left            =   7680
212       TabIndex        =   12
213       Top             =   6480
214       Width           =   855
215    End
216    Begin Threed.SSPanel room_panel 
217       Height          =   375
218       Left            =   6000
219       TabIndex        =   11
220       Top             =   420
221       Width           =   3615
222       _Version        =   65536
223       _ExtentX        =   6376
224       _ExtentY        =   661
225       _StockProps     =   15
226       BackColor       =   12632256
227       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
228          name            =   "MS Sans Serif"
229          charset         =   0
230          weight          =   400
231          size            =   8.25
232          underline       =   0   'False
233          italic          =   0   'False
234          strikethrough   =   0   'False
235       EndProperty
236       BevelWidth      =   3
237       BorderWidth     =   4
238       BevelOuter      =   1
239    End
240    Begin Threed.SSPanel date_panel 
241       Height          =   375
242       Left            =   6000
243       TabIndex        =   8
244       Top             =   15
245       Width           =   3615
246       _Version        =   65536
247       _ExtentX        =   6376
248       _ExtentY        =   661
249       _StockProps     =   15
250       BackColor       =   12632256
251       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
252          name            =   "MS Sans Serif"
253          charset         =   0
254          weight          =   400
255          size            =   8.25
256          underline       =   0   'False
257          italic          =   0   'False
258          strikethrough   =   0   'False
259       EndProperty
260       BevelWidth      =   3
261       BorderWidth     =   4
262       BevelOuter      =   1
263    End
264    Begin Threed.SSPanel to_panel 
265       Height          =   375
266       Left            =   480
267       TabIndex        =   7
268       Top             =   420
269       Width           =   4935
270       _Version        =   65536
271       _ExtentX        =   8705
272       _ExtentY        =   661
273       _StockProps     =   15
274       BackColor       =   12632256
275       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
276          name            =   "MS Sans Serif"
277          charset         =   0
278          weight          =   400
279          size            =   8.25
280          underline       =   0   'False
281          italic          =   0   'False
282          strikethrough   =   0   'False
283       EndProperty
284       BevelWidth      =   3
285       BorderWidth     =   4
286       BevelOuter      =   1
287    End
288    Begin VB.CommandButton back_button 
289       Appearance      =   0  'Flat
290       BackColor       =   &H80000005&
291       Caption         =   "<- &Back"
292       BeginProperty Font 
293          name            =   "MS Sans Serif"
294          charset         =   0
295          weight          =   700
296          size            =   8.25
297          underline       =   0   'False
298          italic          =   0   'False
299          strikethrough   =   0   'False
300       EndProperty
301       Height          =   375
302       Left            =   5520
303       TabIndex        =   2
304       Top             =   6480
305       Width           =   975
306    End
307    Begin VB.CommandButton next_button 
308       Appearance      =   0  'Flat
309       BackColor       =   &H80000005&
310       Caption         =   "&Next  ->"
311       BeginProperty Font 
312          name            =   "MS Sans Serif"
313          charset         =   0
314          weight          =   700
315          size            =   8.25
316          underline       =   0   'False
317          italic          =   0   'False
318          strikethrough   =   0   'False
319       EndProperty
320       Height          =   375
321       Left            =   6600
322       TabIndex        =   1
323       Top             =   6480
324       Width           =   975
325    End
326    Begin VB.CommandButton stop_button 
327       Appearance      =   0  'Flat
328       BackColor       =   &H80000005&
329       Caption         =   "&Stop"
330       BeginProperty Font 
331          name            =   "MS Sans Serif"
332          charset         =   0
333          weight          =   700
334          size            =   8.25
335          underline       =   0   'False
336          italic          =   0   'False
337          strikethrough   =   0   'False
338       EndProperty
339       Height          =   375
340       Left            =   8640
341       TabIndex        =   0
342       Top             =   6480
343       Width           =   855
344    End
345    Begin Threed.SSPanel from_panel 
346       Height          =   375
347       Left            =   480
348       TabIndex        =   4
349       Top             =   15
350       Width           =   4935
351       _Version        =   65536
352       _ExtentX        =   8705
353       _ExtentY        =   661
354       _StockProps     =   15
355       BackColor       =   12632256
356       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
357          name            =   "MS Sans Serif"
358          charset         =   0
359          weight          =   400
360          size            =   8.25
361          underline       =   0   'False
362          italic          =   0   'False
363          strikethrough   =   0   'False
364       EndProperty
365       BevelWidth      =   3
366       BorderWidth     =   4
367       BevelOuter      =   1
368    End
369    Begin VB.Label Label5 
370       Alignment       =   1  'Right Justify
371       Appearance      =   0  'Flat
372       BackColor       =   &H80000005&
373       BackStyle       =   0  'Transparent
374       Caption         =   "Room:"
375       BeginProperty Font 
376          name            =   "MS Sans Serif"
377          charset         =   0
378          weight          =   700
379          size            =   8.25
380          underline       =   0   'False
381          italic          =   0   'False
382          strikethrough   =   0   'False
383       EndProperty
384       ForeColor       =   &H80000008&
385       Height          =   255
386       Left            =   5400
387       TabIndex        =   10
388       Top             =   480
389       Width           =   615
390    End
391    Begin VB.Label Label4 
392       Alignment       =   1  'Right Justify
393       Appearance      =   0  'Flat
394       BackColor       =   &H80000005&
395       BackStyle       =   0  'Transparent
396       Caption         =   "Date:"
397       BeginProperty Font 
398          name            =   "MS Sans Serif"
399          charset         =   0
400          weight          =   700
401          size            =   8.25
402          underline       =   0   'False
403          italic          =   0   'False
404          strikethrough   =   0   'False
405       EndProperty
406       ForeColor       =   &H80000008&
407       Height          =   255
408       Left            =   5520
409       TabIndex        =   9
410       Top             =   120
411       Width           =   495
412    End
413    Begin VB.Label Label3 
414       Alignment       =   1  'Right Justify
415       Appearance      =   0  'Flat
416       BackColor       =   &H80000005&
417       BackStyle       =   0  'Transparent
418       Caption         =   "To:"
419       BeginProperty Font 
420          name            =   "MS Sans Serif"
421          charset         =   0
422          weight          =   700
423          size            =   8.25
424          underline       =   0   'False
425          italic          =   0   'False
426          strikethrough   =   0   'False
427       EndProperty
428       ForeColor       =   &H80000008&
429       Height          =   255
430       Left            =   0
431       TabIndex        =   6
432       Top             =   480
433       Width           =   495
434    End
435    Begin VB.Label Label2 
436       Alignment       =   1  'Right Justify
437       Appearance      =   0  'Flat
438       BackColor       =   &H80000005&
439       BackStyle       =   0  'Transparent
440       Caption         =   "From:"
441       BeginProperty Font 
442          name            =   "MS Sans Serif"
443          charset         =   0
444          weight          =   700
445          size            =   8.25
446          underline       =   0   'False
447          italic          =   0   'False
448          strikethrough   =   0   'False
449       EndProperty
450       ForeColor       =   &H80000008&
451       Height          =   255
452       Left            =   0
453       TabIndex        =   5
454       Top             =   120
455       Width           =   495
456    End
457 End
458 Attribute VB_Name = "ReadMessages"
459 Attribute VB_Creatable = False
460 Attribute VB_Exposed = False
461 Dim curr_msg%
462 Dim varifontname
463 Dim varifontsize
464 Dim fixedfontname
465
466 Private Sub back_button_Click()
467     
468     curr_msg% = curr_msg% - 1
469     Call display_msg
470
471 End Sub
472
473 Private Sub check_quote_button()
474     If message_text.SelLength > 0 Then
475         Quote_Button.Enabled = True
476     Else
477         Quote_Button.Enabled = False
478         End If
479 End Sub
480
481 Private Sub Delete_Button_Click()
482     If begin_trans() = False Then GoTo skipdelete
483     serv_puts ("DELE " + Str$(msg_array&(curr_msg%)))
484     a$ = serv_gets()
485     Call end_trans
486
487     If (Left$(a$, 1) = "2") Then
488         For b% = curr_msg% To max_msgs% - 2
489             msg_array&(b%) = msg_array(b% + 1)
490             Next b%
491         max_msgs% = max_msgs% - 1
492         If max_msgs% = 0 Then Unload ReadMessages
493         If curr_msg% >= (max_msgs% - 1) Then curr_msg% = curr_msg% - 1
494         Call display_msg
495     Else
496         MsgBox Right$(a$, Len(a$) - 4), 16, "Error"
497         End If
498
499 skipdelete:
500 End Sub
501
502 Private Sub display_msg()
503
504     If curr_msg% = 0 Then
505         back_button.Enabled = False
506         first_button.Enabled = False
507     Else
508         back_button.Enabled = True
509         first_button.Enabled = True
510         End If
511
512     If curr_msg% = (max_msgs% - 1) Then
513         next_button.Enabled = False
514         last_button.Enabled = False
515     Else
516         next_button.Enabled = True
517         last_button.Enabled = True
518         End If
519     
520     msg_num.Caption = Str$(curr_msg% + 1) + " of " + Str$(max_msgs%)
521     If begin_trans() = False Then GoTo skipitall
522     LastMessageRead& = msg_array&(curr_msg%)
523     serv_puts ("MSG0 " + Str$(msg_array&(curr_msg%)))
524     a$ = serv_gets()
525     format_type% = 0
526     b$ = ""
527     source_node$ = ""
528     source_hnode$ = ""
529     intext% = 0
530     from_panel.Caption = ""
531     to_panel.Caption = ""
532     room_panel.Caption = ""
533     date_panel.Caption = ""
534     
535     If Left$(a$, 1) = "1" Then
536         message_text.Text = a$
537         Do
538             a$ = serv_gets()
539             If a$ = "000" Then Exit Do
540             If intext% = 0 Then
541                 If Left$(a$, 5) = "from=" Then from_panel.Caption = Right$(a$, Len(a$) - 5)
542                 If Left$(a$, 5) = "rcpt=" Then to_panel.Caption = Right$(a$, Len(a$) - 5)
543                 If Left$(a$, 5) = "room=" Then room_panel.Caption = Right$(a$, Len(a$) - 5)
544                 If Left$(a$, 5) = "time=" Then date_panel.Caption = strtime(Val(Right$(a$, Len(a$) - 5)))
545                 If Left$(a$, 5) = "type=" Then format_type% = Val(Right$(a$, Len(a$) - 5))
546                 If Left$(a$, 5) = "node=" Then source_node$ = Right$(a$, Len(a$) - 5)
547                 If Left$(a$, 5) = "hnod=" Then source_hnode$ = Right$(a$, Len(a$) - 5)
548                 If Left$(a$, 4) = "text" Then
549                     intext% = 1
550                     If format_type% = 1 Then
551                         message_text.FontName = fixedfontname
552                         message_text.FontSize = Int(message_text.Width / 1000)
553                         message_text.FontBold = False
554                         message_text.FontItalic = False
555                     Else
556                         message_text.FontName = varifontname
557                         message_text.FontSize = varifontsize
558                         message_text.FontBold = False
559                         message_text.FontItalic = False
560                         End If
561                     End If
562             Else
563                 b$ = b$ + a$ + Chr$(13) + Chr$(10)
564                 End If
565             
566             Loop
567         If format_type% = 0 Then
568             message_text.Text = Cit_Format(b$)
569         Else
570             message_text.Text = b$
571             End If
572         If source_node$ <> "" Then from_panel.Caption = from_panel.Caption + " @ " + source_node$
573         If source_hnode$ <> "" Then from_panel.Caption = from_panel.Caption + " (" + source_hnode$ + ")"
574     Else
575         message_text.Text = a$
576         End If
577     
578     Call end_trans
579 skipitall:
580     Call message_text_Click
581
582 End Sub
583
584 Private Sub first_button_Click()
585     curr_msg% = 0
586     Call display_msg
587 End Sub
588
589 Private Sub Form_Load()
590
591     varifontname = GetPrivateProfileVBString("Preferences", "VariFontName", "MS Sans Serif", "WINCIT.INI")
592     varifontsize = GetPrivateProfileInt("Preferences", "VariFontSize", 10, "WINCIT.INI")
593
594     fixedfontname = GetPrivateProfileVBString("Preferences", "FixedFontName", "Courier New", "WINCIT.INI")
595     
596     curr_msg% = 0
597
598     move_button.Enabled = IsRoomAide%
599     delete_button.Enabled = IsRoomAide%
600
601     Show
602     DoEvents
603     Call display_msg
604
605 End Sub
606
607 Private Sub Form_Resize()
608     
609     ReadMessages.Left = 0
610     ReadMessages.Top = 0
611     ReadMessages.Width = MainWin.Width
612     ReadMessages.Height = MainWin.Height - 400
613     
614     stop_button.Top = Abs(ReadMessages.Height - 520)
615     last_button.Top = Abs(ReadMessages.Height - 520)
616     next_button.Top = Abs(ReadMessages.Height - 520)
617     back_button.Top = Abs(ReadMessages.Height - 520)
618     first_button.Top = Abs(ReadMessages.Height - 520)
619     move_button.Top = Abs(ReadMessages.Height - 520)
620     delete_button.Top = Abs(ReadMessages.Height - 520)
621     Quote_Button.Top = Abs(ReadMessages.Height - 520)
622     print_button.Top = Abs(ReadMessages.Height - 520)
623     msg_num.Top = Abs(ReadMessages.Height - 520)
624     message_text.Width = Abs(ReadMessages.Width - 336)
625     message_text.Height = Abs(ReadMessages.Height - 1664)
626     message_panel.Height = Abs(ReadMessages.Height - 1424)
627     message_panel.Width = Abs(ReadMessages.Width - 100)
628 End Sub
629
630 Private Sub last_button_Click()
631     curr_msg% = max_msgs% - 1
632     Call display_msg
633 End Sub
634
635 Private Sub message_text_Change()
636     Call check_quote_button
637 End Sub
638
639 Private Sub message_text_Click()
640     Call check_quote_button
641 End Sub
642
643 Private Sub next_button_Click()
644
645     curr_msg% = curr_msg% + 1
646     Call display_msg
647
648 End Sub
649
650 Private Sub print_button_Click()
651
652     a$ = message_text.Text
653     message_text.Text = quotify(a$)
654
655
656
657 End Sub
658
659 Private Sub quote_button_Click()
660
661     a$ = message_text.SelText
662     Clipboard.SetText quotify(a$)
663
664 End Sub
665
666 Private Function quotify(instring As String) As String
667
668 a$ = instring
669 b$ = ""
670
671 Do
672     
673 CHKLN:
674     If Len(a$) = 0 Then GoTo CHKEND
675
676     If Len(a$) < 72 Then
677         b$ = b$ + " >" + a$ + Chr$(13) + Chr$(10)
678         a$ = ""
679         End If
680
681     c = InStr(a$, Chr$(13) + Chr$(10))
682     If (c < 72) And (c <> 0) Then
683         b$ = b$ + " >" + Left$(a$, c - 1) + Chr$(13) + Chr$(10)
684         a$ = Right$(a$, (Len(a$) - c) - 1)
685         End If
686
687     c = InStr(a$, " ")
688     If (c > 72) Or (c = 0) Then
689         b$ = b$ + " >" + Left$(a$, 72) + Chr$(13) + Chr$(10)
690         If Len(a$) > 0 Then a$ = Right$(a$, Len(a$) - 72)
691         GoTo CHKLN
692         End If
693
694     d = 0
695     c = 1
696     Do
697         e = InStr(c, a$, " ")
698         If e > 0 Then
699             If c < 72 Then d = e
700             c = e + 1
701             End If
702         
703         Loop Until e = 0 Or c >= 72
704 ELN:
705
706     If d <> 0 Then
707         b$ = b$ + " >" + Left$(a$, d) + Chr$(13) + Chr$(10)
708         a$ = Right$(a$, (Len(a$) - d) + 1)
709         GoTo CHKLN
710         End If
711
712     Loop Until Len(a$) = 0
713 CHKEND:
714     quotify = b$
715
716 End Function
717
718 Private Sub stop_button_Click()
719
720     Unload ReadMessages
721     Load RoomPrompt
722
723 End Sub
724