⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 Delphi编程实效百例的随书程序 这是其中的界面操作部分
💻 PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, StdCtrls,math, jpeg;


type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    ComboBox1: TComboBox;
    Edit1: TEdit;
    Image1: TImage;
    procedure Edit1Change(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    procedure ListBox1DrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
implementation

{$R *.DFM}

procedure TForm1.Edit1Change(Sender: TObject);
var
 thepchar : array[0..79] of char;
 thestring : string;
 theindex: integer;
begin
  thestring := edit1.text;
  if thestring <> '' then
  begin
    strpcopy(thepchar,thestring);
    theindex := sendmessage(listbox1.handle,lb_selectstring,-1, longint(@thepchar));
    sendmessage(listbox1.handle,lb_settopindex, theindex,0);
  end
  else
  begin
    sendmessage(listbox1.handle,lb_setcursel,-1,0);
    sendmessage(listbox1.handle,lb_settopindex,0,0);
  end;
end;

procedure TForm1.ComboBox1Change(Sender: TObject);
var
  thepchar : array[0..79] of char;
  thestring : string;
  theindex: integer;
begin
 if combobox1.text <> '' then
 begin
   strpcopy(thepchar,combobox1.text);
   theindex := sendmessage(combobox1.handle,cb_selectstring,-1, longint(@thepchar));
   sendmessage(combobox1.handle,cb_settopindex, theindex,0);
 end
 else
 begin
   sendmessage(combobox1.handle,cb_setcursel,-1,0);
   sendmessage(combobox1.handle,cb_settopindex,0,0);
 end;
end;

procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
 begin
  With ( Control As TListBox ).Canvas Do
  Begin
    Case Index Of
      0:
      Begin
        Font.Color  := clBlue;
        Brush.Color := clYellow;
      End;
      1:
      Begin
        Font.Color  := clRed;
        Brush.Color := clLime;
      End;
      2:
      Begin
        Font.Color  := clGreen;
        Brush.Color := clFuchsia;
      End;
      3:
      begin
        font.color:=rgb(10,25,100);
        brush.color:=rgb(56,78,23);
      end;
      4:
      begin
        font.color:=rgb(100,20,40);
        brush.color:=rgb(1,200,1);
        end;
      5:
      begin
      font.color:=rgb(100,200,245);
      brush.color:=rgb(20,10,30);
      end;
      else
      font.color:=rgb(100,160,2);
      brush.color:=rgb(100,20,1);
    End;
    FillRect(Rect);
    TextOut(Rect.Left, Rect.Top, ( Control As TListBox ).Items[Index]);
end;
end;
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -