Ejemplo n.º 1
0
//---------------------------------------------------------------------------
TCustomEdit * __fastcall TAuthenticateForm::GenerateEdit(int Current, bool Echo)
{
  TCustomEdit * Result = (Echo ? static_cast<TCustomEdit *>(new TEdit(this)) :
    static_cast<TCustomEdit *>(new TPasswordEdit(this)));
  Result->Parent = FPromptParent;

  Result->Anchors = TAnchors() << akLeft << akTop << akRight;
  Result->Top = Current;
  Result->Left = FPromptLeft;
  Result->Width = FPromptParent->ClientWidth - FPromptLeft - FPromptRight;

  return Result;
}
Ejemplo n.º 2
0
//---------------------------------------------------------------------------
TLabel * __fastcall TAuthenticateForm::GenerateLabel(int Current, UnicodeString Caption)
{
  TLabel * Result = new TLabel(this);
  Result->Parent = FPromptParent;

  Result->Anchors = TAnchors() << akLeft << akTop << akRight;
  Result->WordWrap = true;
  Result->AutoSize = false;

  Result->Top = Current;
  Result->Left = FPromptLeft;
  Result->Caption = Caption;
  int Width = FPromptParent->ClientWidth - FPromptLeft - FPromptRight;
  Result->Width = Width;
  Result->AutoSize = true;

  return Result;
}
Ejemplo n.º 3
0
void TfrmBaseConverter::InitializeSettings(void)
{
    // Form settings
    this->Width  = DEFAULT_WIDTH;
    this->Height = DEFAULT_HEIGHT;

    // Title bar
    this->TitleBar->IconID    = comn::BI_BASE_CONVERTER;
    this->TitleBar->ShowClose = true;
    this->TitleBar->ShowIcon  = true;

    // Menus
    this->FFromBaseContextMenu = new TEditContextMenu(this);
    this->FToBaseContextMenu   = new TEditContextMenu(this);
    this->MenuExtender->HookMenu(this->FFromBaseContextMenu);
    this->MenuExtender->HookMenu(this->FToBaseContextMenu);

    // Set the default position the form
    this->EnforceMinimumSize = false;
    this->EnforceMaximumSize = true;
    this->Left = (Screen->WorkAreaWidth / 2) - (this->Width / 2);
    this->Top  = (Screen->WorkAreaHeight / 2) - (this->Height / 2);

    // Panels
    this->pnlBaseFrom->BorderStyle  = Forms::bsNone;
    this->pnlBaseFrom->Caption      = "";
    this->pnlBaseFrom->Color        = this->Color;
    this->pnlBaseFrom->BorderWidth  = 0;

    this->pnlBaseTo->BorderStyle    = Forms::bsNone;
    this->pnlBaseTo->Caption        = "";
    this->pnlBaseTo->Color          = this->Color;
    this->pnlBaseTo->BorderWidth    = 0;

    this->pnlLeft->BorderStyle      = Forms::bsNone;
    this->pnlLeft->Caption          = "";
    this->pnlLeft->Color            = this->Color;
    this->pnlLeft->BorderWidth      = 3;
    this->pnlLeft->Width            = (this->Width / 2) - DEFAULT_SPLITTER_SIZE;

    this->pnlRight->BorderStyle     = Forms::bsNone;
    this->pnlRight->Caption         = "";
    this->pnlRight->Color           = this->Color;
    this->pnlRight->BorderWidth     = 3;

    this->pnlBottom->BorderStyle    = Forms::bsNone;
    this->pnlBottom->Caption        = "";
    this->pnlBottom->Color          = (TColor)this->Base->DarkenColor(this->Color, 5);
    this->pnlBottom->BorderWidth    = 0;

    // Splitter
    this->ctlSplitter->Width        = DEFAULT_SPLITTER_SIZE;
    this->ctlSplitter->MinSize      = 0;
    this->ctlSplitter->ResizeStyle  = Extctrls::rsUpdate;

    // Text Controls
    this->txtBaseFrom->BevelInner   = Controls::bvNone;
    this->txtBaseFrom->BevelKind    = Controls::bkFlat;
    this->txtBaseFrom->BevelOuter   = Controls::bvLowered;
    this->txtBaseFrom->BorderStyle  = Forms::bsNone;
    this->txtBaseFrom->ReadOnly     = false;
    this->txtBaseFrom->ScrollBars   = Stdctrls::ssVertical;
    this->txtBaseFrom->TabStop      = true;
    this->txtBaseFrom->Text         = "";
    this->txtBaseFrom->WantReturns  = false;
    this->txtBaseFrom->WantTabs     = false;
    this->txtBaseFrom->WordWrap     = true;
    this->txtBaseFrom->Font->Name   = DEFAULT_FONT_NAME;
    this->txtBaseFrom->Font->Size   = DEFAULT_FONT_SIZE + 1;

    this->txtBaseTo->Color          = this->Color;
    this->txtBaseTo->BevelInner     = Controls::bvNone;
    this->txtBaseTo->BevelKind      = Controls::bkFlat;
    this->txtBaseTo->BevelOuter     = Controls::bvLowered;
    this->txtBaseTo->BorderStyle    = Forms::bsNone;
    this->txtBaseTo->ReadOnly       = true;
    this->txtBaseTo->ScrollBars     = Stdctrls::ssVertical;
    this->txtBaseTo->TabStop        = true;
    this->txtBaseTo->Text           = "";
    this->txtBaseTo->WantReturns    = false;
    this->txtBaseTo->WantTabs       = false;
    this->txtBaseTo->WordWrap       = true;
    this->txtBaseTo->Font->Name     = DEFAULT_FONT_NAME;
    this->txtBaseTo->Font->Size     = DEFAULT_FONT_SIZE + 1;

    // Comboboxes
    this->cmbBaseFrom->AutoComplete     = false;
    this->cmbBaseFrom->AutoDropDown     = false;
    this->cmbBaseFrom->BevelInner       = Controls::bvNone;
    this->cmbBaseFrom->BevelKind        = Controls::bkNone;
    this->cmbBaseFrom->BevelOuter       = Controls::bvNone;
    this->cmbBaseFrom->Font->Name       = DEFAULT_FONT_NAME;
    this->cmbBaseFrom->Font->Size       = DEFAULT_FONT_SIZE;
    this->cmbBaseFrom->Sorted           = false;
    this->cmbBaseFrom->Style            = Stdctrls::csDropDown;
    this->cmbBaseFrom->TabStop          = true;
    this->cmbBaseFrom->Text             = "";
    this->cmbBaseFrom->Parent->Height   = this->cmbBaseFrom->Height + 10;
    this->cmbBaseFrom->Left             = this->txtBaseFrom->Left;
    this->cmbBaseFrom->Top              = 3;
    this->cmbBaseFrom->Width            = this->txtBaseFrom->Width - 3;
    this->cmbBaseFrom->Anchors          = TAnchors() << Controls::akLeft << Controls::akTop << Controls::akRight << Controls::akBottom;
    this->cmbBaseFrom->Clear();

    this->cmbBaseTo->AutoComplete       = false;
    this->cmbBaseTo->AutoDropDown       = false;
    this->cmbBaseTo->BevelInner         = Controls::bvNone;
    this->cmbBaseTo->BevelKind          = Controls::bkNone;
    this->cmbBaseTo->BevelOuter         = Controls::bvNone;
    this->cmbBaseTo->Font->Name         = DEFAULT_FONT_NAME;
    this->cmbBaseTo->Font->Size         = DEFAULT_FONT_SIZE;
    this->cmbBaseTo->Sorted             = false;
    this->cmbBaseTo->Style              = Stdctrls::csDropDown;
    this->cmbBaseTo->TabStop            = true;
    this->cmbBaseTo->Text               = "";
    this->cmbBaseTo->Parent->Height     = this->cmbBaseTo->Height + 10;
    this->cmbBaseTo->Left               = this->txtBaseTo->Left;
    this->cmbBaseTo->Top                = 3;
    this->cmbBaseTo->Width              = this->txtBaseTo->Width;
    this->cmbBaseTo->Anchors            = TAnchors() << Controls::akLeft << Controls::akTop << Controls::akRight << Controls::akBottom;
    this->cmbBaseTo->Clear();

    for (int iBaseItem = 2; iBaseItem <= 36; iBaseItem++)
    {
        this->cmbBaseFrom->AddItem(iBaseItem, NULL);
        this->cmbBaseTo->AddItem(iBaseItem, NULL);
    }

    this->cmbBaseFrom->Text = this->Base->GetSetting(basc::ST_BASE_CONVERTER_FROM_BASE).c_str();
    this->cmbBaseTo->Text   = this->Base->GetSetting(basc::ST_BASE_CONVERTER_TO_BASE).c_str();

    // Assign Menus
    this->cmbBaseFrom->PopupMenu = this->FFromBaseContextMenu;
    this->txtBaseFrom->PopupMenu = this->FFromBaseContextMenu;
    this->cmbBaseTo->PopupMenu   = this->FToBaseContextMenu;
    this->txtBaseTo->PopupMenu   = this->FToBaseContextMenu;

    // Size grip
    this->ctlSizeGrip->Left    = this->ctlSizeGrip->Parent->Width  - this->ctlSizeGrip->Width;
    this->ctlSizeGrip->Top     = this->ctlSizeGrip->Parent->Height - this->ctlSizeGrip->Height;
    this->ctlSizeGrip->Anchors = TAnchors() << Controls::akRight << Controls::akBottom;

    // Close button
    this->cmdClose->Left    = (this->ctlSizeGrip->Left - 2) - this->cmdClose->Width;
    this->cmdClose->Anchors = TAnchors() << Controls::akRight << Controls::akBottom;

    // Fix the control's flicker
    this->pnlBaseFrom->DoubleBuffered   = true;
    this->pnlBaseTo->DoubleBuffered     = true;
    this->pnlLeft->DoubleBuffered       = true;
    this->pnlRight->DoubleBuffered      = true;
    this->pnlBottom->DoubleBuffered     = true;
    this->cmbBaseFrom->DoubleBuffered   = true;
    this->cmbBaseTo->DoubleBuffered     = true;
    this->txtBaseFrom->DoubleBuffered   = true;
    this->txtBaseTo->DoubleBuffered     = true;

    this->pnlBaseFrom->ControlStyle     = this->pnlBaseFrom->ControlStyle << Controls::csOpaque;
    this->pnlBaseTo->ControlStyle       = this->pnlBaseTo->ControlStyle << Controls::csOpaque;
    this->pnlLeft->ControlStyle         = this->pnlLeft->ControlStyle << Controls::csOpaque;
    this->pnlRight->ControlStyle        = this->pnlRight->ControlStyle << Controls::csOpaque;
    this->pnlBottom->ControlStyle       = this->pnlBottom->ControlStyle << Controls::csOpaque;
    this->cmbBaseFrom->ControlStyle     = this->pnlRight->ControlStyle << Controls::csOpaque;
    this->cmbBaseTo->ControlStyle       = this->pnlBottom->ControlStyle << Controls::csOpaque;
    this->txtBaseFrom->ControlStyle     = this->pnlRight->ControlStyle << Controls::csOpaque;
    this->txtBaseTo->ControlStyle       = this->pnlBottom->ControlStyle << Controls::csOpaque;

    // Complete settings
    this->SetCaptions();
    this->LoadFormState();
    this->Resize();

    return;
}