home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / lora299s.zip / READER.CPP < prev    next >
C/C++ Source or Header  |  1998-05-12  |  100KB  |  2,884 lines

  1.  
  2. // LoraBBS Version 2.99 Free Edition
  3. // Copyright (C) 1987-98 Marco Maccaferri
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation; either version 2 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19. #include "_ldefs.h"
  20. #include "lorawin.h"
  21. #include "msgbase.h"
  22. #include "uulib.h"
  23.  
  24. class CMsgHeaderDlg : public CDialog
  25. {
  26. public:
  27.    CMsgHeaderDlg (HWND p_hWnd);
  28.  
  29.    CHAR   From[48], To[48];
  30.    CHAR   Subject[64];
  31.    CHAR   FromAddress[64];
  32.    CHAR   ToAddress[64];
  33.    UCHAR  Crash, Direct, FileAttach, FileRequest, Hold, Immediate;
  34.    UCHAR  Intransit, KillSent, Local, Private, ReceiptRequest, Received;
  35.    UCHAR  Sent;
  36.  
  37.    USHORT OnInitDialog (VOID);
  38.    VOID   OnOK (VOID);
  39. };
  40.  
  41. #if defined(__OS2__)
  42. HAB  hab;
  43. HWND hwndReaderFrame, hwndReaderClient;
  44. FILEDLG fild;
  45. #elif defined(__NT__)
  46. HINSTANCE hinst;
  47. HWND hwndReaderClient;
  48. #endif
  49. HACCEL hAccel, hAccReader, hAccEditor;
  50.  
  51. #define STATIC_HEIGHT      18
  52.  
  53. #define ID_SUBJECT         1108
  54.  
  55. PSZ Months[] = {
  56.    "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  57.    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
  58. };
  59.  
  60. USHORT DoRescan = TRUE, Status = 0, ShowKludges = FALSE;
  61. CHAR   AreaKey[16];
  62. ULONG  Number;
  63. struct dosdate_t d_date;
  64. struct dostime_t d_time;
  65. class  TMsgBase *Msg = NULL;
  66. class  TScan *Scan = NULL;
  67. class  TConfig *Cfg = NULL;
  68. class  TPMLog *Log = NULL;
  69. class  TModem *Modem = NULL;
  70. class  CMsgHeaderDlg *HeaderDlg = NULL;
  71.  
  72. // ----------------------------------------------------------------------
  73.  
  74. typedef struct {
  75.    CHAR   Key[16];
  76.    CHAR   Description[64];
  77.    ULONG  Messages;
  78.    ULONG  New;
  79.    CHAR   Tag[64];
  80.    CHAR   Address[64];
  81. } SCANDATA;
  82.  
  83. class TScan
  84. {
  85. public:
  86.    TScan (void);
  87.    ~TScan (void);
  88.  
  89.    CHAR   Key[16];
  90.    CHAR   Description[64];
  91.    ULONG  Messages;
  92.    ULONG  New;
  93.    CHAR   Tag[64];
  94.    CHAR   Address[64];
  95.  
  96.    VOID   Add (VOID);
  97.    VOID   Clear (VOID);
  98.    USHORT First (VOID);
  99.    USHORT Next (VOID);
  100.    USHORT Read (PSZ key);
  101.    VOID   Update (VOID);
  102.  
  103. private:
  104.    class  TCollection Data;
  105. };
  106.  
  107. TScan::TScan (void)
  108. {
  109.    Data.Clear ();
  110. }
  111.  
  112. TScan::~TScan (void)
  113. {
  114.    Data.Clear ();
  115. }
  116.  
  117. VOID TScan::Add (VOID)
  118. {
  119.    SCANDATA sd;
  120.  
  121.    strcpy (sd.Key, Key);
  122.    strcpy (sd.Description, Description);
  123.    sd.Messages = Messages;
  124.    sd.New = New;
  125.    strcpy (sd.Tag, Tag);
  126.    strcpy (sd.Address, Address);
  127.  
  128.    Data.Add (&sd, sizeof (SCANDATA));
  129. }
  130.  
  131. VOID TScan::Clear (VOID)
  132. {
  133.    Data.Clear ();
  134. }
  135.  
  136. USHORT TScan::First (VOID)
  137. {
  138.    USHORT RetVal = FALSE;
  139.    SCANDATA *sd;
  140.  
  141.    if ((sd = (SCANDATA *)Data.First ()) != NULL) {
  142.       strcpy (Key, sd->Key);
  143.       strcpy (Description, sd->Description);
  144.       Messages = sd->Messages;
  145.       New = sd->New;
  146.       strcpy (Tag, sd->Tag);
  147.       strcpy (Address, sd->Address);
  148.       RetVal = TRUE;
  149.    }
  150.  
  151.    return (RetVal);
  152. }
  153.  
  154. USHORT TScan::Next (VOID)
  155. {
  156.    USHORT RetVal = FALSE;
  157.    SCANDATA *sd;
  158.  
  159.    if ((sd = (SCANDATA *)Data.Next ()) != NULL) {
  160.       strcpy (Key, sd->Key);
  161.       strcpy (Description, sd->Description);
  162.       Messages = sd->Messages;
  163.       New = sd->New;
  164.       strcpy (Tag, sd->Tag);
  165.       strcpy (Address, sd->Address);
  166.       RetVal = TRUE;
  167.    }
  168.  
  169.    return (RetVal);
  170. }
  171.  
  172. USHORT TScan::Read (PSZ key)
  173. {
  174.    USHORT RetVal = FALSE;
  175.    SCANDATA *sd;
  176.  
  177.    if ((sd = (SCANDATA *)Data.First ()) != NULL)
  178.       do {
  179.          if (!stricmp (sd->Key, key)) {
  180.             strcpy (Key, sd->Key);
  181.             strcpy (Description, sd->Description);
  182.             Messages = sd->Messages;
  183.             New = sd->New;
  184.             strcpy (Tag, sd->Tag);
  185.             strcpy (Address, sd->Address);
  186.             RetVal = TRUE;
  187.             break;
  188.          }
  189.       } while ((sd = (SCANDATA *)Data.Next ()) != NULL);
  190.  
  191.    return (RetVal);
  192. }
  193.  
  194. VOID TScan::Update (VOID)
  195. {
  196.    SCANDATA *sd;
  197.  
  198.    if ((sd = (SCANDATA *)Data.Value ()) != NULL) {
  199.       sd->Messages = Messages;
  200.       sd->New = New;
  201.    }
  202. }
  203.  
  204. // ----------------------------------------------------------------------
  205.  
  206. class CScanDlg : public CDialog
  207. {
  208. public:
  209.    CScanDlg (HWND p_hWnd);
  210.    ~CScanDlg (void);
  211.  
  212.    VOID   OnCancel (VOID);
  213.    USHORT OnInitDialog (VOID);
  214.    VOID   OnUser (VOID);
  215.  
  216. private:
  217.    USHORT IsUser;
  218.    class  TMsgData *Data;
  219.    class  TMsgBase *Msg;
  220.    class  TUser *User;
  221.    DECLARE_MESSAGE_MAP ()
  222. };
  223.  
  224. BEGIN_MESSAGE_MAP (CScanDlg, CDialog)
  225.    ON_MESSAGE (WM_USER, OnUser)
  226. END_MESSAGE_MAP ()
  227.  
  228. CScanDlg::CScanDlg (HWND p_hWnd) : CDialog ("203", p_hWnd)
  229. {
  230.    IsUser = FALSE;
  231.    Data = NULL;
  232.    User = NULL;
  233. }
  234.  
  235. CScanDlg::~CScanDlg (void)
  236. {
  237.    if (Data != NULL)
  238.       delete Data;
  239.    if (User != NULL)
  240.       delete User;
  241. }
  242.  
  243. USHORT CScanDlg::OnInitDialog (VOID)
  244. {
  245.    ULONG LastRead;
  246.  
  247.    Center ();
  248.  
  249.    if (Scan != NULL)
  250.       Scan->Clear ();
  251.  
  252.    if ((User = new TUser (Cfg->UserFile)) != NULL) {
  253.      if (User->GetData (Cfg->SysopName) == TRUE)
  254.         IsUser = TRUE;
  255.    }
  256.  
  257.    Msg = NULL;
  258.    switch (Cfg->NetMailStorage) {
  259.       case ST_JAM:
  260.          Msg = new JAM (Cfg->NetMailPath);
  261.          break;
  262.       case ST_SQUISH:
  263.          Msg = new SQUISH (Cfg->NetMailPath);
  264.          break;
  265.       case ST_FIDO:
  266.          Msg = new FIDOSDM (Cfg->NetMailPath);
  267.          break;
  268.       case ST_ADEPT:
  269.          Msg = new ADEPT (Cfg->NetMailPath);
  270.          break;
  271.       case ST_HUDSON:
  272.          Msg = new HUDSON (Cfg->HudsonPath, (UCHAR)Cfg->NetMailBoard);
  273.          break;
  274.    }
  275.    if (Msg != NULL) {
  276.       LastRead = 0L;
  277.       if (IsUser == TRUE && User != NULL) {
  278.          if (User->MsgTag->Read ("NetMail") == TRUE)
  279.             LastRead = User->MsgTag->LastRead;
  280.       }
  281.  
  282.       if (Scan != NULL) {
  283.          strcpy (Scan->Key, "NetMail");
  284.          strcpy (Scan->Description, "FidoNet E-Mail");
  285.          Scan->Messages = Msg->Number ();
  286.          Scan->New = Msg->Number () - Msg->UidToMsgn (LastRead);
  287.          Scan->Tag[0] = '\0';
  288.          Scan->Address[0] = '\0';
  289.          Scan->Add ();
  290.       }
  291.  
  292.       delete Msg;
  293.    }
  294.  
  295. #if !defined(__POINT__)
  296.    Msg = NULL;
  297.    switch (Cfg->MailStorage) {
  298.       case ST_JAM:
  299.          Msg = new JAM (Cfg->MailPath);
  300.          break;
  301.       case ST_SQUISH:
  302.          Msg = new SQUISH (Cfg->MailPath);
  303.          break;
  304.       case ST_FIDO:
  305.          Msg = new FIDOSDM (Cfg->MailPath);
  306.          break;
  307.       case ST_ADEPT:
  308.          Msg = new ADEPT (Cfg->MailPath);
  309.          break;
  310.       case ST_HUDSON:
  311.          Msg = new HUDSON (Cfg->HudsonPath, (UCHAR)Cfg->MailBoard);
  312.          break;
  313.    }
  314.    if (Msg != NULL) {
  315.       LastRead = 0L;
  316.       if (IsUser == TRUE && User != NULL) {
  317.          if (User->MsgTag->Read ("EMail") == TRUE)
  318.             LastRead = User->MsgTag->LastRead;
  319.       }
  320.  
  321.       if (Scan != NULL) {
  322.          strcpy (Scan->Key, "EMail");
  323.          strcpy (Scan->Description, "Personal E-Mail");
  324.          Scan->Messages = Msg->Number ();
  325.          Scan->New = Msg->Number () - Msg->UidToMsgn (LastRead);
  326.          Scan->Tag[0] = '\0';
  327.          Scan->Address[0] = '\0';
  328.          Scan->Add ();
  329.       }
  330.  
  331.       delete Msg;
  332.    }
  333. #endif
  334.  
  335.    Msg = NULL;
  336.    switch (Cfg->BadStorage) {
  337.       case ST_JAM:
  338.          Msg = new JAM (Cfg->BadPath);
  339.          break;
  340.       case ST_SQUISH:
  341.          Msg = new SQUISH (Cfg->BadPath);
  342.          break;
  343.       case ST_FIDO:
  344.          Msg = new FIDOSDM (Cfg->BadPath);
  345.          break;
  346.       case ST_ADEPT:
  347.          Msg = new ADEPT (Cfg->BadPath);
  348.          break;
  349.       case ST_HUDSON:
  350.          Msg = new HUDSON (Cfg->HudsonPath, (UCHAR)Cfg->BadBoard);
  351.          break;
  352.    }
  353.    if (Msg != NULL) {
  354.       LastRead = 0L;
  355.       if (IsUser == TRUE && User != NULL) {
  356.          if (User->MsgTag->Read ("BadMsgs") == TRUE)
  357.             LastRead = User->MsgTag->LastRead;
  358.       }
  359.  
  360.       if (Scan != NULL) {
  361.          strcpy (Scan->Key, "BadMsgs");
  362.          strcpy (Scan->Description, "Bad Messages");
  363.          Scan->Messages = Msg->Number ();
  364.          Scan->New = Msg->Number () - Msg->UidToMsgn (LastRead);
  365.          Scan->Tag[0] = '\0';
  366.          Scan->Address[0] = '\0';
  367.          Scan->Add ();
  368.       }
  369.  
  370.       delete Msg;
  371.    }
  372.  
  373.    Msg = NULL;
  374.    switch (Cfg->DupeStorage) {
  375.       case ST_JAM:
  376.          Msg = new JAM (Cfg->DupePath);
  377.          break;
  378.       case ST_SQUISH:
  379.          Msg = new SQUISH (Cfg->DupePath);
  380.          break;
  381.       case ST_FIDO:
  382.          Msg = new FIDOSDM (Cfg->DupePath);
  383.          break;
  384.       case ST_ADEPT:
  385.          Msg = new ADEPT (Cfg->DupePath);
  386.          break;
  387.       case ST_HUDSON:
  388.          Msg = new HUDSON (Cfg->HudsonPath, (UCHAR)Cfg->DupeBoard);
  389.          break;
  390.    }
  391.    if (Msg != NULL) {
  392.       LastRead = 0L;
  393.       if (IsUser == TRUE && User != NULL) {
  394.          if (User->MsgTag->Read ("Dupes") == TRUE)
  395.             LastRead = User->MsgTag->LastRead;
  396.       }
  397.  
  398.       if (Scan != NULL) {
  399.          strcpy (Scan->Key, "Dupes");
  400.          strcpy (Scan->Description, "Duplicate Messages");
  401.          Scan->Messages = Msg->Number ();
  402.          Scan->New = Msg->Number () - Msg->UidToMsgn (LastRead);
  403.          Scan->Tag[0] = '\0';
  404.          Scan->Address[0] = '\0';
  405.          Scan->Add ();
  406.       }
  407.  
  408.       delete Msg;
  409.    }
  410.  
  411.    if ((Data = new TMsgData (Cfg->SystemPath)) != NULL) {
  412.       if (Data->First () == TRUE)
  413. #if defined(__OS2__)
  414.          WinPostMsg (m_hWnd, WM_USER, 0L, 0L);
  415. #elif defined(__NT__)
  416.          PostMessage (m_hWnd, WM_USER, 0, 0L);
  417. #endif
  418.       else
  419.          EndDialog (TRUE);
  420.    }
  421.  
  422.    return (TRUE);
  423. }
  424.  
  425. VOID CScanDlg::OnUser (VOID)
  426. {
  427.    ULONG LastRead;
  428.  
  429.    SetDlgItemText (101, Data->Display);
  430.  
  431.    Msg = NULL;
  432.    switch (Data->Storage) {
  433.       case ST_JAM:
  434.          Msg = new JAM (Data->Path);
  435.          break;
  436.       case ST_SQUISH:
  437.          Msg = new SQUISH (Data->Path);
  438.          break;
  439.       case ST_FIDO:
  440.          Msg = new FIDOSDM (Data->Path);
  441.          break;
  442.       case ST_ADEPT:
  443.          Msg = new ADEPT (Data->Path);
  444.          break;
  445.       case ST_HUDSON:
  446.          Msg = new HUDSON (Data->Path, (UCHAR)Data->Board);
  447.          break;
  448.    }
  449.  
  450.    if (Msg != NULL) {
  451.       LastRead = 0L;
  452.       if (IsUser == TRUE && User != NULL) {
  453.          if (User->MsgTag->Read (Data->Key) == TRUE)
  454.             LastRead = User->MsgTag->LastRead;
  455.       }
  456.  
  457.       if (Scan != NULL) {
  458.          strcpy (Scan->Key, Data->Key);
  459.          strcpy (Scan->Description, Data->Display);
  460.          Scan->Messages = Msg->Number ();
  461.          Scan->New = Msg->Number () - Msg->UidToMsgn (LastRead);
  462.          strcpy (Scan->Tag, Data->EchoTag);
  463.          strcpy (Scan->Address, Data->Address);
  464.          Scan->Add ();
  465.       }
  466.  
  467.       delete Msg;
  468.    }
  469.  
  470.    if (Data != NULL) {
  471.       if (Data->Next () == TRUE) {
  472. #if defined(__OS2__)
  473.          WinPostMsg (m_hWnd, WM_USER, 0L, 0L);
  474. #elif defined(__NT__)
  475.          PostMessage (m_hWnd, WM_USER, 0, 0L);
  476. #endif
  477.       }
  478.       else
  479.          EndDialog (TRUE);
  480.    }
  481. }
  482.  
  483. VOID CScanDlg::OnCancel (VOID)
  484. {
  485.    EndDialog (TRUE);
  486. }
  487.  
  488. // ----------------------------------------------------------------------
  489.  
  490. CMsgHeaderDlg::CMsgHeaderDlg (HWND p_hWnd) : CDialog ("204", p_hWnd)
  491. {
  492.    Crash = Direct = FileAttach = FileRequest = Hold = Immediate = FALSE;
  493.    Intransit = KillSent = Local = Private = ReceiptRequest = Received = FALSE;
  494.    Sent = FALSE;
  495. }
  496.  
  497. USHORT CMsgHeaderDlg::OnInitDialog (VOID)
  498. {
  499.    Center ();
  500.  
  501.    SetDlgItemText (102, From);
  502.    SetDlgItemText (108, FromAddress);
  503.    SetDlgItemText (104, To);
  504.    SetDlgItemText (110, ToAddress);
  505.    SetDlgItemText (106, Subject);
  506.  
  507.    BM_SetCheck (109, Crash);
  508.    BM_SetCheck (113, FileAttach);
  509.    BM_SetCheck (117, FileRequest);
  510.    BM_SetCheck (115, Hold);
  511.    BM_SetCheck (114, Intransit);
  512.    BM_SetCheck (123, KillSent);
  513.    BM_SetCheck (111, Local);
  514.    BM_SetCheck (107, Private);
  515.    BM_SetCheck (120, ReceiptRequest);
  516.    BM_SetCheck (121, Received);
  517.    BM_SetCheck (112, Sent);
  518.  
  519.    SetFocus (104);
  520.  
  521.    return (TRUE);
  522. }
  523.  
  524. VOID CMsgHeaderDlg::OnOK (VOID)
  525. {
  526.    GetDlgItemText (102, GetDlgItemTextLength (102), From);
  527.    GetDlgItemText (108, GetDlgItemTextLength (108), FromAddress);
  528.    GetDlgItemText (104, GetDlgItemTextLength (104), To);
  529.    GetDlgItemText (110, GetDlgItemTextLength (110), ToAddress);
  530.    GetDlgItemText (106, GetDlgItemTextLength (106), Subject);
  531.  
  532.    Crash = (UCHAR)BM_QueryCheck (109);
  533.    FileAttach = (UCHAR)BM_QueryCheck (113);
  534.    FileRequest = (UCHAR)BM_QueryCheck (117);
  535.    Hold = (UCHAR)BM_QueryCheck (115);
  536.    Intransit = (UCHAR)BM_QueryCheck (114);
  537.    KillSent = (UCHAR)BM_QueryCheck (123);
  538.    Local = (UCHAR)BM_QueryCheck (111);
  539.    Private = (UCHAR)BM_QueryCheck (107);
  540.    ReceiptRequest = (UCHAR)BM_QueryCheck (120);
  541.    Received = (UCHAR)BM_QueryCheck (121);
  542.    Sent = (UCHAR)BM_QueryCheck (112);
  543.  
  544.    EndDialog (TRUE);
  545. }
  546.  
  547. // ----------------------------------------------------------------------
  548.  
  549. class CAreaListDlg : public CDialog
  550. {
  551. public:
  552.    CAreaListDlg (HWND p_hWnd);
  553.  
  554.    USHORT NetMail;
  555.    USHORT EMail;
  556.    USHORT BadMsgs;
  557.    USHORT Dupes;
  558.    class  TMsgData *Data;
  559.  
  560.    VOID   OnChanged (VOID);
  561.    USHORT OnInitDialog (VOID);
  562.    VOID   OnOK (VOID);
  563.  
  564. private:
  565.    int    toSelect;
  566.    CHAR   Temp[128];
  567.    DECLARE_MESSAGE_MAP ()
  568. };
  569.  
  570. BEGIN_MESSAGE_MAP (CAreaListDlg, CDialog)
  571.    ON_CONTROL (CN_ENTER, 101, OnOK)
  572. END_MESSAGE_MAP ()
  573.  
  574. CAreaListDlg::CAreaListDlg (HWND p_hWnd) : CDialog ("201", p_hWnd)
  575. {
  576.    toSelect = -1;
  577.    NetMail = FALSE;
  578.    BadMsgs = FALSE;
  579.    Dupes = FALSE;
  580.    EMail = FALSE;
  581. }
  582.  
  583. USHORT CAreaListDlg::OnInitDialog (VOID)
  584. {
  585.    int i;
  586.    struct stat statbuf;
  587.    class CScanDlg *Dlg;
  588.  
  589.    Center ();
  590.  
  591.    sprintf (Temp, "%sarealist.rsn", Cfg->SystemPath);
  592.    if (stat (Temp, &statbuf) == 0) {
  593.       DoRescan = TRUE;
  594.       unlink (Temp);
  595.    }
  596.  
  597.    if (DoRescan == TRUE || Scan == NULL) {
  598.       if (Scan == NULL)
  599.          Scan = new TScan;
  600.       if (Scan != NULL) {
  601.          if ((Dlg = new CScanDlg (m_hWnd)) != NULL) {
  602.             Dlg->DoModal ();
  603.             delete Dlg;
  604.          }
  605.          DoRescan = FALSE;
  606.       }
  607.    }
  608.  
  609.    LVM_AllocateColumns (101, 4);
  610.    LVM_InsertColumn (101, "Key", LVC_LEFT);
  611.    LVM_InsertColumn (101, "Msgs.", LVC_RIGHT);
  612.    LVM_InsertColumn (101, "New", LVC_RIGHT);
  613.    LVM_InsertColumn (101, "Description", LVC_LEFT);
  614.  
  615.    i = 0;
  616.    if (Scan->First () == TRUE)
  617.       do {
  618.          LVM_InsertItem (101);
  619.  
  620.          LVM_SetItemText (101, 0, Scan->Key);
  621.          sprintf (Temp, "%lu", Scan->Messages);
  622.          LVM_SetItemText (101, 1, Temp);
  623.          sprintf (Temp, "%lu", Scan->New);
  624.          LVM_SetItemText (101, 2, Temp);
  625.          LVM_SetItemText (101, 3, Scan->Description);
  626.  
  627.          if (!stricmp (AreaKey, Scan->Key))
  628.             toSelect = i;
  629.          i++;
  630.       } while (Scan->Next () == TRUE);
  631.  
  632.    LVM_InvalidateView (101);
  633.    if (toSelect != -1)
  634.       LVM_SelectItem (101, toSelect);
  635.  
  636.    return (TRUE);
  637. }
  638.  
  639. VOID CAreaListDlg::OnOK (VOID)
  640. {
  641.    int item;
  642.    CHAR Temp[32];
  643.  
  644.    if ((item = LVM_QuerySelectedItem (101)) != -1) {
  645.       LVM_QueryItemText (101, item, 0, Temp);
  646.  
  647.       if (Scan != NULL)
  648.          Scan->Read (Temp);
  649.       if (!stricmp (Temp, "NetMail"))
  650.          NetMail = TRUE;
  651.       else if (!stricmp (Temp, "EMail"))
  652.          EMail = TRUE;
  653.       else if (!stricmp (Temp, "BadMsgs"))
  654.          BadMsgs = TRUE;
  655.       else if (!stricmp (Temp, "Dupes"))
  656.          Dupes = TRUE;
  657.       else
  658.          Data->Read (Temp, FALSE);
  659.    }
  660.  
  661.    EndDialog (TRUE);
  662. }
  663.  
  664. // ----------------------------------------------------------------------
  665.  
  666. class CMsgListDlg : public CDialog
  667. {
  668. public:
  669.    CMsgListDlg (HWND p_hWnd);
  670.  
  671.    ULONG  NewNumber;
  672.    ULONG  OldNumber;
  673.    class  TMsgBase *Msg;
  674.  
  675.    VOID   OnCancel (VOID);
  676.    USHORT OnInitDialog (VOID);
  677.    VOID   OnOK (VOID);
  678.  
  679. private:
  680.    int    Selected;
  681.    DECLARE_MESSAGE_MAP ()
  682. };
  683.  
  684. BEGIN_MESSAGE_MAP (CMsgListDlg, CDialog)
  685.    ON_CONTROL (CN_ENTER, 101, OnOK)
  686. END_MESSAGE_MAP ()
  687.  
  688. CMsgListDlg::CMsgListDlg (HWND p_hWnd) : CDialog ("202", p_hWnd)
  689. {
  690.    Selected = -1;
  691. }
  692.  
  693. USHORT CMsgListDlg::OnInitDialog (VOID)
  694. {
  695.    CHAR Temp[32];
  696.    USHORT i, ToSelect = 0;
  697.    ULONG ListNumber;
  698.  
  699.    Center ();
  700.  
  701.    LVM_AllocateColumns (101, 4);
  702.    LVM_InsertColumn (101, "Num,", LVC_RIGHT);
  703.    LVM_InsertColumn (101, "From", LVC_LEFT);
  704.    LVM_InsertColumn (101, "To", LVC_LEFT);
  705.    LVM_InsertColumn (101, "Subject", LVC_LEFT);
  706.  
  707.    Msg->Lock (0L);
  708.    ListNumber = Msg->Lowest ();
  709.    i = 0;
  710.  
  711.    do {
  712.       if (Msg->ReadHeader (ListNumber) == TRUE) {
  713.          LVM_InsertItem (101);
  714.  
  715.          sprintf (Temp, "%lu", Msg->UidToMsgn (ListNumber));
  716.          LVM_SetItemText (101, 0, Temp);
  717.          LVM_SetItemText (101, 1, Msg->From);
  718.          LVM_SetItemText (101, 2, Msg->To);
  719.          LVM_SetItemText (101, 3, Msg->Subject);
  720.  
  721.          if (ListNumber == Number)
  722.             ToSelect = i;
  723.          i++;
  724.       }
  725.    } while (Msg->Next (ListNumber) == TRUE);
  726.  
  727.    LVM_InvalidateView (101);
  728.    LVM_SelectItem (101, ToSelect);
  729.  
  730.    Msg->UnLock ();
  731.  
  732.    return (TRUE);
  733. }
  734.  
  735. VOID CMsgListDlg::OnOK (VOID)
  736. {
  737.    CHAR Temp[32];
  738.  
  739.    LVM_QueryItemText (101, LVM_QuerySelectedItem (101), 0, Temp);
  740.    NewNumber = Msg->MsgnToUid (atol (Temp));
  741.  
  742.    EndDialog (TRUE);
  743. }
  744.  
  745. VOID CMsgListDlg::OnCancel (VOID)
  746. {
  747.    Msg->Read (OldNumber);
  748.  
  749.    EndDialog (FALSE);
  750. }
  751.  
  752. // ----------------------------------------------------------------------
  753. // Product informations dialog
  754. // ----------------------------------------------------------------------
  755.  
  756. class CProductDlg : public CDialog
  757. {
  758. public:
  759.    CProductDlg (HWND p_hWnd);
  760.  
  761.    USHORT OnInitDialog (VOID);
  762. };
  763.  
  764. CProductDlg::CProductDlg (HWND p_hWnd) : CDialog ("100", p_hWnd)
  765. {
  766. }
  767.  
  768. USHORT CProductDlg::OnInitDialog (VOID)
  769. {
  770.    Center ();
  771.  
  772.    return (TRUE);
  773. }
  774.  
  775. // ----------------------------------------------------------------------
  776.  
  777. VOID ParseAddress (PSZ text, PSZ name, PSZ address)
  778. {
  779.    CHAR Temp[128], *p, *a;
  780.  
  781.    strcpy (Temp, text);
  782.    if (strchr (Temp, '(') != NULL) {
  783.       if ((p = strtok (Temp, " ")) != NULL) {
  784.          if ((a = strtok (NULL, "")) != NULL)
  785.             p = a;
  786.          while (*p == ' ')
  787.             p++;
  788.          if (*p == '(') {
  789.             strcpy (Temp, ++p);
  790.             p = strchr (Temp, '\0');
  791.             while (--p > Temp) {
  792.                if (*p == ')') {
  793.                   *p = '\0';
  794.                   break;
  795.                }
  796.             }
  797.             if (name != NULL)
  798.                strcpy (name, Temp);
  799.             strcpy (Temp, text);
  800.             if ((p = strtok (Temp, " ")) != NULL) {
  801.                if (address != NULL)
  802.                   strcpy (address, p);
  803.             }
  804.          }
  805.          else {
  806.             strcpy (Temp, text);
  807.             if ((p = strtok (Temp, " ")) != NULL) {
  808.                if (name != NULL)
  809.                   strcpy (name, p);
  810.             }
  811.          }
  812.       }
  813.    }
  814.    else if ((p = strchr (Temp, '<')) != NULL) {
  815.       *p++ = '\0';
  816.       if ((a = strchr (p, '>')) != NULL)
  817.          *a = '\0';
  818.       if (address != NULL)
  819.          strcpy (address, p);
  820.       p = Temp;
  821.       while (*p == ' ')
  822.          p++;
  823.       if (*p == '"')
  824.          strcpy (Temp, ++p);
  825.       p = strchr (Temp, '\0');
  826.       while (--p > Temp) {
  827.          if (*p != ' ' && *p != '"')
  828.             break;
  829.          *p = '\0';
  830.       }
  831.       if (name != NULL) {
  832.          strcpy (name, Temp);
  833.          if (address != NULL) {
  834.             if (*name == '\0' && *address != '\0') {
  835.                strcpy (name, address);
  836.                *address = '\0';
  837.             }
  838.          }
  839.       }
  840.    }
  841.    else if (strchr (Temp, '@') != NULL) {
  842.       if ((p = strtok (Temp, " ,")) != NULL) {
  843.          if (address != NULL)
  844.             strcpy (address, p);
  845.       }
  846.    }
  847. }
  848.  
  849. VOID DisplayMessage (HWND hwnd)
  850. {
  851.    CHAR *p, Temp[128], *Buffer, *a;
  852.    USHORT gotFrom = FALSE, gotTo = FALSE;
  853.    ULONG bytes, Msgn;
  854.    class TAddress Address;
  855. #if defined(__OS2__)
  856.    ULONG Value;
  857.  
  858.    WinSetDlgItemText (hwnd, 1113, "");
  859.    WinSetDlgItemText (hwnd, 1114, "");
  860.    WinSetDlgItemText (hwnd, 1106, "");
  861.    WinSetDlgItemText (hwnd, 1109, "");
  862.    WinSetDlgItemText (hwnd, 1111, "");
  863.    WinSetDlgItemText (hwnd, 1107, "");
  864.    WinSetDlgItemText (hwnd, 1110, "");
  865.    WinSetDlgItemText (hwnd, 1112, "");
  866.    WinSetDlgItemText (hwnd, 1108, "");
  867.  
  868.    WinSetDlgItemText (hwnd, 1105, "");
  869. #elif defined(__NT__)
  870.    SetWindowText (GetDlgItem (hwnd, 1113), "");
  871.    SetWindowText (GetDlgItem (hwnd, 1114), "");
  872.    SetWindowText (GetDlgItem (hwnd, 1106), "");
  873.    SetWindowText (GetDlgItem (hwnd, 1109), "");
  874.    SetWindowText (GetDlgItem (hwnd, 1111), "");
  875.    SetWindowText (GetDlgItem (hwnd, 1107), "");
  876.    SetWindowText (GetDlgItem (hwnd, 1110), "");
  877.    SetWindowText (GetDlgItem (hwnd, 1112), "");
  878.    SetWindowText (GetDlgItem (hwnd, 1108), "");
  879.  
  880.    SetWindowText (GetDlgItem (hwnd, 1105), "");
  881. #endif
  882.  
  883.    if (Msg != NULL) {
  884.       if (Msg->Read (Number, 80) == FALSE) {
  885.          Msg->New ();
  886.          Msgn = 0L;
  887.       }
  888.       else
  889.          Msgn = Msg->UidToMsgn (Number);
  890.  
  891.       if (Scan != NULL) {
  892.          Scan->New = Msg->Number () - Msgn;
  893.          Scan->Update ();
  894.       }
  895.  
  896.       Cfg->MailAddress.First ();
  897.       Address.Parse (Msg->FromAddress);
  898.       if (Address.Zone == 0)
  899.          Address.Zone = Cfg->MailAddress.Zone;
  900.       if (Address.Net == 0)
  901.          Address.Net = Cfg->MailAddress.Net;
  902.       Address.Add ();
  903.       Address.First ();
  904.       strcpy (Msg->FromAddress, Address.String);
  905.       Address.Clear ();
  906.  
  907.       Cfg->MailAddress.First ();
  908.       Address.Parse (Msg->ToAddress);
  909.       if (Address.Zone == 0)
  910.          Address.Zone = Cfg->MailAddress.Zone;
  911.       if (Address.Net == 0)
  912.          Address.Net = Cfg->MailAddress.Net;
  913.       Address.Add ();
  914.       Address.First ();
  915.       strcpy (Msg->ToAddress, Address.String);
  916.       Address.Clear ();
  917.  
  918.       if ((p = (CHAR *)Msg->Text.First ()) != NULL)
  919.          do {
  920.             if (!strncmp (p, " * Origin: ", 11)) {
  921.                Msg->ToAddress[0] = '\0';
  922.  
  923.                strcpy (Temp, &p[11]);
  924.                p = strchr (Temp, '\0');
  925.                while (--p > Temp) {
  926.                   if (*p != ' ' && *p != ')')
  927.                      break;
  928.                   *p = '\0';
  929.                }
  930.                if (p > Temp) {
  931.                   while (--p > Temp) {
  932.                      if (*p == '(' || *p == ' ')
  933.                         break;
  934.                   }
  935.                }
  936.                if (*p == '(' || *p == ' ')
  937.                   p++;
  938.                strcpy (Msg->FromAddress, p);
  939.                Msg->ToAddress[0] = '\0';
  940.                break;
  941.             }
  942.             else if (!strncmp (p, "\001MSGID: ", 8)) {
  943.                strcpy (Temp, &p[8]);
  944.                if ((p = strtok (Temp, " ")) != NULL) {
  945.                   if (strchr (p, ':') != NULL && strchr (p, '/') != NULL)
  946.                      strcpy (Msg->FromAddress, p);
  947.                }
  948.                break;
  949.             }
  950.             else if (!strncmp (p, "\001From: ", 7)) {
  951.                Msg->FromAddress[0] = '\0';
  952.                if (gotTo == FALSE)
  953.                   Msg->ToAddress[0] = '\0';
  954.                ParseAddress (&p[7], Msg->From, Msg->FromAddress);
  955.                gotFrom = TRUE;
  956.             }
  957.             else if (!strncmp (p, "\001To: ", 5)) {
  958.                if (gotFrom == FALSE)
  959.                   Msg->FromAddress[0] = '\0';
  960.                Msg->ToAddress[0] = '\0';
  961.                ParseAddress (&p[5], Msg->To, Msg->ToAddress);
  962.                gotTo = TRUE;
  963.             }
  964.             if (gotFrom == TRUE && gotTo == TRUE)
  965.                break;
  966.          } while ((p = (CHAR *)Msg->Text.Next ()) != NULL);
  967.  
  968. #if defined(__OS2__)
  969.       sprintf (Temp, "%lu of %lu (%lu left)", Msgn, Msg->Number (), Msg->Number () - Msgn);
  970.       if (Msg->Original != 0L)
  971.          sprintf (&Temp[strlen (Temp)], " -%lu", Msg->UidToMsgn (Msg->Original));
  972.       if (Msg->Reply != 0L)
  973.          sprintf (&Temp[strlen (Temp)], " +%lu", Msg->UidToMsgn (Msg->Reply));
  974.       WinSetDlgItemText (hwnd, 1113, Temp);
  975.       Temp[0] = '\0';
  976.       if (Msg->Received == TRUE)
  977.          strcat (Temp, "Rcv ");
  978.       if (Msg->Sent == TRUE)
  979.          strcat (Temp, "Snt ");
  980.       if (Msg->Private == TRUE)
  981.          strcat (Temp, "Pvt ");
  982.       if (Msg->Crash == TRUE)
  983.          strcat (Temp, "Cra ");
  984.       if (Msg->KillSent == TRUE)
  985.          strcat (Temp, "K/s ");
  986.       if (Msg->Local == TRUE)
  987.          strcat (Temp, "Loc ");
  988.       if (Msg->Hold == TRUE)
  989.          strcat (Temp, "Hld ");
  990.       if (Msg->FileAttach == TRUE)
  991.          strcat (Temp, "Att ");
  992.       if (Msg->FileRequest == TRUE)
  993.          strcat (Temp, "Frq ");
  994.       if (Msg->Intransit == TRUE)
  995.          strcat (Temp, "Trs ");
  996.       WinSetDlgItemText (hwnd, 1114, Temp);
  997.       WinSetDlgItemText (hwnd, 1106, Msg->From);
  998.       WinSetDlgItemText (hwnd, 1109, Msg->FromAddress);
  999.       if (Msgn != 0L) {
  1000.          sprintf (Temp, "%02d %s %d %2d:%02d:%02d", Msg->Written.Day, Months[Msg->Written.Month - 1], Msg->Written.Year, Msg->Written.Hour, Msg->Written.Minute, Msg->Written.Second);
  1001.          WinSetDlgItemText (hwnd, 1111, Temp);
  1002.       }
  1003.       WinSetDlgItemText (hwnd, 1107, Msg->To);
  1004.       if (!stricmp (Msg->To, Cfg->SysopName)) {
  1005.          Value = 0xF00000L;
  1006.          WinSetPresParam (WinWindowFromID (hwnd, 1107), PP_FOREGROUNDCOLOR, 4, &Value);
  1007.       }
  1008.       else {
  1009.          Value = 0x000000L;
  1010.          WinSetPresParam (WinWindowFromID (hwnd, 1107), PP_FOREGROUNDCOLOR, 4, &Value);
  1011.       }
  1012.       WinSetDlgItemText (hwnd, 1110, Msg->ToAddress);
  1013.       if (Msgn != 0L) {
  1014.          sprintf (Temp, "%02d %s %d %2d:%02d:%02d", Msg->Arrived.Day, Months[Msg->Arrived.Month - 1], Msg->Arrived.Year, Msg->Arrived.Hour, Msg->Arrived.Minute, Msg->Arrived.Second);
  1015.          WinSetDlgItemText (hwnd, 1112, Temp);
  1016.       }
  1017.       WinSetDlgItemText (hwnd, 1108, Msg->Subject);
  1018. #elif defined(__NT__)
  1019.       sprintf (Temp, "%lu of %lu (%lu left)", Msgn, Msg->Number (), Msg->Number () - Msgn);
  1020.       SetWindowText (GetDlgItem (hwnd, 1113), Temp);
  1021.       Temp[0] = '\0';
  1022.       if (Msg->Received == TRUE)
  1023.          strcat (Temp, "Rcv ");
  1024.       if (Msg->Sent == TRUE)
  1025.          strcat (Temp, "Snt ");
  1026.       if (Msg->Private == TRUE)
  1027.          strcat (Temp, "Pvt ");
  1028.       if (Msg->Crash == TRUE)
  1029.          strcat (Temp, "Cra ");
  1030.       if (Msg->KillSent == TRUE)
  1031.          strcat (Temp, "K/s ");
  1032.       if (Msg->Local == TRUE)
  1033.          strcat (Temp, "Loc ");
  1034.       if (Msg->Hold == TRUE)
  1035.          strcat (Temp, "Hld ");
  1036.       if (Msg->FileAttach == TRUE)
  1037.          strcat (Temp, "Att ");
  1038.       if (Msg->FileRequest == TRUE)
  1039.          strcat (Temp, "Frq ");
  1040.       if (Msg->Intransit == TRUE)
  1041.          strcat (Temp, "Trs ");
  1042.       SetWindowText (GetDlgItem (hwnd, 1114), Temp);
  1043.       SetWindowText (GetDlgItem (hwnd, 1106), Msg->From);
  1044.       SetWindowText (GetDlgItem (hwnd, 1109), Msg->FromAddress);
  1045.       if (Msgn != 0L) {
  1046.          sprintf (Temp, "%02d %s %d %2d:%02d:%02d", Msg->Written.Day, Months[Msg->Written.Month - 1], Msg->Written.Year, Msg->Written.Hour, Msg->Written.Minute, Msg->Written.Second);
  1047.          SetWindowText (GetDlgItem (hwnd, 1111), Temp);
  1048.       }
  1049.       SetWindowText (GetDlgItem (hwnd, 1107), Msg->To);
  1050.       SetWindowText (GetDlgItem (hwnd, 1110), Msg->ToAddress);
  1051.       if (Msgn != 0L) {
  1052.          sprintf (Temp, "%02d %s %d %2d:%02d:%02d", Msg->Arrived.Day, Months[Msg->Arrived.Month - 1], Msg->Arrived.Year, Msg->Arrived.Hour, Msg->Arrived.Minute, Msg->Arrived.Second);
  1053.          SetWindowText (GetDlgItem (hwnd, 1112), Temp);
  1054.       }
  1055.       SetWindowText (GetDlgItem (hwnd, 1108), Msg->Subject);
  1056. #endif
  1057.  
  1058.       bytes = 0L;
  1059.       if ((p = (CHAR *)Msg->Text.First ()) != NULL)
  1060.          do {
  1061.             if ((*p != 0x01 && strncmp (p, "SEEN-BY:", 8)) || ShowKludges == TRUE)
  1062. #if defined(__OS2__)
  1063.                bytes += strlen (p) + 1;
  1064. #elif defined(__NT__)
  1065.                bytes += strlen (p) + 2;
  1066. #endif
  1067.          } while ((p = (CHAR *)Msg->Text.Next ()) != NULL);
  1068.  
  1069.       if ((Buffer = (CHAR *)malloc (bytes + 1)) != NULL) {
  1070.          *Buffer = '\0';
  1071.          a = Buffer;
  1072.          if ((p = (CHAR *)Msg->Text.First ()) != NULL)
  1073.             do {
  1074.                if ((*p != 0x01 && strncmp (p, "SEEN-BY:", 8)) || ShowKludges == TRUE) {
  1075.                   strcpy (a, p);
  1076.                   a = strchr (a, '\0');
  1077. #if defined(__OS2__)
  1078.                   strcpy (a, "\n");
  1079. #elif defined(__NT__)
  1080.                   strcpy (a, "\r\n");
  1081. #endif
  1082.                   a = strchr (a, '\0');
  1083.                }
  1084.             } while ((p = (CHAR *)Msg->Text.Next ()) != NULL);
  1085.  
  1086. #if defined(__OS2__)
  1087.          WinSetDlgItemText (hwnd, 1105, Buffer);
  1088. #elif defined(__NT__)
  1089.          SetWindowText (GetDlgItem (hwnd, 1105), Buffer);
  1090. #endif
  1091.          free (Buffer);
  1092.       }
  1093.  
  1094.       if (!stricmp (Msg->To, Cfg->SysopName) && Msg->Received == FALSE) {
  1095.          Msg->Received = TRUE;
  1096.          Msg->WriteHeader (Number);
  1097. #if defined(__OS2__)
  1098.          WinAlarm (HWND_DESKTOP, WA_NOTE);
  1099. #endif
  1100.       }
  1101.  
  1102. #if defined(__OS2__)
  1103.       WinSendDlgItemMsg (hwnd, 1105, MLM_SETREADONLY, MPFROMSHORT (TRUE), 0L);
  1104.       WinSetFocus (HWND_DESKTOP, WinWindowFromID (hwnd, 1105));
  1105. #elif defined(__NT__)
  1106.       SendDlgItemMessage (hwnd, 1105, EM_SETREADONLY, (WPARAM)TRUE, 0L);
  1107.       SetFocus (GetDlgItem (hwnd, 1105));
  1108. #endif
  1109.  
  1110.       hAccel = hAccReader;
  1111.  
  1112. #if defined(__OS2__)
  1113.       WinEnableControl (hwnd, 1201, TRUE);
  1114.       WinEnableControl (hwnd, 1202, TRUE);
  1115.       WinEnableControl (hwnd, 1203, TRUE);
  1116.       WinEnableControl (hwnd, 1204, TRUE);
  1117.       WinEnableControl (hwnd, 1205, TRUE);
  1118.       WinEnableControl (hwnd, 1206, TRUE);
  1119.       WinEnableControl (hwnd, 1207, TRUE);
  1120.       WinEnableControl (hwnd, 1208, FALSE);
  1121.       WinEnableControl (hwnd, 1209, FALSE);
  1122. #elif defined(__NT__)
  1123.       EnableWindow (GetDlgItem (hwnd, 1201), TRUE);
  1124.       EnableWindow (GetDlgItem (hwnd, 1202), TRUE);
  1125.       EnableWindow (GetDlgItem (hwnd, 1203), TRUE);
  1126.       EnableWindow (GetDlgItem (hwnd, 1204), TRUE);
  1127.       EnableWindow (GetDlgItem (hwnd, 1205), TRUE);
  1128.       EnableWindow (GetDlgItem (hwnd, 1206), TRUE);
  1129.       EnableWindow (GetDlgItem (hwnd, 1207), TRUE);
  1130.       EnableWindow (GetDlgItem (hwnd, 1208), FALSE);
  1131.       EnableWindow (GetDlgItem (hwnd, 1209), FALSE);
  1132. #endif
  1133.    }
  1134. }
  1135.  
  1136. VOID GetOrigin (class TMsgData *Data, PSZ Origin)
  1137. {
  1138.    FILE *fp;
  1139.    int i, max;
  1140.    CHAR Temp[128];
  1141.  
  1142.    strcpy (Origin, Cfg->SystemName);
  1143.    if (Data->Origin[0] != '\0')
  1144.       strcpy (Origin, Data->Origin);
  1145.    else if (Data->OriginIndex == OIDX_DEFAULT)
  1146.       strcpy (Origin, Cfg->SystemName);
  1147.    else if (Data->OriginIndex == OIDX_RANDOM) {
  1148.       srand ((unsigned int)time (NULL));
  1149.       sprintf (Temp, "%sorigin.txt", Cfg->SystemPath);
  1150.       if ((fp = fopen (Temp, "rt")) != NULL) {
  1151.          max = 0;
  1152.          while (fgets (Temp, sizeof (Temp) - 1, fp) != NULL)
  1153.             max++;
  1154.          while ((i = rand ()) > max)
  1155.             ;
  1156.          fseek (fp, 0L, SEEK_SET);
  1157.          while (fgets (Temp, sizeof (Temp) - 1, fp) != NULL) {
  1158.             if (i == 0) {
  1159.                if (Temp[strlen (Temp) - 1] == '\n')
  1160.                   Temp[strlen (Temp) - 1] = '\0';
  1161.                strcpy (Origin, Temp);
  1162.                break;
  1163.             }
  1164.             i--;
  1165.          }
  1166.          fclose (fp);
  1167.       }
  1168.    }
  1169.    else {
  1170.       i = 1;
  1171.       sprintf (Temp, "%sorigin.txt", Cfg->SystemPath);
  1172.       if ((fp = fopen (Temp, "rt")) != NULL) {
  1173.          while (fgets (Temp, sizeof (Temp) - 1, fp) != NULL) {
  1174.             if (i == Data->OriginIndex) {
  1175.                if (Temp[strlen (Temp) - 1] == '\n')
  1176.                   Temp[strlen (Temp) - 1] = '\0';
  1177.                strcpy (Origin, Temp);
  1178.                break;
  1179.             }
  1180.          }
  1181.          fclose (fp);
  1182.       }
  1183.    }
  1184. }
  1185.  
  1186. VOID EditMessage (HWND hwnd, USHORT Reply, USHORT DoQuote)
  1187. {
  1188.    USHORT i, Continue = FALSE, gotReplyTo = FALSE;
  1189.    CHAR *p, Quote[16], Temp[128], *Buffer;
  1190.    CHAR Header[128], Footer[128], FidoAddress[64], Origin[128];
  1191.    ULONG bytes;
  1192. #if defined(__OS2__)
  1193.    IPT ipt = 0L, cursor = 0L;
  1194.    ULONG Value;
  1195. #endif
  1196.    class TMsgData *Data;
  1197.  
  1198.    if (Reply == TRUE) {
  1199.       if (Msg->ReadHeader (Number) == FALSE) {
  1200.          Msg->New ();
  1201.          Reply = FALSE;
  1202.       }
  1203.    }
  1204.  
  1205.    _dos_getdate (&d_date);
  1206.    _dos_gettime (&d_time);
  1207.  
  1208.    if (Msg != NULL && Reply == TRUE) {
  1209.       if (Msg->Read (Number, 72) == TRUE) {
  1210.          strcpy (FidoAddress, Msg->FromAddress);
  1211.          if ((p = (CHAR *)Msg->Text.First ()) != NULL)
  1212.             do {
  1213.                if (!strncmp (p, " * Origin: ", 11)) {
  1214.                   Msg->ToAddress[0] = '\0';
  1215.  
  1216.                   strcpy (Temp, &p[11]);
  1217.                   p = strchr (Temp, '\0');
  1218.                   while (--p > Temp) {
  1219.                      if (*p != ' ' && *p != ')')
  1220.                         break;
  1221.                      *p = '\0';
  1222.                   }
  1223.                   if (p > Temp) {
  1224.                      while (--p > Temp) {
  1225.                         if (*p == '(' || *p == ' ')
  1226.                            break;
  1227.                      }
  1228.                   }
  1229.                   if (*p == '(' || *p == ' ')
  1230.                      p++;
  1231.                   strcpy (Msg->FromAddress, p);
  1232.                   strcpy (FidoAddress, p);
  1233.                   break;
  1234.                }
  1235.                else if (!strncmp (p, "\001MSGID: ", 8)) {
  1236.                   strcpy (Temp, &p[8]);
  1237.                   if ((p = strtok (Temp, " ")) != NULL) {
  1238.                      if (strchr (p, ':') != NULL && strchr (p, '/') != NULL) {
  1239.                         Msg->ToAddress[0] = '\0';
  1240.                         strcpy (Msg->FromAddress, p);
  1241.                         strcpy (FidoAddress, p);
  1242.                      }
  1243.                   }
  1244.                   break;
  1245.                }
  1246.                else if (!strncmp (p, "\001From: ", 7)) {
  1247.                   Msg->ToAddress[0] = '\0';
  1248.                   if (gotReplyTo == TRUE)
  1249.                      ParseAddress (&p[7], Msg->From, NULL);
  1250.                   else {
  1251.                      Msg->FromAddress[0] = '\0';
  1252.                      ParseAddress (&p[7], Msg->From, Msg->FromAddress);
  1253.                   }
  1254.                }
  1255.                else if (!strncmp (p, "\001Reply-To: ", 11)) {
  1256.                   Temp[0] = '\0';
  1257.                   ParseAddress (&p[11], Temp, Msg->FromAddress);
  1258.                   gotReplyTo = TRUE;
  1259.                }
  1260.             } while ((p = (CHAR *)Msg->Text.Next ()) != NULL);
  1261.  
  1262.          Cfg->MailAddress.First ();
  1263.          if ((HeaderDlg = new CMsgHeaderDlg (hwnd)) != NULL) {
  1264.             strcpy (HeaderDlg->From, Cfg->SysopName);
  1265.             if (Scan->Tag[0] == '\0' || Scan->Address[0] == '\0')
  1266.                strcpy (HeaderDlg->FromAddress, Cfg->MailAddress.String);
  1267.             else
  1268.                strcpy (HeaderDlg->FromAddress, Scan->Address);
  1269.             strcpy (HeaderDlg->ToAddress, FidoAddress);
  1270.             if (strchr (Msg->FromAddress, '@') != NULL && strchr (Msg->FromAddress, '/') == NULL && strchr (Msg->FromAddress, ':') == NULL)
  1271.                strcpy (HeaderDlg->To, Msg->FromAddress);
  1272.             else
  1273.                strcpy (HeaderDlg->To, Msg->From);
  1274.  
  1275.             strcpy (Temp, Msg->Subject);
  1276.             if (strncmp (strupr (Temp), "RE:", 3))
  1277.                sprintf (HeaderDlg->Subject, "Re: %s", Msg->Subject);
  1278.             else
  1279.                strcpy (HeaderDlg->Subject, Msg->Subject);
  1280.  
  1281.             HeaderDlg->Private = Msg->Private;
  1282.             HeaderDlg->Local = TRUE;
  1283.  
  1284.             if ((Continue = (USHORT)HeaderDlg->DoModal ()) == TRUE) {
  1285. #if defined(__OS2__)
  1286.                WinSetDlgItemText (hwnd, 1106, HeaderDlg->From);
  1287.                WinSetDlgItemText (hwnd, 1109, HeaderDlg->FromAddress);
  1288.                sprintf (Temp, "%02d %s %d %2d:%02d:%02d", d_date.day, Months[d_date.month - 1], d_date.year, d_time.hour, d_time.minute, d_time.second);
  1289.                WinSetDlgItemText (hwnd, 1111, Temp);
  1290.                WinSetDlgItemText (hwnd, 1107, HeaderDlg->To);
  1291.                WinSetDlgItemText (hwnd, 1110, HeaderDlg->ToAddress);
  1292.                WinSetDlgItemText (hwnd, 1112, "");
  1293.                WinSetDlgItemText (hwnd, 1108, HeaderDlg->Subject);
  1294. #elif defined(__NT__)
  1295.                SetDlgItemText (hwnd, 1106, HeaderDlg->From);
  1296.                SetDlgItemText (hwnd, 1109, HeaderDlg->FromAddress);
  1297.                sprintf (Temp, "%02d %s %d %2d:%02d:%02d", d_date.day, Months[d_date.month - 1], d_date.year, d_time.hour, d_time.minute, d_time.second);
  1298.                SetDlgItemText (hwnd, 1111, Temp);
  1299.                SetDlgItemText (hwnd, 1107, HeaderDlg->To);
  1300.                SetDlgItemText (hwnd, 1110, HeaderDlg->ToAddress);
  1301.                SetDlgItemText (hwnd, 1112, "");
  1302.                SetDlgItemText (hwnd, 1108, HeaderDlg->Subject);
  1303. #endif
  1304.             }
  1305.          }
  1306.       }
  1307.    }
  1308.    else if (Msg != NULL) {
  1309.       Cfg->MailAddress.First ();
  1310.       if ((HeaderDlg = new CMsgHeaderDlg (hwnd)) != NULL) {
  1311.          strcpy (HeaderDlg->From, Cfg->SysopName);
  1312.          if (Scan->Tag[0] == '\0' || Scan->Address[0] == '\0')
  1313.             strcpy (HeaderDlg->FromAddress, Cfg->MailAddress.String);
  1314.          else
  1315.             strcpy (HeaderDlg->FromAddress, Scan->Address);
  1316.          strcpy (HeaderDlg->To, "All");
  1317.          strcpy (HeaderDlg->ToAddress, Cfg->MailAddress.String);
  1318.          strcpy (HeaderDlg->Subject, "");
  1319.  
  1320.          HeaderDlg->Local = TRUE;
  1321.  
  1322.          if ((Continue = (USHORT)HeaderDlg->DoModal ()) == TRUE) {
  1323. #if defined(__OS2__)
  1324.             WinSetDlgItemText (hwnd, 1106, HeaderDlg->From);
  1325.             WinSetDlgItemText (hwnd, 1109, HeaderDlg->FromAddress);
  1326.             sprintf (Temp, "%02d %s %d %2d:%02d:%02d", d_date.day, Months[d_date.month - 1], d_date.year, d_time.hour, d_time.minute, d_time.second);
  1327.             WinSetDlgItemText (hwnd, 1111, Temp);
  1328.             WinSetDlgItemText (hwnd, 1107, HeaderDlg->To);
  1329.             WinSetDlgItemText (hwnd, 1110, HeaderDlg->ToAddress);
  1330.             WinSetDlgItemText (hwnd, 1112, "");
  1331.             WinSetDlgItemText (hwnd, 1108, HeaderDlg->Subject);
  1332. #elif defined(__NT__)
  1333.             SetDlgItemText (hwnd, 1106, HeaderDlg->From);
  1334.             SetDlgItemText (hwnd, 1109, HeaderDlg->FromAddress);
  1335.             sprintf (Temp, "%02d %s %d %2d:%02d:%02d", d_date.day, Months[d_date.month - 1], d_date.year, d_time.hour, d_time.minute, d_time.second);
  1336.             SetDlgItemText (hwnd, 1111, Temp);
  1337.             SetDlgItemText (hwnd, 1107, HeaderDlg->To);
  1338.             SetDlgItemText (hwnd, 1110, HeaderDlg->ToAddress);
  1339.             SetDlgItemText (hwnd, 1112, "");
  1340.             SetDlgItemText (hwnd, 1108, HeaderDlg->Subject);
  1341. #endif
  1342.          }
  1343.       }
  1344.    }
  1345.  
  1346.    if (Msg != NULL && Continue == TRUE && HeaderDlg != NULL) {
  1347.       Temp[0] = '\0';
  1348.       if (HeaderDlg->Received == TRUE)
  1349.          strcat (Temp, "Rcv ");
  1350.       if (HeaderDlg->Sent == TRUE)
  1351.          strcat (Temp, "Snt ");
  1352.       if (HeaderDlg->Private == TRUE)
  1353.          strcat (Temp, "Pvt ");
  1354.       if (HeaderDlg->Crash == TRUE)
  1355.          strcat (Temp, "Cra ");
  1356.       if (HeaderDlg->KillSent == TRUE)
  1357.          strcat (Temp, "K/s ");
  1358.       if (HeaderDlg->Local == TRUE)
  1359.          strcat (Temp, "Loc ");
  1360.       if (HeaderDlg->Hold == TRUE)
  1361.          strcat (Temp, "Hld ");
  1362.       if (HeaderDlg->FileAttach == TRUE)
  1363.          strcat (Temp, "Att ");
  1364.       if (HeaderDlg->FileRequest == TRUE)
  1365.          strcat (Temp, "Frq ");
  1366.       if (HeaderDlg->Intransit == TRUE)
  1367.          strcat (Temp, "Trs ");
  1368. #if defined(__OS2__)
  1369.       WinSetDlgItemText (hwnd, 1114, Temp);
  1370. #elif defined(__NT__)
  1371.       SetDlgItemText (hwnd, 1114, Temp);
  1372. #endif
  1373.  
  1374.       strcpy (Temp, HeaderDlg->To);
  1375. #if defined(__OS2__)
  1376.       if ((p = strtok (Temp, " ")) != NULL)
  1377.          sprintf (Header, "Hello, %s!\n \n", p);
  1378.       else
  1379.          sprintf (Header, "Hello!\n \n");
  1380. #elif defined(__NT__)
  1381.       if ((p = strtok (Temp, " ")) != NULL)
  1382.          sprintf (Header, "Hello, %s!\r\n \r\n", p);
  1383.       else
  1384.          sprintf (Header, "Hello!\r\n \r\n");
  1385. #endif
  1386.  
  1387.       if (Scan->Tag[0] != '\0') {
  1388.          strcpy (Origin, Cfg->SystemName);
  1389.          if ((Data = new TMsgData (Cfg->SystemPath)) != NULL) {
  1390.             Data->Read (Scan->Key);
  1391.             GetOrigin (Data, Origin);
  1392.             delete Data;
  1393.          }
  1394.  
  1395.          Cfg->MailAddress.First ();
  1396. #if defined(__OS2__)
  1397.          sprintf (Footer, " \n--- %s v%s\n * Origin: %s (%s)\n", NAME, VERSION, Origin, HeaderDlg->FromAddress);
  1398. #elif defined(__NT__)
  1399.          sprintf (Footer, " \r\n--- %s v%s\r\n * Origin: %s (%s)\r\n", NAME, VERSION, Origin, HeaderDlg->FromAddress);
  1400. #endif
  1401.       }
  1402.       else {
  1403. #if defined(__OS2__)
  1404.          sprintf (Footer, " \n--- %s v%s\n", NAME, VERSION);
  1405. #elif defined(__NT__)
  1406.          sprintf (Footer, " \r\n--- %s v%s\r\n", NAME, VERSION);
  1407. #endif
  1408.       }
  1409.  
  1410.       Buffer = NULL;
  1411.       if (Reply == TRUE && DoQuote == TRUE) {
  1412.          Quote[0] = ' ';
  1413.          Quote[1] = '\0';
  1414.          i = 1;
  1415.          strcpy (Temp, Msg->From);
  1416.          if ((p = strtok (Temp, " ")) != NULL)
  1417.             do {
  1418.                Quote[i++] = *p;
  1419.             } while ((p = strtok (NULL, " ")) != NULL);
  1420.          Quote[i++] = '>';
  1421.          Quote[i++] = ' ';
  1422.          Quote[i] = '\0';
  1423.  
  1424.          bytes = strlen (Header) + strlen (Footer);
  1425.          if ((p = (CHAR *)Msg->Text.First ()) != NULL)
  1426.             do {
  1427.                if ((*p != 0x01 && strncmp (p, "SEEN-BY:", 8)) || ShowKludges == TRUE)
  1428. #if defined(__OS2__)
  1429.                   bytes += strlen (Quote) + strlen (p) + 1;
  1430. #elif defined(__NT__)
  1431.                   bytes += strlen (Quote) + strlen (p) + 2;
  1432. #endif
  1433.             } while ((p = (CHAR *)Msg->Text.Next ()) != NULL);
  1434.  
  1435.          if ((Buffer = (CHAR *)malloc (bytes + 1)) != NULL) {
  1436.             *Buffer = '\0';
  1437.             strcat (Buffer, Header);
  1438.             if ((p = (CHAR *)Msg->Text.First ()) != NULL)
  1439.                do {
  1440.                   if ((*p != 0x01 && strncmp (p, "SEEN-BY:", 8)) || ShowKludges == TRUE) {
  1441.                      strcat (Buffer, Quote);
  1442.                      strcat (Buffer, p);
  1443. #if defined(__OS2__)
  1444.                      strcat (Buffer, "\n");
  1445. #elif defined(__NT__)
  1446.                      strcat (Buffer, "\r\n");
  1447. #endif
  1448.                   }
  1449.                } while ((p = (CHAR *)Msg->Text.Next ()) != NULL);
  1450.             strcat (Buffer, Footer);
  1451.          }
  1452.       }
  1453.       else {
  1454.          bytes = strlen (Header) + strlen (Footer);
  1455.          if ((Buffer = (CHAR *)malloc (bytes + 1)) != NULL) {
  1456.             *Buffer = '\0';
  1457.             strcat (Buffer, Header);
  1458.             strcat (Buffer, Footer);
  1459.          }
  1460.       }
  1461.  
  1462.       if (Buffer != NULL) {
  1463. #if defined(__OS2__)
  1464.          Value = 0x000000L;
  1465.          WinSetPresParam (WinWindowFromID (hwnd, 1107), PP_FOREGROUNDCOLOR, 4, &Value);
  1466.  
  1467.          WinSetDlgItemText (hwnd, 1105, Buffer);
  1468. #elif defined(__NT__)
  1469.          SetDlgItemText (hwnd, 1105, Buffer);
  1470. #endif
  1471.          free (Buffer);
  1472.  
  1473.          hAccel = hAccEditor;
  1474.  
  1475. #if defined(__OS2__)
  1476.          WinSendDlgItemMsg (hwnd, 1105, MLM_SETREADONLY, MPFROMSHORT (FALSE), 0L);
  1477.          WinSetFocus (HWND_DESKTOP, WinWindowFromID (hwnd, 1105));
  1478. #elif defined(__NT__)
  1479.          SendDlgItemMessage (hwnd, 1105, EM_SETREADONLY, (WPARAM)FALSE, 0L);
  1480.          SetFocus (GetDlgItem (hwnd, 1105));
  1481. #endif
  1482.  
  1483. #if defined(__OS2__)
  1484.          WinEnableControl (hwnd, 1201, FALSE);
  1485.          WinEnableControl (hwnd, 1202, FALSE);
  1486.          WinEnableControl (hwnd, 1203, FALSE);
  1487.          WinEnableControl (hwnd, 1204, FALSE);
  1488.          WinEnableControl (hwnd, 1205, FALSE);
  1489.          WinEnableControl (hwnd, 1206, FALSE);
  1490.          WinEnableControl (hwnd, 1207, FALSE);
  1491.          WinEnableControl (hwnd, 1208, TRUE);
  1492.          WinEnableControl (hwnd, 1209, TRUE);
  1493. #elif defined(__NT__)
  1494.          EnableWindow (GetDlgItem (hwnd, 1201), FALSE);
  1495.          EnableWindow (GetDlgItem (hwnd, 1202), FALSE);
  1496.          EnableWindow (GetDlgItem (hwnd, 1203), FALSE);
  1497.          EnableWindow (GetDlgItem (hwnd, 1204), FALSE);
  1498.          EnableWindow (GetDlgItem (hwnd, 1205), FALSE);
  1499.          EnableWindow (GetDlgItem (hwnd, 1206), FALSE);
  1500.          EnableWindow (GetDlgItem (hwnd, 1207), FALSE);
  1501.          EnableWindow (GetDlgItem (hwnd, 1208), TRUE);
  1502.          EnableWindow (GetDlgItem (hwnd, 1209), TRUE);
  1503. #endif
  1504.       }
  1505.    }
  1506. }
  1507.  
  1508. VOID SaveMessage (HWND hwnd)
  1509. {
  1510.    CHAR *p, *a, *Buffer, Temp[64];
  1511.    LONG bytes;
  1512.    class TEchotoss *EchoToss;
  1513.    class TAddress FromAddress, ToAddress;
  1514.  
  1515. #if defined(__OS2__)
  1516.    bytes = (LONG)WinQueryDlgItemTextLength (hwnd, 1105) + 1;
  1517. #elif defined(__NT__)
  1518.    bytes = GetWindowTextLength (GetDlgItem (hwnd, 1105)) + 1;
  1519. #endif
  1520.  
  1521.    if (Msg != NULL && bytes != 0L) {
  1522.       Msg->New ();
  1523.  
  1524. #if defined(__OS2__)
  1525.       WinQueryDlgItemText (hwnd, 1106, WinQueryDlgItemTextLength (hwnd, 1106) + 1, Msg->From);
  1526.       WinQueryDlgItemText (hwnd, 1107, WinQueryDlgItemTextLength (hwnd, 1107) + 1, Msg->To);
  1527.       WinQueryDlgItemText (hwnd, 1108, WinQueryDlgItemTextLength (hwnd, 1108) + 1, Msg->Subject);
  1528.  
  1529.       WinQueryDlgItemText (hwnd, 1109, WinQueryDlgItemTextLength (hwnd, 1109) + 1, Msg->FromAddress);
  1530.       WinQueryDlgItemText (hwnd, 1110, WinQueryDlgItemTextLength (hwnd, 1110) + 1, Msg->ToAddress);
  1531. #elif defined(__NT__)
  1532.       GetWindowText (GetDlgItem (hwnd, 1106), Msg->From, GetWindowTextLength (GetDlgItem (hwnd, 1106)) + 1);
  1533.       GetWindowText (GetDlgItem (hwnd, 1107), Msg->To, GetWindowTextLength (GetDlgItem (hwnd, 1107)) + 1);
  1534.       GetWindowText (GetDlgItem (hwnd, 1108), Msg->Subject, GetWindowTextLength (GetDlgItem (hwnd, 1108)) + 1);
  1535.  
  1536.       GetWindowText (GetDlgItem (hwnd, 1109), Msg->FromAddress, GetWindowTextLength (GetDlgItem (hwnd, 1109)) + 1);
  1537.       GetWindowText (GetDlgItem (hwnd, 1110), Msg->ToAddress, GetWindowTextLength (GetDlgItem (hwnd, 1110)) + 1);
  1538. #endif
  1539.  
  1540.       if (HeaderDlg != NULL) {
  1541.          Msg->Crash = HeaderDlg->Crash;
  1542.          Msg->FileAttach = HeaderDlg->FileAttach;
  1543.          Msg->FileRequest = HeaderDlg->FileRequest;
  1544.          Msg->Hold = HeaderDlg->Hold;
  1545.          Msg->Intransit = HeaderDlg->Intransit;
  1546.          Msg->KillSent = HeaderDlg->KillSent;
  1547.          Msg->Local = HeaderDlg->Local;
  1548.          Msg->Private = HeaderDlg->Private;
  1549.          Msg->ReceiptRequest = HeaderDlg->ReceiptRequest;
  1550.          Msg->Received = HeaderDlg->Received;
  1551.          Msg->Sent = HeaderDlg->Sent;
  1552.       }
  1553.  
  1554.       if (Scan->Tag[0] == '\0') {
  1555.          FromAddress.Parse (Msg->FromAddress);
  1556.          ToAddress.Parse (Msg->ToAddress);
  1557.          Cfg->MailAddress.First ();
  1558.          if ((FromAddress.Zone != ToAddress.Zone) || FromAddress.Zone != Cfg->MailAddress.Zone || ToAddress.Zone != Cfg->MailAddress.Zone || Cfg->ForceIntl == TRUE) {
  1559.             sprintf (Temp, "\001INTL %u:%u/%u %u:%u/%u", ToAddress.Zone, ToAddress.Net, ToAddress.Node, FromAddress.Zone, FromAddress.Net, FromAddress.Node);
  1560.             Msg->Text.Add (Temp);
  1561.          }
  1562.          if (FromAddress.Point != 0) {
  1563.             sprintf (Temp, "\001FMPT %u", FromAddress.Point);
  1564.             Msg->Text.Add (Temp);
  1565.          }
  1566.          if (ToAddress.Point != 0) {
  1567.             sprintf (Temp, "\001TOPT %u", ToAddress.Point);
  1568.             Msg->Text.Add (Temp);
  1569.          }
  1570.       }
  1571.  
  1572.       sprintf (Temp, "\001MSGID: %s %08lx", Msg->FromAddress, time (NULL));
  1573.       Msg->Text.Add (Temp);
  1574.       sprintf (Temp, "\001PID: %s", NAME_OS);
  1575.       Msg->Text.Add (Temp);
  1576.  
  1577.       if ((Buffer = (CHAR *)malloc (bytes + 1)) != NULL) {
  1578. #if defined(__OS2__)
  1579.          WinQueryDlgItemText (hwnd, 1105, bytes, Buffer);
  1580. #elif defined(__NT__)
  1581.          GetWindowText (GetDlgItem (hwnd, 1105), Buffer, bytes);
  1582. #endif
  1583.          Buffer[bytes] = '\0';
  1584.  
  1585.          a = Buffer;
  1586.          while ((p = strchr (a, '\n')) != NULL) {
  1587.             if (p > a) {
  1588.                p--;
  1589.                if (*p == '\r')
  1590.                   *p = '\0';
  1591.                p++;
  1592.             }
  1593.             *p = '\0';
  1594.             Msg->Text.Add (a);
  1595.             a = p + 1;
  1596.          }
  1597.          if (*a != '\0')
  1598.             Msg->Text.Add (a);
  1599.  
  1600.          free (Buffer);
  1601.       }
  1602.  
  1603.       Msg->Arrived.Day = Msg->Written.Day = d_date.day;
  1604.       Msg->Arrived.Month = Msg->Written.Month = d_date.month;
  1605.       Msg->Arrived.Year = Msg->Written.Year = (USHORT)d_date.year;
  1606.       Msg->Arrived.Hour = Msg->Written.Hour = d_time.hour;
  1607.       Msg->Arrived.Minute = Msg->Written.Minute = d_time.minute;
  1608.       Msg->Arrived.Second = Msg->Written.Second = d_time.second;
  1609.  
  1610.       Msg->Add ();
  1611.  
  1612.       if (Scan != NULL && Scan->Tag[0] != '\0') {
  1613.          if ((EchoToss = new TEchotoss (Cfg->SystemPath)) != NULL) {
  1614.             EchoToss->Load ();
  1615.             EchoToss->Add (Scan->Tag);
  1616.             EchoToss->Save ();
  1617.             delete EchoToss;
  1618.          }
  1619.       }
  1620.    }
  1621.  
  1622.    if (HeaderDlg != NULL) {
  1623.       delete HeaderDlg;
  1624.       HeaderDlg = NULL;
  1625.    }
  1626.  
  1627.    DisplayMessage (hwnd);
  1628. }
  1629.  
  1630. class TMsgBase *OpenArea (USHORT Storage, PSZ Path, PSZ Newsgroup, USHORT Board)
  1631. {
  1632.    class TMsgBase *Msg = NULL;
  1633.  
  1634.    switch (Storage) {
  1635.       case ST_JAM:
  1636.          Msg = new JAM (Path);
  1637.          break;
  1638.       case ST_SQUISH:
  1639.          Msg = new SQUISH (Path);
  1640.          break;
  1641.       case ST_FIDO:
  1642.          Msg = new FIDOSDM (Path);
  1643.          break;
  1644.       case ST_ADEPT:
  1645.          Msg = new ADEPT (Path);
  1646.          break;
  1647.       case ST_HUDSON:
  1648.          Msg = new HUDSON (Path, (UCHAR)Board);
  1649.          break;
  1650.       case ST_USENET:
  1651.          Msg = new USENET (Cfg->NewsServer, Newsgroup);
  1652.          break;
  1653.    }
  1654.  
  1655.    return (Msg);
  1656. }
  1657.  
  1658. VOID CopyMessage (HWND hwnd, USHORT DoDelete)
  1659. {
  1660.    class CAreaListDlg *Dlg;
  1661.    class TMsgBase *CopyMsg = NULL;
  1662.  
  1663.    if ((Dlg = new CAreaListDlg (hwnd)) != NULL) {
  1664.       Dlg->Data = new TMsgData (Cfg->SystemPath);
  1665.       if (Dlg->DoModal () == TRUE) {
  1666.          if (Dlg->NetMail == TRUE)
  1667.             CopyMsg = OpenArea (Cfg->NetMailStorage, Cfg->NetMailPath, NULL, Cfg->NetMailBoard);
  1668.          else if (Dlg->EMail == TRUE)
  1669.             CopyMsg = OpenArea (Cfg->MailStorage, Cfg->MailPath, NULL, Cfg->MailBoard);
  1670.          else if (Dlg->Dupes == TRUE)
  1671.             CopyMsg = OpenArea (Cfg->DupeStorage, Cfg->DupePath, NULL, Cfg->DupeBoard);
  1672.          else if (Dlg->BadMsgs == TRUE)
  1673.             CopyMsg = OpenArea (Cfg->BadStorage, Cfg->BadPath, NULL, Cfg->BadBoard);
  1674.          else
  1675.             CopyMsg = OpenArea (Dlg->Data->Storage, Dlg->Data->Path, Dlg->Data->NewsGroup, Dlg->Data->Board);
  1676.  
  1677.          if (CopyMsg != NULL) {
  1678.             CopyMsg->Add (Msg);
  1679.             if (Scan != NULL) {
  1680.                Scan->Messages = CopyMsg->Number ();
  1681.                Scan->New++;
  1682.                Scan->Update ();
  1683.             }
  1684.             delete CopyMsg;
  1685.             if (DoDelete == TRUE) {
  1686.                Msg->Delete (Number);
  1687.                if (Msg->Next (Number) == FALSE) {
  1688.                   if (Msg->Previous (Number) == FALSE)
  1689.                      Msg->New ();
  1690.                }
  1691.                DisplayMessage (hwnd);
  1692.             }
  1693.          }
  1694.       }
  1695.       if (Dlg->Data != NULL)
  1696.          delete Dlg->Data;
  1697.       delete Dlg;
  1698.    }
  1699.  
  1700.    if (Scan != NULL) {
  1701.       Scan->Read (AreaKey);
  1702.       Scan->Messages = Msg->Number ();
  1703.       if (Scan->New != 0)
  1704.          Scan->New--;
  1705.       Scan->Update ();
  1706.    }
  1707. }
  1708.  
  1709. VOID ForwardMessage (HWND hwnd)
  1710. {
  1711.    CHAR Temp[128], CopyKey[32], Origin[128], *p;
  1712.    class TAddress FromAddress, ToAddress;
  1713.    class TMsgBase *CopyMsg = NULL;
  1714.    class CAreaListDlg *alDlg;
  1715.    class CMsgHeaderDlg *Dlg = NULL;
  1716.  
  1717.    _dos_getdate (&d_date);
  1718.    _dos_gettime (&d_time);
  1719.  
  1720.    if ((alDlg = new CAreaListDlg (hwnd)) != NULL) {
  1721.       alDlg->Data = new TMsgData (Cfg->SystemPath);
  1722.       if (alDlg->DoModal () == TRUE) {
  1723.          if (alDlg->NetMail == TRUE) {
  1724.             CopyMsg = OpenArea (Cfg->NetMailStorage, Cfg->NetMailPath, NULL, Cfg->NetMailBoard);
  1725.             strcpy (CopyKey, "NetMail");
  1726.          }
  1727.          else if (alDlg->EMail == TRUE) {
  1728.             CopyMsg = OpenArea (Cfg->MailStorage, Cfg->MailPath, NULL, Cfg->MailBoard);
  1729.             strcpy (CopyKey, "EMail");
  1730.          }
  1731.          else if (alDlg->Dupes == TRUE) {
  1732.             CopyMsg = OpenArea (Cfg->DupeStorage, Cfg->DupePath, NULL, Cfg->DupeBoard);
  1733.             strcpy (CopyKey, "Dupes");
  1734.          }
  1735.          else if (alDlg->BadMsgs == TRUE) {
  1736.             CopyMsg = OpenArea (Cfg->BadStorage, Cfg->BadPath, NULL, Cfg->BadBoard);
  1737.             strcpy (CopyKey, "BadMsgs");
  1738.          }
  1739.          else
  1740.             CopyMsg = OpenArea (alDlg->Data->Storage, alDlg->Data->Path, alDlg->Data->NewsGroup, alDlg->Data->Board);
  1741.  
  1742.          if (CopyMsg != NULL) {
  1743.             Cfg->MailAddress.First ();
  1744.             if ((Dlg = new CMsgHeaderDlg (hwnd)) != NULL) {
  1745.                strcpy (Dlg->From, Cfg->SysopName);
  1746.                if (Scan->Tag[0] == '\0' || Scan->Address[0] == '\0')
  1747.                   strcpy (Dlg->FromAddress, Cfg->MailAddress.String);
  1748.                else
  1749.                   strcpy (Dlg->FromAddress, Scan->Address);
  1750.                strcpy (Dlg->To, "All");
  1751.                strcpy (Dlg->ToAddress, Cfg->MailAddress.String);
  1752.                strcpy (Dlg->Subject, Msg->Subject);
  1753.  
  1754.                if (Dlg->DoModal () == TRUE) {
  1755.                   if (Scan->Tag[0] == '\0') {
  1756.                      FromAddress.Parse (Dlg->FromAddress);
  1757.                      ToAddress.Parse (Dlg->ToAddress);
  1758.                      Cfg->MailAddress.First ();
  1759.                      if ((FromAddress.Zone != ToAddress.Zone) || FromAddress.Zone != Cfg->MailAddress.Zone || ToAddress.Zone != Cfg->MailAddress.Zone || Cfg->ForceIntl == TRUE) {
  1760.                         sprintf (Temp, "\001INTL %u:%u/%u %u:%u/%u", ToAddress.Zone, ToAddress.Net, ToAddress.Node, FromAddress.Zone, FromAddress.Net, FromAddress.Node);
  1761.                         CopyMsg->Text.Add (Temp);
  1762.                      }
  1763.                      if (FromAddress.Point != 0) {
  1764.                         sprintf (Temp, "\001FMPT %u", FromAddress.Point);
  1765.                         CopyMsg->Text.Add (Temp);
  1766.                      }
  1767.                      if (ToAddress.Point != 0) {
  1768.                         sprintf (Temp, "\001TOPT %u", ToAddress.Point);
  1769.                         CopyMsg->Text.Add (Temp);
  1770.                      }
  1771.                   }
  1772.  
  1773.                   CopyMsg->New ();
  1774.                   strcpy (CopyMsg->From, Dlg->From);
  1775.                   strcpy (CopyMsg->FromAddress, Dlg->FromAddress);
  1776.                   strcpy (CopyMsg->To, Dlg->To);
  1777.                   strcpy (CopyMsg->ToAddress, Dlg->ToAddress);
  1778.                   strcpy (CopyMsg->Subject, Dlg->Subject);
  1779.  
  1780.                   sprintf (Temp, "\001MSGID: %s %08lx", CopyMsg->FromAddress, time (NULL));
  1781.                   CopyMsg->Text.Add (Temp);
  1782.                   sprintf (Temp, "\001PID: %s", NAME_OS);
  1783.                   CopyMsg->Text.Add (Temp);
  1784.  
  1785.                   CopyMsg->Arrived.Day = Msg->Written.Day = d_date.day;
  1786.                   CopyMsg->Arrived.Month = Msg->Written.Month = d_date.month;
  1787.                   CopyMsg->Arrived.Year = Msg->Written.Year = (USHORT)d_date.year;
  1788.                   CopyMsg->Arrived.Hour = Msg->Written.Hour = d_time.hour;
  1789.                   CopyMsg->Arrived.Minute = Msg->Written.Minute = d_time.minute;
  1790.                   CopyMsg->Arrived.Second = Msg->Written.Second = d_time.second;
  1791.  
  1792.                   CopyMsg->Text.Add ("===============================================================================");
  1793.                   sprintf (Temp, "* Forwarded by %s (%s)", Dlg->From, Dlg->FromAddress);
  1794.                   CopyMsg->Text.Add (Temp);
  1795.                   if (alDlg->NetMail == TRUE || alDlg->EMail == TRUE || alDlg->Dupes == TRUE || alDlg->BadMsgs == TRUE)
  1796.                      sprintf (Temp, "* Area : %s", CopyKey);
  1797.                   else
  1798.                      sprintf (Temp, "* Area : %s (%s)", alDlg->Data->Key, alDlg->Data->Display);
  1799.                   CopyMsg->Text.Add (Temp);
  1800.                   sprintf (Temp, "* From : %s, %s", Msg->From, Msg->FromAddress);
  1801.                   CopyMsg->Text.Add (Temp);
  1802.                   sprintf (Temp, "* To   : %s", Msg->To);
  1803.                   CopyMsg->Text.Add (Temp);
  1804.                   sprintf (Temp, "* Subj : %-.70s", Msg->Subject);
  1805.                   CopyMsg->Text.Add (Temp);
  1806.                   CopyMsg->Text.Add ("===============================================================================");
  1807.  
  1808.                   if ((p = (PSZ)Msg->Text.First ()) != NULL)
  1809.                      do {
  1810.                         if (*p != 0x01 && strncmp (p, "SEEN-BY: ", 9)) {
  1811.                            if (!strcmp (p, "---") || !strncmp (p, "--- ", 4)) {
  1812.                               strcpy (Temp, p);
  1813.                               Temp[1] = '+';
  1814.                            }
  1815.                            else if (!strncmp (p, " * Origin: ", 11)) {
  1816.                               strcpy (Temp, p);
  1817.                               Temp[3] = '0';
  1818.                            }
  1819.                            else
  1820.                               CopyMsg->Text.Add (p);
  1821.                         }
  1822.                         else if (ShowKludges == TRUE) {
  1823.                            strcpy (Temp, p);
  1824.                            if (Temp[0] == 0x01)
  1825.                               Temp[0] = '@';
  1826.                            else if (!strncmp (Temp, "SEEN-BY: ", 9))
  1827.                               Temp[4] = '+';
  1828.                            CopyMsg->Text.Add (Temp);
  1829.                         }
  1830.                      } while ((p = (PSZ)Msg->Text.Next ()) != NULL);
  1831.  
  1832.                   CopyMsg->Text.Add ("");
  1833.                   sprintf (Temp, "--- %s v%s", NAME, VERSION);
  1834.                   CopyMsg->Text.Add (Temp);
  1835.  
  1836.                   if (Scan->Tag[0] != '\0') {
  1837.                      GetOrigin (alDlg->Data, Origin);
  1838.                      Cfg->MailAddress.First ();
  1839.                      sprintf (Temp, " * Origin: %s (%s)", NAME, VERSION, Origin, Msg->FromAddress);
  1840.                      CopyMsg->Text.Add (Temp);
  1841.                   }
  1842.  
  1843.                   CopyMsg->Add ();
  1844.  
  1845.                   if (Scan != NULL) {
  1846.                      Scan->Messages = CopyMsg->Number ();
  1847.                      Scan->New++;
  1848.                      Scan->Update ();
  1849.                   }
  1850.                }
  1851.                delete Dlg;
  1852.             }
  1853.             delete CopyMsg;
  1854.          }
  1855.       }
  1856.       if (alDlg->Data != NULL)
  1857.          delete alDlg->Data;
  1858.       delete alDlg;
  1859.    }
  1860.  
  1861.    if (Scan != NULL)
  1862.       Scan->Read (AreaKey);
  1863. }
  1864.  
  1865. VOID ChangeArea (HWND hwnd)
  1866. {
  1867.    CHAR Title[128];
  1868.    class CAreaListDlg *Dlg;
  1869.    class TMsgData *Data;
  1870.    class TUser *User;
  1871.  
  1872.    if ((User = new TUser (Cfg->UserFile)) != NULL) {
  1873.       if (User->GetData (Cfg->SysopName) == TRUE) {
  1874.          if (User->MsgTag->Read (AreaKey) == TRUE) {
  1875.             User->MsgTag->LastRead = Number;
  1876.             User->MsgTag->Update ();
  1877.          }
  1878.          else {
  1879.             User->MsgTag->New ();
  1880.             strcpy (User->MsgTag->Area, AreaKey);
  1881.             User->MsgTag->Tagged = FALSE;
  1882.             User->MsgTag->LastRead = Number;
  1883.             User->MsgTag->Add ();
  1884.          }
  1885.          User->Update ();
  1886.       }
  1887.       delete User;
  1888.    }
  1889.  
  1890.    Data = new TMsgData (Cfg->SystemPath);
  1891.  
  1892.    if ((Dlg = new CAreaListDlg (hwnd)) != NULL) {
  1893.       Dlg->Data = Data;
  1894.       if (Dlg->DoModal () == TRUE) {
  1895.          if (Msg != NULL)
  1896.             delete Msg;
  1897.          Msg = NULL;
  1898.  
  1899.          if (Dlg->NetMail == TRUE) {
  1900.             strcpy (AreaKey, "NetMail");
  1901. #if defined(__POINT__)
  1902.             sprintf (Title, "%s v%s - %s", NAME, VERSION, AreaKey);
  1903. #else
  1904.             sprintf (Title, "%s Message Reader v%s - %s", NAME, VERSION, AreaKey);
  1905. #endif
  1906. #if defined(__OS2__)
  1907.             WinSetWindowText (hwndReaderFrame, Title);
  1908. #elif defined(__NT__)
  1909.             SetWindowText (hwndReaderClient, Title);
  1910. #endif
  1911.             Msg = OpenArea (Cfg->NetMailStorage, Cfg->NetMailPath, NULL, Cfg->NetMailBoard);
  1912.          }
  1913.          else if (Dlg->EMail == TRUE) {
  1914.             strcpy (AreaKey, "EMail");
  1915. #if defined(__POINT__)
  1916.             sprintf (Title, "%s v%s - %s", NAME, VERSION, AreaKey);
  1917. #else
  1918.             sprintf (Title, "%s Message Reader v%s - %s", NAME, VERSION, AreaKey);
  1919. #endif
  1920. #if defined(__OS2__)
  1921.             WinSetWindowText (hwndReaderFrame, Title);
  1922. #elif defined(__NT__)
  1923.             SetWindowText (hwndReaderClient, Title);
  1924. #endif
  1925.             Msg = OpenArea (Cfg->MailStorage, Cfg->MailPath, NULL, Cfg->MailBoard);
  1926.          }
  1927.          else if (Dlg->Dupes == TRUE) {
  1928.             strcpy (AreaKey, "Dupes");
  1929. #if defined(__POINT__)
  1930.             sprintf (Title, "%s v%s - %s", NAME, VERSION, AreaKey);
  1931. #else
  1932.             sprintf (Title, "%s Message Reader v%s - %s", NAME, VERSION, AreaKey);
  1933. #endif
  1934. #if defined(__OS2__)
  1935.             WinSetWindowText (hwndReaderFrame, Title);
  1936. #elif defined(__NT__)
  1937.             SetWindowText (hwndReaderClient, Title);
  1938. #endif
  1939.             Msg = OpenArea (Cfg->DupeStorage, Cfg->DupePath, NULL, Cfg->DupeBoard);
  1940.          }
  1941.          else if (Dlg->BadMsgs == TRUE) {
  1942.             strcpy (AreaKey, "BadMsgs");
  1943. #if defined(__POINT__)
  1944.             sprintf (Title, "%s v%s - %s", NAME, VERSION, AreaKey);
  1945. #else
  1946.             sprintf (Title, "%s Message Reader v%s - %s", NAME, VERSION, AreaKey);
  1947. #endif
  1948. #if defined(__OS2__)
  1949.             WinSetWindowText (hwndReaderFrame, Title);
  1950. #elif defined(__NT__)
  1951.             SetWindowText (hwndReaderClient, Title);
  1952. #endif
  1953.             Msg = OpenArea (Cfg->BadStorage, Cfg->BadPath, NULL, Cfg->BadBoard);
  1954.          }
  1955.          else {
  1956.             strcpy (AreaKey, Data->Key);
  1957. #if defined(__POINT__)
  1958.             sprintf (Title, "%s v%s - %s", NAME, VERSION, Data->Display);
  1959. #else
  1960.             sprintf (Title, "%s Message Reader v%s - %s", NAME, VERSION, Data->Display);
  1961. #endif
  1962. #if defined(__OS2__)
  1963.             WinSetWindowText (hwndReaderFrame, Title);
  1964. #elif defined(__NT__)
  1965.             SetWindowText (hwndReaderClient, Title);
  1966. #endif
  1967.             Msg = OpenArea (Data->Storage, Data->Path, Data->NewsGroup, Data->Board);
  1968.          }
  1969.  
  1970.          if (Msg != NULL && Scan != NULL) {
  1971.             Scan->Messages = Msg->Number ();
  1972.             Scan->Update ();
  1973.          }
  1974.  
  1975.          Number = 0L;
  1976.          if ((User = new TUser (Cfg->UserFile)) != NULL) {
  1977.             if (User->GetData (Cfg->SysopName) == TRUE) {
  1978.                if (User->MsgTag->Read (AreaKey) == TRUE)
  1979.                   Number = User->MsgTag->LastRead;
  1980.             }
  1981.             delete User;
  1982.          }
  1983.  
  1984.          if (Msg != NULL)
  1985.             Msg->Next (Number);
  1986.          DisplayMessage (hwnd);
  1987.       }
  1988.       delete Dlg;
  1989.    }
  1990.  
  1991.    if (Data != NULL)
  1992.       delete Data;
  1993. }
  1994.  
  1995. // ----------------------------------------------------------------------
  1996.  
  1997. /*
  1998. #if defined(__NT__)
  1999.  
  2000. static FARPROC PrevEditProc;
  2001.  
  2002. LRESULT CALLBACK EditSubclassProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  2003. {
  2004.    switch (msg) {
  2005.       default:
  2006.          return (CallWindowProc (PrevEditProc, hwnd, msg, wParam, lParam));
  2007.    }
  2008. }
  2009. #endif
  2010. */
  2011.  
  2012. #if defined(__OS2__)
  2013. MRESULT EXPENTRY ReaderWinProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
  2014. #elif defined(__NT__)
  2015. LRESULT CALLBACK ReaderWinProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  2016. #endif
  2017. {
  2018.    switch (msg) {
  2019.       case WM_CREATE: {
  2020.          class TUser *User;
  2021. #if defined(__OS2__)
  2022.          ULONG Value;
  2023.          HWND hwndCtl;
  2024.  
  2025.          if ((hwndCtl = WinCreateWindow (hwnd, WC_STATIC, "Msg: ", SS_TEXT|DT_RIGHT|DT_VCENTER|WS_GROUP|WS_TABSTOP|WS_VISIBLE, 0, 0, 0, 0, hwnd, HWND_TOP, 1101, NULL, NULL)) != NULLHANDLE) {
  2026.             Value = WinQuerySysColor (HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0L);
  2027.             WinSetPresParam (hwndCtl, PP_BACKGROUNDCOLOR, 4, &Value);
  2028.          }
  2029.  
  2030.          if ((hwndCtl = WinCreateWindow (hwnd, WC_ENTRYFIELD, NULL, ES_READONLY|ES_LEFT|WS_GROUP|WS_TABSTOP|WS_VISIBLE, 0, 0, 0, 0, hwnd, HWND_TOP, 1113, NULL, NULL)) != NULLHANDLE) {
  2031.             Value = 0x000000L;
  2032.             WinSetPresParam (hwndCtl, PP_FOREGROUNDCOLOR, 4, &Value);
  2033.             Value = WinQuerySysColor (HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0L);
  2034.             WinSetPresParam (hwndCtl, PP_BACKGROUNDCOLOR, 4, &Value);
  2035.          }
  2036.  
  2037.          if ((hwndCtl = WinCreateWindow (hwnd, WC_ENTRYFIELD, NULL, ES_READONLY|ES_LEFT|WS_GROUP|WS_TABSTOP|WS_VISIBLE, 0, 0, 0, 0, hwnd, HWND_TOP, 1114, NULL, NULL)) != NULLHANDLE) {
  2038.             Value = 0x000000L;
  2039.             WinSetPresParam (hwndCtl, PP_FOREGROUNDCOLOR, 4, &Value);
  2040.             Value = WinQuerySysColor (HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0L);
  2041.             WinSetPresParam (hwndCtl, PP_BACKGROUNDCOLOR, 4, &Value);
  2042.          }
  2043.  
  2044.          if ((hwndCtl = WinCreateWindow (hwnd, WC_STATIC, NULL, SS_TEXT|DT_RIGHT|DT_VCENTER|WS_GROUP|WS_TABSTOP|WS_VISIBLE, 0, 0, 0, 0, hwnd, HWND_TOP, 1102, NULL, NULL)) != NULLHANDLE) {
  2045.             Value = WinQuerySysColor (HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0L);
  2046.             WinSetPresParam (hwndCtl, PP_BACKGROUNDCOLOR, 4, &Value);
  2047.             WinSetWindowText (hwndCtl, "From: ");
  2048.          }
  2049.  
  2050.          if ((hwndCtl = WinCreateWindow (hwnd, WC_ENTRYFIELD, NULL, ES_READONLY|ES_LEFT|WS_GROUP|WS_TABSTOP|WS_VISIBLE, 0, 0, 0, 0, hwnd, HWND_TOP, 1106, NULL, NULL)) != NULLHANDLE) {
  2051.             Value = 0x000000L;
  2052.             WinSetPresParam (hwndCtl, PP_FOREGROUNDCOLOR, 4, &Value);
  2053.             Value = WinQuerySysColor (HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0L);
  2054.             WinSetPresParam (hwndCtl, PP_BACKGROUNDCOLOR, 4, &Value);
  2055.          }
  2056.  
  2057.          if ((hwndCtl = WinCreateWindow (hwnd, WC_STATIC, NULL, SS_TEXT|DT_LEFT|DT_VCENTER|WS_GROUP|WS_TABSTOP|WS_VISIBLE, 0, 0, 0, 0, hwnd, HWND_TOP, 1109, NULL, NULL)) != NULLHANDLE) {
  2058.             Value = 0x000000L;
  2059.             WinSetPresParam (hwndCtl, PP_FOREGROUNDCOLOR, 4, &Value);
  2060.             Value = WinQuerySysColor (HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0L);
  2061.             WinSetPresParam (hwndCtl, PP_BACKGROUNDCOLOR, 4, &Value);
  2062.          }
  2063.  
  2064.          if ((hwndCtl = WinCreateWindow (hwnd, WC_STATIC, NULL, SS_TEXT|DT_LEFT|DT_VCENTER|WS_GROUP|WS_TABSTOP|WS_VISIBLE, 0, 0, 0, 0, hwnd, HWND_TOP, 1111, NULL, NULL)) != NULLHANDLE) {
  2065.             WinSetPresParam (hwndCtl, PP_FONTNAMESIZE, 7, "8.Helv");
  2066.             Value = 0x000000L;
  2067.             WinSetPresParam (hwndCtl, PP_FOREGROUNDCOLOR, 4, &Value);
  2068.             Value = WinQuerySysColor (HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0L);
  2069.             WinSetPresParam (hwndCtl, PP_BACKGROUNDCOLOR, 4, &Value);
  2070.          }
  2071.  
  2072.          if ((hwndCtl = WinCreateWindow (hwnd, WC_STATIC, NULL, SS_TEXT|DT_RIGHT|DT_VCENTER|WS_GROUP|WS_TABSTOP|WS_VISIBLE, 0, 0, 0, 0, hwnd, HWND_TOP, 1103, NULL, NULL)) != NULLHANDLE) {
  2073.             Value = WinQuerySysColor (HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0L);
  2074.             WinSetPresParam (hwndCtl, PP_BACKGROUNDCOLOR, 4, &Value);
  2075.             WinSetWindowText (hwndCtl, "To: ");
  2076.          }
  2077.  
  2078.          if ((hwndCtl = WinCreateWindow (hwnd, WC_ENTRYFIELD, NULL, ES_READONLY|ES_LEFT|WS_GROUP|WS_TABSTOP|WS_VISIBLE, 0, 0, 0, 0, hwnd, HWND_TOP, 1107, NULL, NULL)) != NULLHANDLE) {
  2079.             Value = 0x000000L;
  2080.             WinSetPresParam (hwndCtl, PP_FOREGROUNDCOLOR, 4, &Value);
  2081.             Value = WinQuerySysColor (HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0L);
  2082.             WinSetPresParam (hwndCtl, PP_BACKGROUNDCOLOR, 4, &Value);
  2083.          }
  2084.  
  2085.          if ((hwndCtl = WinCreateWindow (hwnd, WC_STATIC, NULL, SS_TEXT|DT_LEFT|DT_VCENTER|WS_GROUP|WS_TABSTOP|WS_VISIBLE, 0, 0, 0, 0, hwnd, HWND_TOP, 1110, NULL, NULL)) != NULLHANDLE) {
  2086.             Value = 0x000000L;
  2087.             WinSetPresParam (hwndCtl, PP_FOREGROUNDCOLOR, 4, &Value);
  2088.             Value = WinQuerySysColor (HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0L);
  2089.             WinSetPresParam (hwndCtl, PP_BACKGROUNDCOLOR, 4, &Value);
  2090.          }
  2091.  
  2092.          if ((hwndCtl = WinCreateWindow (hwnd, WC_STATIC, NULL, SS_TEXT|DT_LEFT|DT_VCENTER|WS_GROUP|WS_TABSTOP|WS_VISIBLE, 0, 0, 0, 0, hwnd, HWND_TOP, 1112, NULL, NULL)) != NULLHANDLE) {
  2093.             WinSetPresParam (hwndCtl, PP_FONTNAMESIZE, 7, "8.Helv");
  2094.             Value = 0x000000L;
  2095.             WinSetPresParam (hwndCtl, PP_FOREGROUNDCOLOR, 4, &Value);
  2096.             Value = WinQuerySysColor (HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0L);
  2097.             WinSetPresParam (hwndCtl, PP_BACKGROUNDCOLOR, 4, &Value);
  2098.          }
  2099.  
  2100.          if ((hwndCtl = WinCreateWindow (hwnd, WC_STATIC, NULL, SS_TEXT|DT_RIGHT|DT_VCENTER|WS_GROUP|WS_TABSTOP|WS_VISIBLE, 0, 0, 0, 0, hwnd, HWND_TOP, 1104, NULL, NULL)) != NULLHANDLE) {
  2101.             Value = WinQuerySysColor (HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0L);
  2102.             WinSetPresParam (hwndCtl, PP_BACKGROUNDCOLOR, 4, &Value);
  2103.             WinSetWindowText (hwndCtl, "Subject: ");
  2104.          }
  2105.  
  2106.          if ((hwndCtl = WinCreateWindow (hwnd, WC_ENTRYFIELD, NULL, ES_READONLY|ES_LEFT|WS_GROUP|WS_TABSTOP|WS_VISIBLE, 0, 0, 0, 0, hwnd, HWND_TOP, 1108, NULL, NULL)) != NULLHANDLE) {
  2107.             Value = 0x000000L;
  2108.             WinSetPresParam (hwndCtl, PP_FOREGROUNDCOLOR, 4, &Value);
  2109.             Value = WinQuerySysColor (HWND_DESKTOP, SYSCLR_DIALOGBACKGROUND, 0L);
  2110.             WinSetPresParam (hwndCtl, PP_BACKGROUNDCOLOR, 4, &Value);
  2111.          }
  2112.  
  2113.          if ((hwndCtl = WinCreateWindow (hwnd, WC_MLE, NULL, MLS_WORDWRAP|MLS_BORDER|MLS_READONLY|MLS_VSCROLL|WS_GROUP|WS_TABSTOP|WS_VISIBLE, 0, 0, 0, 0, hwnd, HWND_TOP, 1105, NULL, NULL)) != NULLHANDLE) {
  2114.             WinSetPresParam (hwndCtl, PP_FONTNAMESIZE, 14, "11.System VIO");
  2115.             Value = 0xFFFFFFL;
  2116.             WinSetPresParam (hwndCtl, PP_BACKGROUNDCOLOR, 4, &Value);
  2117.             Value = 0x000000L;
  2118.             WinSetPresParam (hwndCtl, PP_FOREGROUNDCOLOR, 4, &Value);
  2119.             WinSendMsg (hwndCtl, MLM_FORMAT, MPFROMSHORT (MLFIE_NOTRANS), 0L);
  2120.          }
  2121.  
  2122.          if ((hwndCtl = WinCreateWindow (hwnd, WC_BUTTON, "~Previous", BS_PUSHBUTTON|WS_GROUP|WS_TABSTOP|WS_VISIBLE, 0, 0, 60, 25, hwnd, HWND_TOP, 1201, NULL, NULL)) != NULLHANDLE)
  2123.             WinSetPresParam (hwndCtl, PP_FONTNAMESIZE, 7, "8.Helv");
  2124.          if ((hwndCtl = WinCreateWindow (hwnd, WC_BUTTON, "~Next", BS_PUSHBUTTON|WS_GROUP|WS_TABSTOP|WS_VISIBLE, 0, 0, 60, 25, hwnd, HWND_TOP, 1202, NULL, NULL)) != NULLHANDLE)
  2125.             WinSetPresParam (hwndCtl, PP_FONTNAMESIZE, 7, "8.Helv");
  2126.          if ((hwndCtl = WinCreateWindow (hwnd, WC_BUTTON, "~Reply", BS_PUSHBUTTON|WS_GROUP|WS_TABSTOP|WS_VISIBLE, 0, 0, 60, 25, hwnd, HWND_TOP, 1203, NULL, NULL)) != NULLHANDLE)
  2127.             WinSetPresParam (hwndCtl, PP_FONTNAMESIZE, 7, "8.Helv");
  2128.          if ((hwndCtl = WinCreateWindow (hwnd, WC_BUTTON, "~List", BS_PUSHBUTTON|WS_GROUP|WS_TABSTOP|WS_VISIBLE, 0, 0, 60, 25, hwnd, HWND_TOP, 1204, NULL, NULL)) != NULLHANDLE)
  2129.             WinSetPresParam (hwndCtl, PP_FONTNAMESIZE, 7, "8.Helv");
  2130.          if ((hwndCtl = WinCreateWindow (hwnd, WC_BUTTON, "~Enter", BS_PUSHBUTTON|WS_GROUP|WS_TABSTOP|WS_VISIBLE, 0, 0, 60, 25, hwnd, HWND_TOP, 1205, NULL, NULL)) != NULLHANDLE)
  2131.             WinSetPresParam (hwndCtl, PP_FONTNAMESIZE, 7, "8.Helv");
  2132.          if ((hwndCtl = WinCreateWindow (hwnd, WC_BUTTON, "~Area", BS_PUSHBUTTON|WS_GROUP|WS_TABSTOP|WS_VISIBLE, 0, 0, 60, 25, hwnd, HWND_TOP, 1206, NULL, NULL)) != NULLHANDLE)
  2133.             WinSetPresParam (hwndCtl, PP_FONTNAMESIZE, 7, "8.Helv");
  2134.          if ((hwndCtl = WinCreateWindow (hwnd, WC_BUTTON, "~Delete", BS_PUSHBUTTON|WS_GROUP|WS_TABSTOP|WS_VISIBLE, 0, 0, 60, 25, hwnd, HWND_TOP, 1207, NULL, NULL)) != NULLHANDLE)
  2135.             WinSetPresParam (hwndCtl, PP_FONTNAMESIZE, 7, "8.Helv");
  2136.          if ((hwndCtl = WinCreateWindow (hwnd, WC_BUTTON, "~Abort", BS_PUSHBUTTON|WS_GROUP|WS_TABSTOP|WS_VISIBLE, 0, 0, 60, 25, hwnd, HWND_TOP, 1208, NULL, NULL)) != NULLHANDLE)
  2137.             WinSetPresParam (hwndCtl, PP_FONTNAMESIZE, 7, "8.Helv");
  2138.          if ((hwndCtl = WinCreateWindow (hwnd, WC_BUTTON, "~Save", BS_PUSHBUTTON|WS_GROUP|WS_TABSTOP|WS_VISIBLE, 0, 0, 60, 25, hwnd, HWND_TOP, 1209, NULL, NULL)) != NULLHANDLE)
  2139.             WinSetPresParam (hwndCtl, PP_FONTNAMESIZE, 7, "8.Helv");
  2140. #elif defined(__NT__)
  2141.          LOGFONT logFont;
  2142.          HFONT hFontHelv, hFontFixed;
  2143.          HWND hwndCtl;
  2144.  
  2145.          logFont.lfHeight = 6;
  2146.          logFont.lfWidth = 6;
  2147.          logFont.lfEscapement = 0;
  2148.          logFont.lfOrientation = 0;
  2149.          logFont.lfWeight = FW_NORMAL;
  2150.          logFont.lfItalic = FALSE;
  2151.          logFont.lfUnderline = FALSE;
  2152.          logFont.lfStrikeOut = FALSE;
  2153.          logFont.lfCharSet = OEM_CHARSET;
  2154.          logFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
  2155.          logFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
  2156.          logFont.lfQuality = DEFAULT_QUALITY;
  2157.          logFont.lfPitchAndFamily = DEFAULT_PITCH|FF_DONTCARE;
  2158.          strcpy (logFont.lfFaceName, "Helv");
  2159.          hFontHelv = CreateFontIndirect (&logFont);
  2160.  
  2161.          logFont.lfHeight = 12;
  2162.          logFont.lfWidth = 8;
  2163.          logFont.lfEscapement = 0;
  2164.          logFont.lfOrientation = 0;
  2165.          logFont.lfWeight = FW_NORMAL;
  2166.          logFont.lfItalic = FALSE;
  2167.          logFont.lfUnderline = FALSE;
  2168.          logFont.lfStrikeOut = FALSE;
  2169.          logFont.lfCharSet = OEM_CHARSET;
  2170.          logFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
  2171.          logFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
  2172.          logFont.lfQuality = DEFAULT_QUALITY;
  2173.          logFont.lfPitchAndFamily = DEFAULT_PITCH|FF_DONTCARE;
  2174.          strcpy (logFont.lfFaceName, "Fixedsys");
  2175.          hFontFixed = CreateFontIndirect (&logFont);
  2176.  
  2177.          CreateWindow ("STATIC", "Msg: ", SS_RIGHT|WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)1101, hinst, NULL);
  2178.          CreateWindow ("STATIC", "", SS_LEFT|WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)1113, hinst, NULL);
  2179.          CreateWindow ("STATIC", "", SS_LEFT|WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)1114, hinst, NULL);
  2180.  
  2181.          CreateWindow ("STATIC", "From: ", SS_RIGHT|WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)1102, hinst, NULL);
  2182.          CreateWindow ("STATIC", "", SS_LEFT|WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)1106, hinst, NULL);
  2183.          CreateWindow ("STATIC", "", SS_LEFT|WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)1109, hinst, NULL);
  2184.          hwndCtl = CreateWindow ("STATIC", "", SS_LEFT|WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)1111, hinst, NULL);
  2185.          SendMessage (hwndCtl, WM_SETFONT, (WPARAM)hFontHelv, MAKELPARAM (FALSE, 0));
  2186.  
  2187.          CreateWindow ("STATIC", "To: ", SS_RIGHT|WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)1103, hinst, NULL);
  2188.          CreateWindow ("STATIC", "", SS_LEFT|WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)1107, hinst, NULL);
  2189.          CreateWindow ("STATIC", "", SS_LEFT|WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)1110, hinst, NULL);
  2190.          hwndCtl = CreateWindow ("STATIC", "", SS_LEFT|WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)1112, hinst, NULL);
  2191.          SendMessage (hwndCtl, WM_SETFONT, (WPARAM)hFontHelv, MAKELPARAM (FALSE, 0));
  2192.  
  2193.          CreateWindow ("STATIC", "Subject: ", SS_RIGHT|WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)1104, hinst, NULL);
  2194.          CreateWindow ("STATIC", "", SS_LEFT|WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)1108, hinst, NULL);
  2195.  
  2196.          hwndCtl = CreateWindowEx (WS_EX_CLIENTEDGE, "EDIT", "", ES_MULTILINE|ES_LEFT|WS_CHILD|WS_VISIBLE|WS_VSCROLL, 0, 0, 0, 0, hwnd, (HMENU)1105, hinst, NULL);
  2197.          SendMessage (hwndCtl, WM_SETFONT, (WPARAM)hFontFixed, MAKELPARAM (FALSE, 0));
  2198. //         PrevEditProc = (FARPROC)SetWindowLong (hwndCtl, GWL_WNDPROC, (LONG)EditSubclassProc);
  2199.  
  2200.          hwndCtl = CreateWindow ("BUTTON", "&Previous", BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)1201, hinst, NULL);
  2201.          SendMessage (hwndCtl, WM_SETFONT, (WPARAM)hFontHelv, MAKELPARAM (FALSE, 0));
  2202.          hwndCtl = CreateWindow ("BUTTON", "&Next", BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)1202, hinst, NULL);
  2203.          SendMessage (hwndCtl, WM_SETFONT, (WPARAM)hFontHelv, MAKELPARAM (FALSE, 0));
  2204.          hwndCtl = CreateWindow ("BUTTON", "&Abort", BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)1208, hinst, NULL);
  2205.          SendMessage (hwndCtl, WM_SETFONT, (WPARAM)hFontHelv, MAKELPARAM (FALSE, 0));
  2206.          hwndCtl = CreateWindow ("BUTTON", "&Save", BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)1209, hinst, NULL);
  2207.          SendMessage (hwndCtl, WM_SETFONT, (WPARAM)hFontHelv, MAKELPARAM (FALSE, 0));
  2208.          hwndCtl = CreateWindow ("BUTTON", "&Enter", BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)1205, hinst, NULL);
  2209.          SendMessage (hwndCtl, WM_SETFONT, (WPARAM)hFontHelv, MAKELPARAM (FALSE, 0));
  2210.          hwndCtl = CreateWindow ("BUTTON", "&Reply", BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)1203, hinst, NULL);
  2211.          SendMessage (hwndCtl, WM_SETFONT, (WPARAM)hFontHelv, MAKELPARAM (FALSE, 0));
  2212.          hwndCtl = CreateWindow ("BUTTON", "&List", BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)1204, hinst, NULL);
  2213.          SendMessage (hwndCtl, WM_SETFONT, (WPARAM)hFontHelv, MAKELPARAM (FALSE, 0));
  2214.          hwndCtl = CreateWindow ("BUTTON", "&Area", BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)1206, hinst, NULL);
  2215.          SendMessage (hwndCtl, WM_SETFONT, (WPARAM)hFontHelv, MAKELPARAM (FALSE, 0));
  2216.          hwndCtl = CreateWindow ("BUTTON", "&Delete", BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)1207, hinst, NULL);
  2217.          SendMessage (hwndCtl, WM_SETFONT, (WPARAM)hFontHelv, MAKELPARAM (FALSE, 0));
  2218. #endif
  2219.          Msg = OpenArea (Cfg->NetMailStorage, Cfg->NetMailPath, NULL, Cfg->NetMailBoard);
  2220.          strcpy (AreaKey, "NetMail");
  2221.          Number = 0L;
  2222.          if ((User = new TUser (Cfg->UserFile)) != NULL) {
  2223.             if (User->GetData (Cfg->SysopName) == TRUE) {
  2224.                if (User->MsgTag->Read (AreaKey) == TRUE)
  2225.                   Number = User->MsgTag->LastRead;
  2226.             }
  2227.             delete User;
  2228.          }
  2229.          if (Msg->ReadHeader (Number) == FALSE) {
  2230.             if (Msg->Next (Number) == FALSE)
  2231.                Msg->Previous (Number);
  2232.          }
  2233.  
  2234.          if ((Scan = new TScan) != NULL) {
  2235.             strcpy (Scan->Key, "NetMail");
  2236.             strcpy (Scan->Description, "FidoNet E-Mail");
  2237.             Scan->Messages = Msg->Number ();
  2238.             Scan->New = Msg->Number () - Msg->UidToMsgn (Number);
  2239.             Scan->Tag[0] = '\0';
  2240.             Scan->Add ();
  2241.             Scan->First ();
  2242.          }
  2243.          break;
  2244.       }
  2245.  
  2246. #if defined(__NT__)
  2247.       case WM_CTLCOLORSTATIC: {
  2248.          CHAR Temp[96];
  2249.          LOGBRUSH logBrush;
  2250.  
  2251.          if ((HWND)lParam == GetDlgItem (hwnd, 1107)) {
  2252.             GetWindowText ((HWND)lParam, Temp, GetWindowTextLength ((HWND)lParam) + 1);
  2253.             if (!stricmp (Temp, Cfg->SysopName))
  2254.                SetTextColor ((HDC)wParam, RGB (0xD0, 0x00, 0x00));
  2255.             else
  2256.                SetTextColor ((HDC)wParam, RGB (0x00, 0x00, 0x00));
  2257.          }
  2258.  
  2259.          SetBkColor ((HDC)wParam, RGB (0xC0, 0xC0, 0xC0));
  2260.  
  2261.          logBrush.lbStyle = BS_SOLID;
  2262.          logBrush.lbColor = RGB (0xC0, 0xC0, 0xC0);
  2263.          logBrush.lbHatch = 0;
  2264.  
  2265.          return ((BOOL)CreateBrushIndirect (&logBrush));
  2266.       }
  2267. #endif
  2268.  
  2269.       case WM_SIZE: {
  2270.          USHORT dx, dy;
  2271.          USHORT xcol2, wcol2, wcol3, wcol4;
  2272.  
  2273.          xcol2 = 80;
  2274. #if defined(__OS2__)
  2275.          dx = (USHORT)SHORT1FROMMP (mp2);
  2276.          dy = (USHORT)SHORT2FROMMP (mp2);
  2277. #elif defined(__NT__)
  2278.          dx = (USHORT)LOWORD (lParam);
  2279.          dy = (USHORT)HIWORD (lParam);
  2280. #endif
  2281.          wcol2 = (USHORT)(((float)(dx - xcol2) / 100.0) * 45.0);
  2282.          wcol3 = (USHORT)(((float)(dx - xcol2) / 100.0) * 32.0);
  2283.          wcol4 = (USHORT)(dx - xcol2 - wcol2 - wcol3);
  2284.  
  2285. #if defined(__OS2__)
  2286.          WinSetWindowPos (WinWindowFromID (hwnd, 1101), NULLHANDLE, 0, dy - STATIC_HEIGHT * 1, xcol2, STATIC_HEIGHT, SWP_SIZE|SWP_MOVE|SWP_SHOW);
  2287.          WinSetWindowPos (WinWindowFromID (hwnd, 1102), NULLHANDLE, 0, dy - STATIC_HEIGHT * 2, xcol2, STATIC_HEIGHT, SWP_SIZE|SWP_MOVE|SWP_SHOW);
  2288.          WinSetWindowPos (WinWindowFromID (hwnd, 1103), NULLHANDLE, 0, dy - STATIC_HEIGHT * 3, xcol2, STATIC_HEIGHT, SWP_SIZE|SWP_MOVE|SWP_SHOW);
  2289.          WinSetWindowPos (WinWindowFromID (hwnd, 1104), NULLHANDLE, 0, dy - STATIC_HEIGHT * 4, xcol2, STATIC_HEIGHT, SWP_SIZE|SWP_MOVE|SWP_SHOW);
  2290.  
  2291.          WinSetWindowPos (WinWindowFromID (hwnd, 1113), NULLHANDLE, xcol2, dy - STATIC_HEIGHT * 1, dx - xcol2, STATIC_HEIGHT, SWP_SIZE|SWP_MOVE|SWP_SHOW);
  2292.          WinSetWindowPos (WinWindowFromID (hwnd, 1106), NULLHANDLE, xcol2, dy - STATIC_HEIGHT * 2, wcol2, STATIC_HEIGHT, SWP_SIZE|SWP_MOVE|SWP_SHOW);
  2293.          WinSetWindowPos (WinWindowFromID (hwnd, 1107), NULLHANDLE, xcol2, dy - STATIC_HEIGHT * 3, wcol2, STATIC_HEIGHT, SWP_SIZE|SWP_MOVE|SWP_SHOW);
  2294.          WinSetWindowPos (WinWindowFromID (hwnd, 1108), NULLHANDLE, xcol2, dy - STATIC_HEIGHT * 4, dx - xcol2, STATIC_HEIGHT, SWP_SIZE|SWP_MOVE|SWP_SHOW);
  2295.  
  2296.          WinSetWindowPos (WinWindowFromID (hwnd, 1114), NULLHANDLE, xcol2 + wcol2, dy - STATIC_HEIGHT * 1, wcol3 + wcol4, STATIC_HEIGHT, SWP_SIZE|SWP_MOVE|SWP_SHOW);
  2297.          WinSetWindowPos (WinWindowFromID (hwnd, 1109), NULLHANDLE, xcol2 + wcol2, dy - STATIC_HEIGHT * 2, wcol3, STATIC_HEIGHT, SWP_SIZE|SWP_MOVE|SWP_SHOW);
  2298.          WinSetWindowPos (WinWindowFromID (hwnd, 1110), NULLHANDLE, xcol2 + wcol2, dy - STATIC_HEIGHT * 3, wcol3, STATIC_HEIGHT, SWP_SIZE|SWP_MOVE|SWP_SHOW);
  2299.  
  2300.          WinSetWindowPos (WinWindowFromID (hwnd, 1111), NULLHANDLE, xcol2 + wcol2 + wcol3, dy - STATIC_HEIGHT * 2, wcol4, STATIC_HEIGHT, SWP_SIZE|SWP_MOVE|SWP_SHOW);
  2301.          WinSetWindowPos (WinWindowFromID (hwnd, 1112), NULLHANDLE, xcol2 + wcol2 + wcol3, dy - STATIC_HEIGHT * 3, wcol4, STATIC_HEIGHT, SWP_SIZE|SWP_MOVE|SWP_SHOW);
  2302.  
  2303.          WinSetWindowPos (WinWindowFromID (hwnd, 1105), NULLHANDLE, 0, 35, dx, dy - STATIC_HEIGHT * 4 - 35, SWP_SIZE|SWP_MOVE|SWP_SHOW);
  2304.  
  2305.          WinSetWindowPos (WinWindowFromID (hwnd, 1201), NULLHANDLE, 5, 5, 0, 0, SWP_MOVE|SWP_SHOW);
  2306.          WinSetWindowPos (WinWindowFromID (hwnd, 1202), NULLHANDLE, 5 + 65 * 1, 5, 0, 0, SWP_MOVE|SWP_SHOW);
  2307.          WinSetWindowPos (WinWindowFromID (hwnd, 1208), NULLHANDLE, 5 + 65 * 2 + 5, 5, 0, 0, SWP_MOVE|SWP_SHOW);
  2308.          WinSetWindowPos (WinWindowFromID (hwnd, 1209), NULLHANDLE, 5 + 65 * 3 + 5, 5, 0, 0, SWP_MOVE|SWP_SHOW);
  2309.          WinSetWindowPos (WinWindowFromID (hwnd, 1205), NULLHANDLE, 5 + 65 * 4 + 10, 5, 0, 0, SWP_MOVE|SWP_SHOW);
  2310.          WinSetWindowPos (WinWindowFromID (hwnd, 1203), NULLHANDLE, 5 + 65 * 5 + 10, 5, 0, 0, SWP_MOVE|SWP_SHOW);
  2311.          WinSetWindowPos (WinWindowFromID (hwnd, 1204), NULLHANDLE, 5 + 65 * 6 + 15, 5, 0, 0, SWP_MOVE|SWP_SHOW);
  2312.          WinSetWindowPos (WinWindowFromID (hwnd, 1206), NULLHANDLE, 5 + 65 * 7 + 15, 5, 0, 0, SWP_MOVE|SWP_SHOW);
  2313.          WinSetWindowPos (WinWindowFromID (hwnd, 1207), NULLHANDLE, 5 + 65 * 8 + 20, 5, 0, 0, SWP_MOVE|SWP_SHOW);
  2314. #elif defined(__NT__)
  2315.          MoveWindow (GetDlgItem (hwnd, 1101), 0, 0, xcol2, STATIC_HEIGHT, TRUE);
  2316.          MoveWindow (GetDlgItem (hwnd, 1102), 0, STATIC_HEIGHT, xcol2, STATIC_HEIGHT, TRUE);
  2317.          MoveWindow (GetDlgItem (hwnd, 1103), 0, STATIC_HEIGHT * 2, xcol2, STATIC_HEIGHT, TRUE);
  2318.          MoveWindow (GetDlgItem (hwnd, 1104), 0, STATIC_HEIGHT * 3, xcol2, STATIC_HEIGHT, TRUE);
  2319.  
  2320.          MoveWindow (GetDlgItem (hwnd, 1113), xcol2, 0, dx - xcol2, STATIC_HEIGHT, TRUE);
  2321.          MoveWindow (GetDlgItem (hwnd, 1106), xcol2, STATIC_HEIGHT, wcol2, STATIC_HEIGHT, TRUE);
  2322.          MoveWindow (GetDlgItem (hwnd, 1107), xcol2, STATIC_HEIGHT * 2, wcol2, STATIC_HEIGHT, TRUE);
  2323.          MoveWindow (GetDlgItem (hwnd, 1108), xcol2, STATIC_HEIGHT * 3, dx - xcol2, STATIC_HEIGHT, TRUE);
  2324.  
  2325.          MoveWindow (GetDlgItem (hwnd, 1114), xcol2 + wcol2, 0, wcol3 + wcol4, STATIC_HEIGHT, TRUE);
  2326.          MoveWindow (GetDlgItem (hwnd, 1109), xcol2 + wcol2, STATIC_HEIGHT, wcol3, STATIC_HEIGHT, TRUE);
  2327.          MoveWindow (GetDlgItem (hwnd, 1110), xcol2 + wcol2, STATIC_HEIGHT * 2, wcol3, STATIC_HEIGHT, TRUE);
  2328.  
  2329.          MoveWindow (GetDlgItem (hwnd, 1111), xcol2 + wcol2 + wcol3, STATIC_HEIGHT, wcol4, STATIC_HEIGHT, TRUE);
  2330.          MoveWindow (GetDlgItem (hwnd, 1112), xcol2 + wcol2 + wcol3, STATIC_HEIGHT * 2, wcol4, STATIC_HEIGHT, TRUE);
  2331.  
  2332.          MoveWindow (GetDlgItem (hwnd, 1105), 0, STATIC_HEIGHT * 4, dx, dy - (STATIC_HEIGHT * 4) - 35, TRUE);
  2333.  
  2334.          MoveWindow (GetDlgItem (hwnd, 1201), 5, dy - 25 - 5, 60, 25, TRUE);
  2335.          MoveWindow (GetDlgItem (hwnd, 1202), 5 + 65 * 1, dy - 25 - 5, 60, 25, TRUE);
  2336.          MoveWindow (GetDlgItem (hwnd, 1208), 5 + 65 * 2 + 5, dy - 25 - 5, 60, 25, TRUE);
  2337.          MoveWindow (GetDlgItem (hwnd, 1209), 5 + 65 * 3 + 5, dy - 25 - 5, 60, 25, TRUE);
  2338.          MoveWindow (GetDlgItem (hwnd, 1205), 5 + 65 * 4 + 10, dy - 25 - 5, 60, 25, TRUE);
  2339.          MoveWindow (GetDlgItem (hwnd, 1203), 5 + 65 * 5 + 10, dy - 25 - 5, 60, 25, TRUE);
  2340.          MoveWindow (GetDlgItem (hwnd, 1204), 5 + 65 * 6 + 15, dy - 25 - 5, 60, 25, TRUE);
  2341.          MoveWindow (GetDlgItem (hwnd, 1206), 5 + 65 * 7 + 15, dy - 25 - 5, 60, 25, TRUE);
  2342.          MoveWindow (GetDlgItem (hwnd, 1207), 5 + 65 * 8 + 20, dy - 25 - 5, 60, 25, TRUE);
  2343. #endif
  2344.          break;
  2345.       }
  2346.  
  2347.       case WM_USER:
  2348.          DisplayMessage (hwnd);
  2349.          break;
  2350.  
  2351.       case WM_COMMAND:
  2352. #if defined(__OS2__)
  2353.          if (SHORT1FROMMP (mp1) >= 1200 && SHORT1FROMMP (mp1) < 1300)
  2354.             WinSetFocus (HWND_DESKTOP, WinWindowFromID (hwnd, SHORT1FROMMP (mp1)));
  2355.          switch (SHORT1FROMMP (mp1)) {
  2356. #elif defined(__NT__)
  2357.          if (LOWORD (wParam) >= 1200 && LOWORD (wParam) < 1300)
  2358.             SetFocus (GetDlgItem (hwnd, LOWORD (wParam)));
  2359.          switch (LOWORD (wParam)) {
  2360. #endif
  2361.             case 103:
  2362. #if defined(__OS2__)
  2363.                WinPostMsg (hwnd, WM_CLOSE, 0L, 0L);
  2364. #elif defined(__NT__)
  2365.                PostMessage (hwnd, WM_CLOSE, 0, 0L);
  2366. #endif
  2367.                break;
  2368.             case 104: {
  2369.                class TUULib *UULib;
  2370.  
  2371.                if ((UULib = new TUULib) != NULL) {
  2372.                   UULib->Decode (Msg->Text);
  2373.                   delete UULib;
  2374.                }
  2375.                break;
  2376.             }
  2377.             case 201:   // Edit / Undo
  2378. #if defined(__OS2__)
  2379.                WinSendDlgItemMsg (hwnd, 1105, MLM_UNDO, 0L, 0L);
  2380. #endif
  2381.                break;
  2382.             case 202:   // Edit / Cut
  2383. #if defined(__OS2__)
  2384.                WinSendDlgItemMsg (hwnd, 1105, MLM_CUT, 0L, 0L);
  2385. #endif
  2386.                break;
  2387.             case 203:   // Edit / Copy
  2388. #if defined(__OS2__)
  2389.                WinSendDlgItemMsg (hwnd, 1105, MLM_COPY, 0L, 0L);
  2390. #endif
  2391.                break;
  2392.             case 204:   // Edit / Paste
  2393. #if defined(__OS2__)
  2394.                WinSendDlgItemMsg (hwnd, 1105, MLM_PASTE, 0L, 0L);
  2395. #endif
  2396.                break;   // Edit / Clear
  2397.             case 205:
  2398. #if defined(__OS2__)
  2399.                WinSendDlgItemMsg (hwnd, 1105, MLM_CLEAR, 0L, 0L);
  2400. #endif
  2401.                break;
  2402.             case 301:   // Message / Move
  2403.                CopyMessage (hwnd, TRUE);
  2404.                break;
  2405.             case 302:   // Message / Copy
  2406.                CopyMessage (hwnd, FALSE);
  2407.                break;
  2408.             case 303:   // Message / Forward
  2409.                ForwardMessage (hwnd);
  2410.                break;
  2411.             case 304:
  2412. #if defined(__OS2__)
  2413.                WinPostMsg (hwnd, WM_COMMAND, MPFROMSHORT (1205), 0L);
  2414. #elif defined(__NT__)
  2415.                PostMessage (hwnd, WM_COMMAND, 1205, 0L);
  2416. #endif
  2417.                break;
  2418.             case 305:
  2419. #if defined(__OS2__)
  2420.                WinPostMsg (hwnd, WM_COMMAND, MPFROMSHORT (1203), 0L);
  2421. #elif defined(__NT__)
  2422.                PostMessage (hwnd, WM_COMMAND, 1203, 0L);
  2423. #endif
  2424.                break;
  2425.             case 306:
  2426. #if defined(__OS2__)
  2427.                WinPostMsg (hwnd, WM_COMMAND, MPFROMSHORT (1207), 0L);
  2428. #elif defined(__NT__)
  2429.                PostMessage (hwnd, WM_COMMAND, 1207, 0L);
  2430. #endif
  2431.                break;
  2432.             case 308:
  2433.                if (Msg != NULL) {
  2434.                   if (Number != Msg->Lowest ()) {
  2435.                      Number = Msg->Lowest ();
  2436.                      DisplayMessage (hwnd);
  2437.                   }
  2438.                }
  2439.                break;
  2440.             case 309:
  2441.                if (Msg != NULL) {
  2442.                   if (Number != Msg->Highest ()) {
  2443.                      Number = Msg->Highest ();
  2444.                      DisplayMessage (hwnd);
  2445.                   }
  2446.                }
  2447.                break;
  2448.  
  2449. #if defined(__POINT__)
  2450.             case 401: {
  2451.                class CHardwareDlg *Dlg;
  2452.  
  2453.                if ((Dlg = new CHardwareDlg (hwnd)) != NULL) {
  2454.                   if (Dlg->DoModal () == TRUE)
  2455.                      Cfg->Save ();
  2456.                   delete Dlg;
  2457.                }
  2458.                break;
  2459.             }
  2460.             case 402: {
  2461.                class CCommandsDlg *Dlg;
  2462.  
  2463.                if ((Dlg = new CCommandsDlg (hwnd)) != NULL) {
  2464.                   if (Dlg->DoModal () == TRUE)
  2465.                      Cfg->Save ();
  2466.                   delete Dlg;
  2467.                }
  2468.                break;
  2469.             }
  2470.             case 403: {
  2471.                class CSiteInfoDlg *Dlg;
  2472.  
  2473.                if ((Dlg = new CSiteInfoDlg (hwnd)) != NULL) {
  2474.                   if (Dlg->DoModal () == TRUE)
  2475.                      Cfg->Save ();
  2476.                   delete Dlg;
  2477.                }
  2478.                break;
  2479.             }
  2480.             case 404: {
  2481.                class CMessageDlg *Dlg;
  2482.  
  2483.                if ((Dlg = new CMessageDlg (hwnd)) != NULL) {
  2484.                   Dlg->DoModal ();
  2485.                   delete Dlg;
  2486.                }
  2487.                break;
  2488.             }
  2489.             case 406: {
  2490.                class CInternetDlg *Dlg;
  2491.  
  2492.                if ((Dlg = new CInternetDlg (hwnd)) != NULL) {
  2493.                   Dlg->DoModal ();
  2494.                   delete Dlg;
  2495.                }
  2496.                break;
  2497.             }
  2498.             case 407: {
  2499.                class CNodesDlg *Dlg;
  2500.  
  2501.                if ((Dlg = new CNodesDlg (hwnd)) != NULL) {
  2502.                   Dlg->DoModal ();
  2503.                   delete Dlg;
  2504.                }
  2505.                break;
  2506.             }
  2507. #endif
  2508.             case 905: {
  2509.                class CProductDlg *Dlg;
  2510.  
  2511.                if ((Dlg = new CProductDlg (hwnd)) != NULL) {
  2512.                   Dlg->DoModal ();
  2513.                   delete Dlg;
  2514.                }
  2515.                break;
  2516.             }
  2517.  
  2518.             case 1201:
  2519.                if (Msg->Previous (Number) == TRUE)
  2520.                   DisplayMessage (hwnd);
  2521.                else {
  2522. #if defined(__OS2__)
  2523.                   WinAlarm (HWND_DESKTOP, WA_ERROR);
  2524. #endif
  2525.                   ChangeArea (hwnd);
  2526.                }
  2527.                break;
  2528.             case 1202:
  2529.                if (Msg->Next (Number) == TRUE)
  2530.                   DisplayMessage (hwnd);
  2531.                else {
  2532. #if defined(__OS2__)
  2533.                   WinAlarm (HWND_DESKTOP, WA_ERROR);
  2534. #endif
  2535.                   ChangeArea (hwnd);
  2536.                }
  2537.                break;
  2538.             case 1203:
  2539.                EditMessage (hwnd, TRUE, TRUE);
  2540.                break;
  2541.             case 1204: {
  2542.                class CMsgListDlg *Dlg;
  2543.  
  2544.                if ((Dlg = new CMsgListDlg (hwnd)) != NULL) {
  2545.                   Dlg->OldNumber = Number;
  2546.                   Dlg->Msg = Msg;
  2547.                   if (Dlg->DoModal () == TRUE) {
  2548.                      Number = Dlg->NewNumber;
  2549.                      DisplayMessage (hwnd);
  2550.                   }
  2551.                   delete Dlg;
  2552.                }
  2553.                break;
  2554.             }
  2555.  
  2556.             case 1205:     // Enter new message
  2557.                EditMessage (hwnd, FALSE, FALSE);
  2558.                break;
  2559.  
  2560.             case 1206:     // Message Areas List
  2561.                ChangeArea (hwnd);
  2562.                break;
  2563.  
  2564.             case 1207:        // Delete
  2565. #if defined(__OS2__)
  2566.                if ((int)WinMessageBox (HWND_DESKTOP, hwnd, "Do you want to delete this message ?", "Delete", 0, MB_YESNO|MB_MOVEABLE) == MBID_YES) {
  2567. #elif defined(__NT__)
  2568.                if (MessageBox (hwnd, "Do you want to delete this message ?", "Delete", MB_YESNO) == IDYES) {
  2569. #endif
  2570.                   Msg->Delete (Number);
  2571.  
  2572.                   if (Msg->Next (Number) == TRUE)
  2573.                      DisplayMessage (hwnd);
  2574.                   else if (Msg->Previous (Number) == TRUE)
  2575.                      DisplayMessage (hwnd);
  2576.                   else {
  2577.                      Msg->New ();
  2578.                      DisplayMessage (hwnd);
  2579.                   }
  2580.                }
  2581.                break;
  2582.  
  2583.             case 1208:
  2584.                DisplayMessage (hwnd);
  2585.                break;
  2586.  
  2587.             case 1209:
  2588.                SaveMessage (hwnd);
  2589.                break;
  2590.  
  2591.             case 1300:
  2592.                ShowKludges = (ShowKludges == TRUE) ? FALSE : TRUE;
  2593.                DisplayMessage (hwnd);
  2594.                break;
  2595.  
  2596.             case 1301:
  2597.                EditMessage (hwnd, TRUE, FALSE);
  2598.                break;
  2599.  
  2600.             case 1302:
  2601.                if (Msg->Original != 0L) {
  2602.                   Number = Msg->Original;
  2603.                   DisplayMessage (hwnd);
  2604.                }
  2605. #if defined(__OS2__)
  2606.                else
  2607.                   WinAlarm (HWND_DESKTOP, WA_ERROR);
  2608. #endif
  2609.                break;
  2610.  
  2611.             case 1303:
  2612.                if (Msg->Reply != 0L) {
  2613.                   Number = Msg->Reply;
  2614.                   DisplayMessage (hwnd);
  2615.                }
  2616. #if defined(__OS2__)
  2617.                else
  2618.                   WinAlarm (HWND_DESKTOP, WA_ERROR);
  2619. #endif
  2620.                break;
  2621.          }
  2622.          break;
  2623.  
  2624. #if defined(__OS2__)
  2625.       case WM_ERASEBACKGROUND: {
  2626.          POINTL pt;
  2627.          RECTL *rc = (RECTL *)mp2;
  2628.  
  2629.          pt.x = rc->xLeft;
  2630.          pt.y = rc->yTop;
  2631.          GpiMove ((HPS)mp1, &pt);
  2632.          pt.x = rc->xRight;
  2633.          pt.y = rc->yBottom;
  2634.          GpiSetColor ((HPS)mp1, CLR_PALEGRAY);
  2635.          GpiBox ((HPS)mp1, DRO_FILL, &pt, 0L, 0L);
  2636.          return ((MRESULT)FALSE);
  2637.       }
  2638. #endif
  2639.  
  2640. #if defined(__OS2__)
  2641.       case WM_CONTROL:
  2642.          break;
  2643. #endif
  2644.  
  2645. #if defined(__OS2__)
  2646.       case WM_CLOSE: {
  2647. #elif defined(__NT__)
  2648.       case WM_DESTROY: {
  2649. #endif
  2650.          class TUser *User;
  2651.  
  2652.          if ((User = new TUser (Cfg->UserFile)) != NULL) {
  2653.             if (User->GetData (Cfg->SysopName) == TRUE) {
  2654.                if (User->MsgTag->Read (AreaKey) == TRUE) {
  2655.                   User->MsgTag->LastRead = Number;
  2656.                   User->MsgTag->Update ();
  2657.                }
  2658.                else {
  2659.                   User->MsgTag->New ();
  2660.                   strcpy (User->MsgTag->Area, AreaKey);
  2661.                   User->MsgTag->Tagged = FALSE;
  2662.                   User->MsgTag->LastRead = Number;
  2663.                   User->MsgTag->Add ();
  2664.                }
  2665.                User->Update ();
  2666.             }
  2667.             delete User;
  2668.          }
  2669.  
  2670.          if (Scan != NULL) {
  2671.             delete Scan;
  2672.             Scan = NULL;
  2673.          }
  2674.  
  2675. #if defined(__NT__)
  2676.          PostQuitMessage (0);
  2677. #endif
  2678.          break;
  2679.       }
  2680.    }
  2681.  
  2682. #if defined(__OS2__)
  2683.    return (WinDefWindowProc (hwnd, msg, mp1, mp2));
  2684. #elif defined(__NT__)
  2685.    return (DefWindowProc (hwnd, msg, wParam, lParam));
  2686. #endif
  2687. }
  2688.  
  2689. #if defined(__OS2__)
  2690. void main (int argc, char *argv[])
  2691. {
  2692.    int i, x, y, dx, dy;
  2693.    CHAR Title[128], *Config, *Channel;
  2694.    HMQ hmq;
  2695.    QMSG qmsg;
  2696.    FRAMECDATA fd;
  2697.    RECTL rc;
  2698.  
  2699.    Config = Channel = NULL;
  2700.  
  2701.    for (i = 1; i < argc; i++) {
  2702.       if (Config == NULL)
  2703.          Config = argv[i];
  2704.       else if (Channel == NULL)
  2705.          Channel = argv[i];
  2706.    }
  2707.  
  2708.    if (Config == NULL)
  2709.       Config = getenv ("LORA_CONFIG");
  2710.    if (Channel == NULL)
  2711.       Channel = getenv ("LORA_CHANNEL");
  2712.  
  2713.    if ((Cfg = new TConfig) != NULL) {
  2714.       Cfg->TaskNumber = 1;
  2715.       if (Cfg->Load (Config, Channel) == FALSE)
  2716.          Cfg->Default ();
  2717.    }
  2718.  
  2719.    if ((hab = WinInitialize (0)) != 0) {
  2720.       if ((hmq = WinCreateMsgQueue (hab, 0)) != 0) {
  2721. #if defined(__POINT__)
  2722.          WinRegisterClass (hab, "POINT_WINDOW", ReaderWinProc, CS_CLIPCHILDREN|CS_SIZEREDRAW|CS_MOVENOTIFY, 0);
  2723. #else
  2724.          WinRegisterClass (hab, "READER_WINDOW", ReaderWinProc, CS_CLIPCHILDREN|CS_SIZEREDRAW|CS_MOVENOTIFY, 0);
  2725. #endif
  2726.          fd.cb = sizeof (fd);
  2727.          fd.flCreateFlags = FCF_TASKLIST|FCF_TITLEBAR|FCF_SYSMENU|FCF_MINMAX|FCF_SIZEBORDER|FCF_NOBYTEALIGN|FCF_MENU;
  2728.          fd.hmodResources = NULL;
  2729.          fd.idResources = 257;
  2730.  
  2731.          if ((hwndReaderFrame = WinCreateWindow (HWND_DESKTOP, WC_FRAME, NULL, 0, 0, 0, 0, 0, NULL, HWND_TOP, fd.idResources, &fd, NULL)) != NULLHANDLE)
  2732. #if defined(__POINT__)
  2733.             hwndReaderClient = WinCreateWindow (hwndReaderFrame, "POINT_WINDOW", NULL, 0, 0, 0, 10, 10, hwndReaderFrame, HWND_BOTTOM, FID_CLIENT, NULL, NULL);
  2734. #else
  2735.             hwndReaderClient = WinCreateWindow (hwndReaderFrame, "READER_WINDOW", NULL, 0, 0, 0, 10, 10, hwndReaderFrame, HWND_BOTTOM, FID_CLIENT, NULL, NULL);
  2736. #endif
  2737.  
  2738.          if (hwndReaderFrame != NULLHANDLE && hwndReaderClient != NULLHANDLE) {
  2739. #if defined(__POINT__)
  2740.             sprintf (Title, "%s v%s - %s", NAME, VERSION, "NetMail");
  2741. #else
  2742.             sprintf (Title, "%s Message Reader v%s - %s", NAME, VERSION, "NetMail");
  2743. #endif
  2744.             WinSetWindowText (hwndReaderFrame, Title);
  2745.  
  2746.             WinQueryWindowRect (HWND_DESKTOP, &rc);
  2747.             dx = 690;
  2748.             if ((rc.xRight - rc.xLeft) < dx)
  2749.                dx = rc.xRight - rc.xLeft;
  2750.             dy = 490;
  2751.             if ((rc.yTop - rc.yBottom) < dy)
  2752.                dy = rc.yTop - rc.yBottom;
  2753.  
  2754.             x = ((rc.xRight - rc.xLeft) - dx) / 2;
  2755.             y = ((rc.yTop - rc.yBottom) - dy) / 2;
  2756.  
  2757.             WinSetWindowPos (hwndReaderFrame, NULLHANDLE, x, y, dx, dy, SWP_SIZE|SWP_MOVE|SWP_SHOW|SWP_ACTIVATE);
  2758.  
  2759.             hAccReader = WinLoadAccelTable (hab, NULLHANDLE, 1);
  2760.             hAccEditor = NULLHANDLE;
  2761.             hAccel = hAccReader;
  2762.  
  2763.             WinPostMsg (hwndReaderClient, WM_USER, 0L, 0L);
  2764.             WinPostMsg (hwndReaderClient, WM_COMMAND, MPFROMSHORT (1206), 0L);
  2765.  
  2766.             while (WinGetMsg (hab, &qmsg, NULLHANDLE, 0, 0)) {
  2767.                if (hAccel != NULLHANDLE)
  2768.                   WinTranslateAccel (hab, hwndReaderClient, hAccel, &qmsg);
  2769.                WinDispatchMsg (hab, &qmsg);
  2770.             }
  2771.  
  2772.             if (hAccReader != NULLHANDLE)
  2773.                WinDestroyAccelTable (hAccReader);
  2774.             if (hAccEditor != NULLHANDLE)
  2775.                WinDestroyAccelTable (hAccEditor);
  2776.  
  2777.             WinDestroyWindow (hwndReaderFrame);
  2778.          }
  2779.  
  2780.          WinDestroyMsgQueue (hmq);
  2781.       }
  2782.  
  2783.       WinTerminate (hab);
  2784.    }
  2785. }
  2786. #elif defined(__NT__)
  2787. int PASCAL WinMain (HINSTANCE hinstCurrent, HINSTANCE hinstPrevious, LPSTR lpszCmdLine, int nCmdShow)
  2788. {
  2789.    int x, y, dx, dy;
  2790.    CHAR Title[128], *Config, *Channel, *p;
  2791.    MSG msg;
  2792.    WNDCLASS wc;
  2793.    RECT rc;
  2794.  
  2795.    Config = Channel = NULL;
  2796.  
  2797.    strcpy (Title, lpszCmdLine);
  2798.    if ((p = strtok (Title, " ")) != NULL)
  2799.       do {
  2800.          if (Config == NULL)
  2801.             Config = p;
  2802.          else if (Channel == NULL)
  2803.             Channel = p;
  2804.       } while ((p = strtok (NULL, " ")) != NULL);
  2805.  
  2806.    if (Config == NULL)
  2807.       Config = getenv ("LORA_CONFIG");
  2808.    if (Channel == NULL)
  2809.       Channel = getenv ("LORA_CHANNEL");
  2810.  
  2811.    if ((Cfg = new TConfig) != NULL) {
  2812.       if (Cfg->Load (Config, Channel) == FALSE)
  2813.          Cfg->Default ();
  2814.    }
  2815.  
  2816.    if (hinstPrevious == NULL) {
  2817.       wc.style         = 0;
  2818.       wc.lpfnWndProc   = ReaderWinProc;
  2819.       wc.cbClsExtra    = 0;
  2820.       wc.cbWndExtra    = 0;
  2821.       wc.hInstance     = hinstCurrent;
  2822.       wc.hIcon         = LoadIcon (NULL, MAKEINTRESOURCE (1));;
  2823.       wc.hCursor       = LoadCursor (NULL, IDC_ARROW);
  2824.       wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
  2825.       wc.lpszMenuName  = "MENU_1";
  2826. #if defined(__POINT__)
  2827.       wc.lpszClassName = "POINT_WINDOW";
  2828. #else
  2829.       wc.lpszClassName = "READER_WINDOW";
  2830. #endif
  2831.  
  2832.       if (!RegisterClass (&wc))
  2833.          return (FALSE);
  2834.    }
  2835.  
  2836.    hinst = hinstCurrent;
  2837.    msg.wParam = FALSE;
  2838.  
  2839.    hAccReader = LoadAccelerators (hinstCurrent, "ACCELERATOR_1");
  2840.    hAccEditor = LoadAccelerators (hinstCurrent, "ACCELERATOR_2");
  2841.    hAccel = hAccReader;
  2842.  
  2843.    GetClientRect (GetDesktopWindow (), &rc);
  2844.    dx = 690;
  2845.    if ((rc.right - rc.left) < dx)
  2846.       dx = rc.right - rc.left;
  2847.    dy = 490;
  2848.    if ((rc.bottom - rc.top) < dy)
  2849.       dy = rc.bottom - rc.top;
  2850.  
  2851.    x = ((rc.right - rc.left) - dx) / 2;
  2852.    y = ((rc.bottom - rc.top) - dy) / 2;
  2853.  
  2854. #if defined(__POINT__)
  2855.    sprintf (Title, "%s v%s - %s", NAME, VERSION, "NetMail");
  2856. #else
  2857.    sprintf (Title, "%s Mail Reader v%s - %s", NAME, VERSION, "NetMail");
  2858. #endif
  2859. #if defined(__POINT__)
  2860.    if ((hwndReaderClient = CreateWindowEx (WS_EX_OVERLAPPEDWINDOW, "POINT_WINDOW", Title, WS_OVERLAPPEDWINDOW, x, y, dx, dy, NULL, NULL, hinstCurrent, NULL)) != NULL) {
  2861. #else
  2862.    if ((hwndReaderClient = CreateWindowEx (WS_EX_OVERLAPPEDWINDOW, "READER_WINDOW", Title, WS_OVERLAPPEDWINDOW, x, y, dx, dy, NULL, NULL, hinstCurrent, NULL)) != NULL) {
  2863. #endif
  2864.       ShowWindow (hwndReaderClient, nCmdShow);
  2865.  
  2866.       PostMessage (hwndReaderClient, WM_USER, 0, 0L);
  2867.       PostMessage (hwndReaderClient, WM_COMMAND, 1206, 0L);
  2868.  
  2869.       while (GetMessage (&msg, NULL, 0, 0)) {
  2870.          if (!TranslateAccelerator (hwndReaderClient, hAccel, &msg)) {
  2871.             TranslateMessage (&msg);
  2872.             DispatchMessage (&msg);
  2873.          }
  2874.       }
  2875.    }
  2876.  
  2877.    if (Cfg != NULL)
  2878.       delete Cfg;
  2879.  
  2880.    return ((int)msg.wParam);
  2881. }
  2882. #endif
  2883.  
  2884.