![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Создание формы из консоли
leklerk © (2012-04-13 09:56:00)Добрый день! Создаю из консоли форму, на ней Label, но почему-то Label не показывается. Вот код:
uses
Windows,
Messages,
SysUtils,
Variants,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
DB,
ADODB,
Grids,
DBGrids,
ExtCtrls,
ActiveX,
StdCtrls;
var ADO1: TADODataSet;
FORM1: TForm;
LABEL1: TLabel;
begin
{ TODO -oUser -cConsole Main : Insert code here }
try
CoInitialize(nil);
ADO1 := TADODataSet.Create(nil);
with ADO1 do begin
ConnectionString:='Provider=SQLOLEDB.1;Integrated Security=SSPI;'+
'Persist Security Info=False;Initial Catalog=Work_pk;'+
'Data Source=PROG\SQLEXPRESS';
CommandType := cmdText;
CommandText := 'select * from Табель where Корректировка=1';
Open;
end;
if (not ADO1.IsEmpty) then begin
FORM1 := TForm.Create(nil);
with FORM1 do begin
Height := Screen.Height;
Width := Screen.Width;
end;
LABEL1 := TLabel.Create(FORM1);
with LABEL1 do begin
Caption := 'Hello,World!';
Left := 50;
Top := 50;
Font.Size := 15;
Font.Color := clRed;
AutoSize := True;
Visible := True;
end;
FORM1.ShowModal;
end;
finally
ADO1.Free();
LABEL1.Free();
FORM1.Free();
CoUninitialize;
end;
sniknik (2012-04-13 12:40:00) [1]> if FORM1 <> nil then FORM1.Free();
лишнее
procedure TObject.Free;
begin
if Self <> nil then
Destroy;
end;
и LABEL1 освобождать при существующем "хозяине" тоже лишнее.
toropoff (2012-04-13 12:34:00) [2]поставь хотя бы проверку
if FORM1 <> nil then FORM1.Free();
toropoff (2012-04-13 12:33:00) [3]а если запрос пустой, что ты освобождать будешь?
LABEL1.Free();
FORM1.Free();
leklerk (2012-04-13 10:17:00) [4]Спасибо большое!
Омлет (2012-04-13 10:05:00) [5]Label1.Parent := Form1;