Вниз
Скачать: 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 вся ветка

Скачать: CL | DM;



Память: 0.46 MB
Время: 0.047 c
15-1328702657
Арт
2012-02-08 16:04
2013.03.22
Google кидок..


15-1331757006
Юрий
2012-03-15 00:30
2013.03.22
С днем рождения ! 15 марта 2012 четверг


15-1351816418
ЖЖ
2012-11-02 04:33
2013.03.22
Как постить в LiveJournal ?


2-1345735828
Dennis I. Komarov
2012-08-23 19:30
2013.03.22
TService + User SYSTEM + поток + ODBC = Источник данных не на...


10-1176745972
Neket
2007-04-16 21:52
2013.03.22
Быстрое заполнение Excel




   Наверх