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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
| //---------------------------------------------------------------------
#define ALPHA_VALUE 128
#define BORDER_WIDTH 3
#define MESSAGE_INNER_SPACE 5
#define BETWEEN_SPACE 5
//---------------------------------------------------------------------
/*****************************************************************************/
/************************ Constructor & Destructor ***********************/
/*****************************************************************************/
__fastcall Waiting_Screen::Waiting_Screen(TComponent* owner) : TCustomForm(owner, 1), waiting_screen(new TImage32((TComponent*) NULL)), layer_transparent(NULL), layer_message_box(NULL) {
OldCreateOrder = false;
OnClose = &form_close;
}
__fastcall Waiting_Screen::~Waiting_Screen() {
if (layer_transparent != NULL) {
layer_transparent->LayerCollection = NULL;
layer_transparent->Bitmap = NULL;
delete layer_transparent;
layer_transparent = NULL;
}
if (layer_message_box != NULL) {
layer_message_box->LayerCollection = NULL;
layer_message_box->Bitmap = NULL;
delete layer_message_box;
layer_message_box = NULL;
}
waiting_screen->Layers->Clear();
if (waiting_screen!= NULL) {
waiting_screen->Parent = NULL;
delete waiting_screen;
waiting_screen= NULL;
}
}
/*****************************************************************************/
/**************************** Life Management ****************************/
/*****************************************************************************/
void __fastcall Waiting_Screen::form_close(TObject*, TCloseAction& action) {
action = caHide;
}
/*****************************************************************************/
/**************************** Public Interface ***************************/
/*****************************************************************************/
void Waiting_Screen::prepare(TForm* window, UnicodeString message_01, UnicodeString message_02) {
if ((window == NULL) || (waiting_screen == NULL)) { return; }
waiting_screen->Bitmap->BeginUpdate();
// Screenshot
BitBlt(waiting_screen->Bitmap->Handle, 0, 0, Width, Height, GetDC(window->Handle), 0, 0, SRCCOPY);
// Message computations
waiting_screen->Bitmap->Font = Font;
waiting_screen->Canvas->Font = Font;
msg_01_size = waiting_screen->Bitmap->TextExtentW( message_01.w_str() );
msg_02_size = waiting_screen->Bitmap->TextExtentW( message_02.w_str() );
if (layer_transparent != NULL) {
layer_transparent->Bitmap->DrawMode = dmBlend;
layer_transparent->Bitmap->MasterAlpha = ALPHA_VALUE;
layer_transparent->Bitmap->Clear(clBlack32);
}
if (layer_message_box != NULL) {
layer_message_box->Bitmap->DrawMode = dmOpaque;
for(unsigned short step = 0; step < BORDER_WIDTH; ++step) {
layer_message_box->Bitmap->FrameRectS(step, step, (260 - step), (80 - step), 0x00814A00);
}
layer_message_box->Bitmap->FillRect(BORDER_WIDTH, BORDER_WIDTH, (260 - BORDER_WIDTH), (80 - BORDER_WIDTH), (TColor) 0x00F5F5F5);
layer_message_box->Bitmap->Font = Font;
layer_message_box->Bitmap->TextoutW(((0 + ((260 - 0 - msg_01_size.cx) / 2))), (0 + 15), message_01.w_str());
layer_message_box->Bitmap->TextoutW(((0 + ((260 - 0 - msg_02_size.cx) / 2))), (0 + 45), message_02.w_str());
}
waiting_screen->Bitmap->EndUpdate();
waiting_screen->Refresh();
}
void Waiting_Screen::setup(TForm* parent) {
if (parent == NULL) { return; }
Left = 0;
Top = 0;
BorderStyle = bsNone;
Height = parent->Height;
Width = parent->Width;
Color = (TColor) 0x00F5F5F5;
// TransparentColor = true;
DoubleBuffered = true;
Font->Charset = DEFAULT_CHARSET;
Font->Color = clBlack;
Font->Name = L"Tahoma";
Font->Size = 11;
PopupMode = pmExplicit;
if (waiting_screen == NULL) { waiting_screen = new TImage32((TComponent*) NULL); }
waiting_screen->AutoSize = false;
waiting_screen->BitmapAlign = baTopLeft;
waiting_screen->DoubleBuffered = true;
waiting_screen->Scale = 1;
waiting_screen->ScaleMode = smNormal;
waiting_screen->TabOrder = 0;
waiting_screen->Parent = this;
waiting_screen->Top = 0;
waiting_screen->Left = 0;
waiting_screen->Width = parent->Width;
waiting_screen->Height = parent->Height;
waiting_screen->SetupBitmap();
waiting_screen->Bitmap->ResamplerClassName = L"TNearestResampler";
if (layer_transparent == NULL) {
layer_transparent = new TBitmapLayer(waiting_screen->Layers);
}
layer_transparent->Location.Left = 0;
layer_transparent->Location.Top = 0;
layer_transparent->Location.Right = Width;
layer_transparent->Location.Bottom = Height;
layer_transparent->Scaled = 1.0;
layer_transparent->Visible = true;
layer_transparent->Bitmap->SetSize(Width, Height);
if (layer_message_box == NULL) {
layer_message_box = new TBitmapLayer(waiting_screen->Layers);
layer_message_box->Location.Left = ((Width - 260) / 2);
layer_message_box->Location.Top = ((Height - 80) / 2);
layer_message_box->Location.Right = (layer_message_box->Location.Left + 260);
layer_message_box->Location.Bottom = (layer_message_box->Location.Top + 80);
layer_message_box->Scaled = 1.0;
layer_message_box->Visible = true;
layer_message_box->Bitmap->SetSize(260, 80);
}
PopupMode = pmExplicit;
PopupParent = parent;
}
void Waiting_Screen::update_rect(TForm* window, unsigned int rect_left, unsigned int rect_top, unsigned int rect_width, unsigned int rect_height) {
waiting_screen->Bitmap->BeginUpdate();
BitBlt(waiting_screen->Bitmap->Handle, rect_left, rect_top, rect_width, rect_height, GetDC(window->Handle), rect_left, rect_top, SRCCOPY);
waiting_screen->Bitmap->EndUpdate();
waiting_screen->Refresh();
} |
Partager