Форум: "Основная";
Текущий архив: 2002.09.05;
Скачать: [xml.tar.bz2];
ВнизMessageDlgEx Найти похожие ветки
← →
Schummi (2002-08-26 09:46) [0]Мастера, подскажите пожалуйста, есть ли что-нибудь наподобие MessageDlg, только с CheckBox внизу "Больше не показывать... ". Заранее благодарен!
← →
RV (2002-08-26 10:05) [1]сам сделай!
можть те еще компонентик типа TKernel или OSWizard нужен?
← →
Игорь Шевченко (2002-08-26 10:34) [2]Примерно так:
function hs_MessageDlgWithCheckBox (const MsgStr : String;
DlgType : TMsgDlgType;
var Checked : Boolean;
CheckBoxStr : String) : Integer;
const
CheckBoxOffset = 10; //Отступ CheckBox"а от краев формы и от кнопок
var CheckBox : TCheckBox;
AForm : TForm;
HeightInc, WidthInc : Integer; //Изменения ширины и высоты формы для
//вставки CheckBox"а
CheckBoxWidth : Integer; //Ширина CheckBox"а с надписью и отступами
TextRect : TRect;
AMsgButtons : TMsgDlgButtons;
AButton : TButton;
begin
AMsgButtons := [mbOk];
case DlgType of
mtConfirmation:
AMsgButtons := [mbYes, mbNo];
end;
AForm := CreateMessageDialog(MsgStr, DlgType, AMsgButtons);
with AForm do
try
Caption := Application.Title;
Position := poMainFormCenter;
//Создание CheckBox"а с флажком слева от надписи и установка его на форму
CheckBox := TCheckBox.Create(AForm);
CheckBox.Alignment := taRightJustify;
CheckBox.Parent := AForm;
CheckBox.Caption := CheckBoxStr;
//Определение ширины надписи на CheckBox"е. Поскольку Canvas CheckBox"а
//недоступна, ширина определяется по Canvas формы, а чтобы надпись была
//той же ширины, Font CheckBox"а приравнивается к Font формы.
CheckBox.Font.Assign(Font);
SetRect(TextRect, 0, 0, Screen.Width div 2, 0);
DrawText(Canvas.Handle, PChar(CheckBoxStr), Length(CheckBoxStr), TextRect,
DT_CALCRECT OR DT_EXPANDTABS OR DT_WORDBREAK);
//TextRect содержит размеры надписи для CheckBox"а.
//Я считаю, что CheckBox без надписи имеет ширину, равную высоте
//(установлено эмпирическим путем)
//Ширина CheckBox"а с отступами справа и слева.
CheckBoxWidth := TextRect.Right + CheckBoxOffset * 2 + CheckBox.Height;
//Изменение высоты формы
HeightInc := CheckBox.Height + CheckBoxOffset;
Height := Height + HeightInc;
//Если CheckBox с надписью получился шире формы, то форма должна стать
//шире, а кнопки выровнены по центру.
if (Width < CheckBoxWidth) then begin
WidthInc := (CheckBoxWidth - Width) DIV 2; //Для центрирования кнопок
Width := CheckBoxWidth;
end else
WidthInc := 0;
if (DlgType = mtConfirmation) then begin
AButton := FindComponent("Yes") as TButton;
AButton.Caption:=SMsgDlgYes;
end else
AButton := FindComponent("Ok") as TButton;
with AButton do begin
Top := Top + HeightInc;
//По первой кнопке спозиционировать CheckBox по высоте
CheckBox.Top := Top - CheckBox.Height - CheckBoxOffset;
Left := Left + WidthInc;
end;
if DlgType = mtConfirmation then
with (FindComponent("No") as TButton) do begin
Caption:=SMsgDlgNo;
Top := Top + HeightInc;
Left := Left + WidthInc;
end;
CheckBox.Width := Width - CheckBoxOffset;
CheckBox.Left := CheckBoxOffset;
Result := ShowModal;
Checked := CheckBox.Checked;
finally
Free;
end;
end;
← →
Schummi (2002-08-27 08:56) [3]Большое спасибо, Игорь Шевченко!
Страницы: 1 вся ветка
Форум: "Основная";
Текущий архив: 2002.09.05;
Скачать: [xml.tar.bz2];
Память: 0.45 MB
Время: 0.008 c