home *** CD-ROM | disk | FTP | other *** search
- unit FMain;
-
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, UPTImageCombo, UPTFrame;
-
- type
- TFrmMain = class(TForm)
- PTImageCombo1: TPTImageCombo;
- PTFrame1: TPTFrame;
- PTFrame4: TPTFrame;
- PTFrame2: TPTFrame;
- PTFrame3: TPTFrame;
- ImageList1: TImageList;
- procedure FormCreate(Sender: TObject);
- procedure PTImageCombo1SelEndOk(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- FrmMain: TFrmMain;
-
- implementation
-
- {$R *.DFM}
-
- function GetIcon( hInst: THandle; id, size: Integer; icon: TIcon ): TIcon;
- begin // Retrieve an icon from a given module instance
- icon.Handle := Windows.LoadImage( hInst, MAKEINTRESOURCE(id), IMAGE_ICON, size,size, 0 );
- result := icon;
- end;
-
-
- procedure TFrmMain.FormCreate(Sender: TObject);
- var i: TIcon;
- item: TPTImageComboItem;
- begin
- //-- Create image list and load 16x16 icons from resources
- i := TIcon.Create;
- try
- ImageList1.AddIcon( GetIcon(HInstance, 100, 16, i) );
- ImageList1.AddIcon( GetIcon(HInstance, 101, 16, i) );
- ImageList1.AddIcon( GetIcon(HInstance, 102, 16, i) );
- finally
- i.Free;
- end;
-
- //-- Fill the image combo with some data items, and associate a frame control with
- //-- each entry via the item.Data property.
- item := PTImageCombo1.AddItem( 'First Item', 0, 0 );
- item.Data := PTFrame1;
-
- item := PTImageCombo1.AddItem( 'Second Item', 1, 1 );
- item.Data := PTFrame2;
-
- item := PTImageCombo1.AddItem( 'Third Item', 2, 2 );
- item.Data := PTFrame3;
-
- item := PTImageCombo1.AddItem( 'Fourth Item', 1, 1 );
- item.Data := PTFrame4;
-
- //-- Start with something selected
- PTImageCombo1.ItemIndex := 0;
- end;
-
-
- { This event is called after a 'successful' selection by the user.
- * It is not called when the combo item is changed programatically.
- * It is not called if the user presses 'Esc' or moves to another control while the combo is dropped down.
- * It is not called as the user moves up and down with the arrow keys.
-
- * It IS called if the user drops down the list and selects an item with the mouse.
- * It IS called when the user presses the Enter key on a new item.
-
- This is how the comboboxes in Explorer and Internet Explorer behave.
-
- This event just toggles the color of the frame control associated with the newly selected item.
- }
- procedure TFrmMain.PTImageCombo1SelEndOk(Sender: TObject);
- var itemd: TPTFrame;
- begin
- itemd := TObject(PTImageCombo1.ImageComboItem[PTImageCombo1.ItemIndex].Data) as TPTFrame;
- if itemd.Tag=0 then
- begin
- itemd.Tag := 1;
- itemd.Color := clRed;
- end
- else
- begin
- itemd.Tag := 0;
- itemd.Color := clBtnFace;
- end;
- end;
-
-
-
-
- end.
-