home *** CD-ROM | disk | FTP | other *** search
/ .net 1999 December / netCD65.iso / pc / Software / Construc / V4.0 / _SETUP.1 / Prompt.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-16  |  3.0 KB  |  82 lines

  1. //---------------------------------------------------------------------------
  2. #include <vcl\vcl.h>
  3. #pragma hdrstop
  4.  
  5. #include "Prompt.h"
  6. //---------------------------------------------------------------------------
  7. #pragma resource "*.dfm"
  8. TMainForm *MainForm;
  9. //---------------------------------------------------------------------------
  10. __fastcall TMainForm::TMainForm(TComponent* Owner)
  11.     : TForm(Owner)
  12. {
  13. }
  14. //---------------------------------------------------------------------------
  15. void __fastcall TMainForm::PreviewClick(TObject *Sender)
  16. {
  17. if (Type->ItemIndex == 0) Application->MessageBox(Message->Text.c_str(), "Browser Name",MB_OKCANCEL+MB_ICONQUESTION+MB_DEFBUTTON1+MB_SYSTEMMODAL);
  18. else Application->MessageBox(Message->Text.c_str(), "Browser Name",MB_OK+MB_ICONEXCLAMATION+MB_DEFBUTTON1+MB_SYSTEMMODAL);
  19. }
  20. //---------------------------------------------------------------------------
  21. void __fastcall TMainForm::InsertClick(TObject *Sender)
  22. {
  23. if (Type->ItemIndex == 0) CodeString = "window.confirm('";
  24. else CodeString = "window.alert('";
  25.  
  26. AnsiString MessageString = "";
  27. int Line = 0;
  28. while (Line < Message->Lines->Count)
  29.       {
  30.       MessageString = MessageString + Message->Lines->Strings[Line];
  31.       if (Line < (Message->Lines->Count - 1)) MessageString = MessageString + "\\n";
  32.       Line++;
  33.       };
  34.  
  35. CodeString += MessageString + "')";
  36.  
  37. if (OnCancel->Enabled)
  38.    {
  39.    if (OnCancel->ItemIndex == 0) CodeString = "if (!" + CodeString + ") window.close();";
  40.    else if (OnCancel->ItemIndex == 1) CodeString = "if (!" + CodeString + ") window.history.back();";
  41.    else CodeString += ";";
  42.    }
  43. else CodeString += ";";
  44.  
  45. if (Code->Enabled && Code->ItemIndex == 0)
  46.    {
  47.    TSearchTypes Options;
  48.    RichEdit->SelStart = RichEdit->FindText("<body", 0, RichEdit->Text.Length(), Options);
  49.    RichEdit->SelLength = 5;
  50.    if (RichEdit->SelText.AnsiCompareIC("<body") == 0)
  51.       {
  52.       int Start = RichEdit->SelStart;
  53.       int End = RichEdit->FindText(">", Start, RichEdit->Text.Length(), Options);
  54.       RichEdit->SelStart = RichEdit->FindText("onload=\"", Start, End, Options);
  55.       RichEdit->SelLength = 8;
  56.       if (RichEdit->SelText.AnsiCompareIC("onload=\"") == 0)
  57.          {
  58.          RichEdit->SelLength = RichEdit->FindText("\"", RichEdit->SelStart + 8, End, Options) - RichEdit->SelStart;
  59.          }
  60.       else
  61.           {
  62.           RichEdit->SelStart = End;
  63.           RichEdit->SelLength = 0;
  64.           RichEdit->SelText = " ";
  65.           };
  66.       RichEdit->SelText = "onload=\"" + CodeString + "\"";
  67.       };
  68.    };
  69. }
  70. //---------------------------------------------------------------------------
  71. void __fastcall TMainForm::TypeClick(TObject *Sender)
  72. {
  73. OnCancel->Enabled = (Type->ItemIndex == 0);
  74. }
  75. //---------------------------------------------------------------------------
  76. void __fastcall TMainForm::MessageChange(TObject *Sender)
  77. {
  78. Insert->Enabled = (Message->Text != "");
  79. Preview->Enabled = Insert->Enabled;
  80. }
  81. //---------------------------------------------------------------------------
  82.