-
Notifications
You must be signed in to change notification settings - Fork 0
/
PromptForString.cpp
57 lines (48 loc) · 1.6 KB
/
PromptForString.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <RsUtil.h>
#include "PromptForString.h"
#include "Util.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFormPromptForString *FormPromptForString;
//---------------------------------------------------------------------------
bool PromptForString(const String &Prompt, String &Value)
{
std::auto_ptr<TFormPromptForString> Form = rsutil::CreateVclForm<TFormPromptForString>();
Form->Set(Prompt, Value);
if (Form->ShowModal() != mrOk)
return false;
Value = Form->GetValue();
return true;
}
//---------------------------------------------------------------------------
__fastcall TFormPromptForString::TFormPromptForString(TComponent* Owner)
: TForm(Owner)
, m_bFirstIdle(true)
{
}
//---------------------------------------------------------------------------
void TFormPromptForString::Set(const String &Prompt, const String &Value)
{
Caption = Prompt;
LabelPrompt->Caption = Prompt + L":";
EditValue->Text = Value;
}
//---------------------------------------------------------------------------
String TFormPromptForString::GetValue()
{
return EditValue->Text;
}
//---------------------------------------------------------------------------
void __fastcall TFormPromptForString::ApplicationEventsIdle(TObject *Sender, bool &Done)
{
if (m_bFirstIdle)
{
m_bFirstIdle = false;
EnsureOnScreen(this);
}
}
//---------------------------------------------------------------------------