本文整理汇总了C++中TForm::SetBounds方法的典型用法代码示例。如果您正苦于以下问题:C++ TForm::SetBounds方法的具体用法?C++ TForm::SetBounds怎么用?C++ TForm::SetBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TForm
的用法示例。
在下文中一共展示了TForm::SetBounds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//---------------------------------------------------------------------------
inline void __fastcall DoFormWindowProc(TCustomForm * Form, TWndMethod WndProc,
TMessage & Message)
{
if ((Message.Msg == WM_SYSCOMMAND) &&
(Message.WParam == SC_CONTEXTHELP))
{
InvokeHelp(Form->ActiveControl);
Message.Result = 1;
}
else if (Message.Msg == CM_SHOWINGCHANGED)
{
TForm * AForm = dynamic_cast<TForm *>(Form);
assert(AForm != NULL);
if ((Application->MainForm == Form) ||
// this particularly happens if error occurs while main
// window is being shown (e.g. non existent local directory when opening
// explorer)
((Application->MainForm != NULL) && !Application->MainForm->Visible))
{
if (Form->Showing)
{
SendMessage(Form->Handle, WM_SETICON, ICON_BIG, reinterpret_cast<long>(Application->Icon->Handle));
}
if (!Form->Showing)
{
// when closing main form, remember its monitor,
// so that the next form is shown on the same one
LastMonitor = Form->Monitor;
}
else if ((LastMonitor != NULL) && (LastMonitor != Form->Monitor) &&
Form->Showing)
{
// would actually always be poScreenCenter, see _SafeFormCreate
if ((AForm->Position == poMainFormCenter) ||
(AForm->Position == poOwnerFormCenter) ||
(AForm->Position == poScreenCenter))
{
// this would typically be an authentication dialog,
// but it may as well be an message box
// taken from TCustomForm::SetWindowToMonitor
AForm->SetBounds(LastMonitor->Left + ((LastMonitor->Width - AForm->Width) / 2),
LastMonitor->Top + ((LastMonitor->Height - AForm->Height) / 2),
AForm->Width, AForm->Height);
AForm->Position = poDesigned;
}
else if ((AForm->Position != poDesigned) &&
(AForm->Position != poDefaultPosOnly))
{
// we do not expect any other positioning
assert(false);
}
}
else
{
TForm * AForm = dynamic_cast<TForm *>(Form);
assert(AForm != NULL);
// otherwise it would not get centered
if ((AForm->Position == poMainFormCenter) ||
(AForm->Position == poOwnerFormCenter))
{
AForm->Position = poScreenCenter;
}
}
}
bool WasFormCenter =
(AForm->Position == poMainFormCenter) ||
(AForm->Position == poOwnerFormCenter);
WndProc(Message);
// Make sure dialogs are shown on-screen even if center of the main window
// is off-screen. Occurs e.g. if you move the main window so that
// only window title is visible above taksbar.
if (Form->Showing && WasFormCenter && (AForm->Position == poDesigned))
{
TRect Rect;
// Reading Form.Left/Form.Top instead here does not work, likely due to some
// bug, when querying TProgressForm opened from TEditorForm (reloading remote file)
GetWindowRect(Form->Handle, &Rect);
int Left = Rect.Left;
int Top = Rect.Top;
TRect WorkArea = AForm->Monitor->WorkareaRect;
if (Left + Rect.Width() > WorkArea.Right)
{
Left = WorkArea.Right - Rect.Width();
}
if (Left < WorkArea.Left)
{
Left = WorkArea.Left;
}
if (Top + Rect.Height() > WorkArea.Bottom)
{
Top = WorkArea.Bottom - Rect.Height();
}
if (Top < WorkArea.Top)
{
Top = WorkArea.Top;
//.........这里部分代码省略.........