Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2013.03.22;
Скачать: CL | DM;

Вниз

Создание формы из консоли   Найти похожие ветки 

 
leklerk ©   (2012-04-13 09:56) [0]

Добрый день! Создаю из консоли форму, на ней 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;


 
Омлет ©   (2012-04-13 10:05) [1]

Label1.Parent := Form1;


 
leklerk ©   (2012-04-13 10:17) [2]

Спасибо большое!


 
toropoff   (2012-04-13 12:33) [3]

а если запрос пустой, что ты освобождать будешь?

LABEL1.Free();
FORM1.Free();


 
toropoff   (2012-04-13 12:34) [4]

поставь хотя бы проверку
if FORM1 <> nil then FORM1.Free();


 
sniknik ©   (2012-04-13 12:40) [5]

> if FORM1 <> nil then FORM1.Free();
лишнее
procedure TObject.Free;
begin
 if Self <> nil then
   Destroy;
end;

и LABEL1 освобождать при существующем "хозяине" тоже лишнее.



Страницы: 1 вся ветка

Текущий архив: 2013.03.22;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.051 c
15-1334595190
Cyberden
2012-04-16 20:53
2013.03.22
Помогите написать программу!


15-1350464720
AV
2012-10-17 13:05
2013.03.22
Подскажите запрос


15-1343334602
Юрий
2012-07-27 00:30
2013.03.22
С днем рождения ! 27 июля 2012 пятница


15-1328787124
Медвежонок Пятачок
2012-02-09 15:32
2013.03.22
о старом....


15-1336720167
alexdn
2012-05-11 11:09
2013.03.22
Что первое?