Пятница, 25.09.2026, 21:33
Вы вошли как Гость | Группа "Гости"Приветствую Вас Гость | RSS
Форма входа
Меню сайта
Главная » FAQ [ Добавить вопрос ]

Программирование Delphi [91]
Вопрос-Ответ по программированию

В приведенном примере для преобразования RGB-цвета используются коэффициенты, принятые в телевидении:

 
             function RgbToGray(RGBColor : TColor) : TColor; 
             var 
               Gray : byte; 
             begin 
               Gray := Round((0.30 * GetRValue(RGBColor)) + 
                             (0.59 * GetGValue(RGBColor)) + 
                             (0.11 * GetBValue(RGBColor ))); 
               Result := RGB(Gray, Gray, Gray); 
             end; 
 
             procedure TForm1.FormCreate(Sender: TObject); 
             begin 
               Shape1.Brush.Color := RGB(255, 64, 64); 
               Shape2.Brush.Color := RgbToGray(Shape1.Brush.Color); 
             end;
Добавил: casperof

Установите свойство WindowState в Minimized. Создайте обработчик сообщения WM_QueryOpen.
Пример :

 
             {Place this code in the private section of the Form declaration} 
 
             procedure WMQueryOpen(VAR Msg : TWMQueryOpen); message WM_QUERYOPEN; 
 
             {Place this code in the Form implementation section} 
 
             procedure TForm1.WMQueryOpen(VAR Msg : TWMQueryOpen); 
             begin 
               Msg.Result := 0; 
             end; 
Добавил: casperof

Функция RegisterClass() обьявлена в модулях Classes и Windows unit. Чтобы вызвать функцию из модуля Windows просто добавте префикс "Windows."
Пример
:

 
             procedure TForm1.Button1Click(Sender: TObject); 
               wc : TWndClass; 
             begin 
               Windows.RegisterClass(wc) 
             end; 
 
Добавил: casperof

Нужно сообщить Windows, что ваша форма принимает файлы по drag & drop с помощью функции Shell API DragAcceptFiles.(в обработчике события form create) Затем нужно реагироавть на сообытия drag & drop чтобы принять файлы. (см. пример)

 
             unit Unit1; 
 
             interface 
 
             uses 
               Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, 
               Dialogs, StdCtrls; 
 
             type 
               TForm1 = class(TForm) 
                 Memo1: TMemo; 
                 procedure FormCreate(Sender: TObject); 
               private 
                 procedure WMDROPFILES(var Message: TWMDROPFILES); 
                   message WM_DROPFILES; 
                 { Private declarations } 
               public 
                 { Public declarations } 
               end; 
 
             var 
               Form1: TForm1; 
 
             implementation 
 
             {$R *.DFM} 
 
             uses ShellApi; 
 
             procedure TForm1.FormCreate(Sender: TObject); 
             begin 
              {Let Windows know we accept dropped files} 
               DragAcceptFiles(Form1.Handle, True); 
             end; 
 
             procedure TForm1.WMDROPFILES(var Message: TWMDROPFILES); 
             var 
               NumFiles : longint; 
               i : longint; 
               buffer : array[0..255] of char; 
             begin 
              {How many files are being dropped} 
               NumFiles := DragQueryFile(Message.Drop, 
                                         -1, 
                                         nil, 
                                         0); 
              {Accept the dropped files} 
               for i := 0 to (NumFiles - 1) do begin 
                 DragQueryFile(Message.Drop, 
                               i, 
                               @buffer, 
                               sizeof(buffer)); 
                 Form1.Memo1.Lines.Add(buffer); 
               end; 
             end; 
 
             end.
Добавил: casperof

В примере используется вызов Application.ProcessMessages для того, чтобы Windows обрабатывал сообщения во время цикла задержки.

 
             procedure Delay(ms : longint); 
             var 
               TheTime : LongInt; 
             begin 
               TheTime := GetTickCount + ms; 
 
               while GetTickCount < TheTime do 
                 Application.ProcessMessages; 
             end; 
 
             procedure TForm1.Button1Click(Sender: TObject); 
             begin 
               ShowMessage('Start Test'); 
               Delay(2000); 
               ShowMessage('End Test'); 
             end;
Добавил: casperof

1-5 6-10 ... 76-80 81-85 86-90 91-91
Наш опрос
Сколько вам лет
Всего ответов: 20
Статистика

Онлайн всего: 1
Гостей: 1
Пользователей: 0
Поиск