0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

C++ Builder 10.2 Tokyo + Windows10 > Geometry > フォームサイズ設定ではまる > (Height, Width)でなく(ClientHeight, ClientWidth)で設定する

Last updated at Posted at 2019-07-21
動作環境
RAD Studio 10.2 Tokyo Update 3
Windows 10 v1903

概要

  • フォームのHeight, Widthを指定
    • => 期待していたサイズよりも小さい
  • フォームのClientHeight, ClientWidthを指定
    • => 期待していたサイズになる

実装

Unit1.cpp
//---------------------------------------------------------------------------

# include <vcl.h>
# pragma hdrstop

# include "Unit1.h"
//---------------------------------------------------------------------------
# pragma package(smart_init)
# pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
	Shape1->Width = 500;
	Shape1->Height = 500;

	this->Height = Shape1->Top + Shape1->Height + 10;
	this->Width = Shape1->Left + Shape1->Width + 10;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
	Shape1->Width = 500;
	Shape1->Height = 500;

	this->ClientHeight = Shape1->Top + Shape1->Height + 10;
	this->ClientWidth = Shape1->Left + Shape1->Width + 10;
}
//---------------------------------------------------------------------------

実行例

Height, Widthでの設定
2019-07-21_16h25_54.png

ClientHeight, ClientWidthでの設定
2019-07-21_16h26_07.png

備考

:thinking:

Windows 7 + XE4では(Height, Width)で問題なかったような。

関連

XE4 + Windows 7

XE4 + Windows 7でも同じ実装を試した。
同じ結果になった。

自分が勘違いしていたようだ。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?