Q&A
HOME
Tips & Tech
Q&A
Discuss
Download
자유게시판
홍보 / 광고
구인 / 구직
LOGIN
회원가입
컴포넌트 구합니다.
콤보 박스의 Item에 텍스트가 아닌 텍스트와 이미지가 들어가는
컴포넌트를 구합니다.
(Source포함이고요....)
아시는 분 있으면 알려주세요.. 꼭, 꼭, 꼭....
2
COMMENTS
글쎄요.
•
1999.05.10 23:16
영문으로 되 있는 데 참고하시는 데 그리 어려움이 없을 겁니다.
그럼 좋은 하루 되셔요.
//////////
TI: Inserting graphics in Owner Drawn ListBoxes and ComboBoxes
The ability to place graphics inside ListBoxes and ComboBoxes
can improve the look of your application and set your user
interface apart from the others.
Q: How do I stick graphics in a Listbox or ComboBox???
Here is an step-by-step example.....
1. Create a form.
2. Place a ComboBox and Listbox component on your form.
3. Change the Style property of the ComboBox component to
csOwnerDrawVariable and the Style property of the ListBox to
lbOwnerDrawVariable.
An Owner-Draw TListBox or TComboBox allows you to display
both objects (ex. graphics) and strings as the items. For
this example, we are adding both a graphic object and a
string.
4. Create 5 variables of type TBitmap in the Form's VAR
section.
5. Create a Procedure for the Form's OnCreate event.
6. Create a Procedure for the ComboBox's OnDraw Event.
7. Create a Procedure for the ComboBox's OnMeasureItem.
8. Freee the resources in the Form's OnClose Event.
{START OWNERDRW.PAS}
unit Ownerdrw;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
ComboBox1: TComboBox;
ListBox1: TListBox;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
procedure ComboBox1MeasureItem(Control: TWinControl; Index: Integer;
var Height: Integer);
procedure ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
procedure ListBox1MeasureItem(Control: TWinControl; Index: Integer;
var Height: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
TheBitmap1, TheBitmap2, TheBitmap3, TheBittmap4,
TheBitmap5 : TBitmap;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
TheBitmap1 := TBitmap.Create;
TheBitmap1.LoadFromFile('C:delphiimagesbuttonsglobe.bmp');
TheBitmap2 := TBitmap.Create;
TheBitmap2.LoadFromFile('C:delphiimagesbuttonsvideo.bmp');
TheBitmap3 := TBitmap.Create;
TheBitmap3.LoadFromFile('C:delphiimagesbuttonsgears.bmp');
TheBitmap4 := TBitmap.Create;
TheBitmap4.LoadFromFile('C:delphiimagesbuttonskey.bmp');
TheBitmap5 := TBitmap.Create;
TheBitmap5.LoadFromFile('C:delphiimagesbuttonstools.bmp');
ComboBox1.Items.AddObject('Bitmap1: Globe', TheBitmap1);
ComboBox1.Items.AddObject('Bitmap2: Video', TheBitmap2);
ComboBox1.Items.AddObject('Bitmap3: Gears', TheBitmap3);
ComboBox1.Items.AddObject('Bitmap4: Key', TheBitmap4);
ComboBox1.Items.AddObject('Bitmap5: Tools', TheBitmap5);
ListBox1.Items.AddObject('Bitmap1: Globe', TheBitmap1);
ListBox1.Items.AddObject('Bitmmap2: Video', TheBitmap2);
ListBox1.Items.AddObject('Bitmap3: Gears', TheBitmap3);
ListBox1.Items.AddObject('Bitmap4: Key', TheBitmap4);
ListBox1.Items.AddObject('Bitmap5: Tools', TheBitmap5);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
TheBitmap1.Free;
TheBitmap2.Free;
TheBitmap3.Free;
TheBitmap4.Free;
TheBitmap5.Free;
end;
procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
Bitmap: TBitmap;
Offset: Integer;
begin
with (Control as TComboBox).Canvas do
begin
FillRect(Rect);
Bitmap := TBitmap(ComboBox1.Items.Objects[Index]);
if Bitmap <> nil then
begin
BrushCopy(Bounds(Rect.Left + 2, Rect.Top + 2, Bitmap.Width,
Bitmap.Height), Bitmap, Bounds(0, 0, Bitmap.Width,
Bitmap.Height), clRed);
Offset := Bitmap.width + 8;
end;
{ display the text }
TextOut(Rect.Left + Offset, Rect.Top, Combobox1.Items[Index])
end;
end;
procedure TForm1.ComboBox1MeasureItem(Control: TWinControl; Index:
Integer; var Height: Integer);
begin
height:= 20;
end;
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
Bitmap: TBitmap;
Offset: Integer;
begin
with (Control as TListBox).Canvas do
begin
FillRect(Rect);
Bitmap := TBitmap(ListBox1.Items.Objects[Index]);
if Bitmap <> nil then
begin
BrushCopy(Bounds(Rect.Left + 2, Rect.Top + 2, Bitmap.Width,
Bitmap.Height), Bitmap, Bounds(0, 0, Bitmap.Width,
Bitmap.Height), clRed);
Offset := Bitmap.width + 8;
end;
{ display the text }
TextOut(Rect.Left + Offset, Rect.Top, Listbox1.Items[Index])
end;
end;
procedure TForm1.ListBox1MeasureItem(Control: TWinControl; Index: Integer;
var Height: Integer);
begin
heeight:= 20;
end;
end.
{END OWNERDRW.PAS}
{START OWNERDRW.DFM}
object Form1: TForm1
Left = 211
Top = 155
Width = 435
Height = 300
Caption = 'Form1'
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'System'
Font.Style = []
PixelsPerInch = 96
OnClose = FormClose
OnCreate = FormCreate
TextHeight = 16
object ComboBox1: TComboBox
Left = 26
Top = 30
Width = 165
Height = 22
Style = csOwnerDrawVariable
ItemHeight = 16
TabOrder = 0
OnDrawItem = ComboBox1DrawItem
OnMeasureItem = ComboBox1MeasureItem
end
object ListBox1: TListBox
Left = 216
Top = 28
Width = 151
Height = 167
ItemHeight = 16
Style = lbOwnerDrawVariable
TabOrder = 1
OnDrawItem = ListBox1DrawItem
OnMeasureItem = ListBox1MeasureItem
end
end
{END OWNERDRW.DFM}
0
0
삭제
수정
댓글
김영대
•
1999.05.10 22:27
김장섭 wrote:
> 콤보 박스의 Item에 텍스트가 아닌 텍스트와 이미지가 들어가는
> 컴포넌트를 구합니다.
> (Source포함이고요....)
> 아시는 분 있으면 알려주세요.. 꼭, 꼭, 꼭....
안녕하세요 김영대입니다
그런 기능이라면 직접 코딩하셔도 몇줄 안됩니다
아래 예제가 있는데
CB_GroupName 는 TComboBox 이고요
Image_group 는 이미지가 들어있는 조그만 TImage 입니다
procedure TWinUserForm.CB_GroupNameDrawItem(Control: TWinControl;
Index: Integer; Rect: TRect; State: TOwnerDrawState);
begin
with CB_GroupName.Canvas do
begin
FillRect(Rect); {clear the rectangle}
BrushCopy(Bounds(Rect.Left, Rect.Top, Image_group.Picture.Bitmap.Width, Image_group.Picture.Bitmap.Height), Image_group.Picture.Bitmap,
Bounds(0,0, Image_group.Picture.Bitmap.Width, Image_group.Picture.Bitmap.Height), clRed);
TextOut(Rect.Left+21, Rect.Top+3, CB_GroupName.Items[Index]);
end;
end;
0
0
삭제
수정
댓글
(NOTICE) You must be
logged in
to comment on this post.
최석기
•
1999.05.11 21:40
2
COMMENTS
/
0
LIKES
금액 콤포넌트 만드는데 문제점..
이정욱
•
1999.05.11 22:26
먼저 OnChange이벤트를 재정의를 하십시요. 그리고 ChangeBySelf라는 변수를 Boolean형으로 주시구요.. O...
최석기
•
1999.05.12 02:23
이정욱 wrote: > 먼저 OnChange이벤트를 재정의를 하십시요. > 그리고 ChangeBySelf라는 변수를 Boolean...
남윤혁
•
1999.05.11 18:58
1
COMMENTS
/
0
LIKES
텍스트 입력 컴포넌트? 좋은 것 추천 좀...
이정욱
•
1999.05.11 20:23
RxLib의 RichEDit2 콘트롤을 사용하는 방법이 있구요.. 또하나는 상용인 InfoPower에 포함되어있는 RichEd...
아무게
•
1999.05.11 18:49
1
COMMENTS
/
0
LIKES
컴퓨터의 공유 폴더
이정욱
•
1999.05.11 20:26
공유정보를 읽어오는것입니다. 김영대님의 팁에서 가져왔습니다. // 아래 예제는 Windows NT/Windows 20...
summe
1999.05.11 18:19
0
COMMENTS
/
0
LIKES
인스톨 실드를 만드는데 MSSql7.0 연결방법
김지건
•
1999.05.11 18:10
2
COMMENTS
/
0
LIKES
메모장이 용량을 초과하면??
이정욱
•
1999.05.11 20:16
64k 이상을 넘지 못합니다. 그럴때는 RichEdit을 사용하시는것이 좋습니다. 아니면 상용으로나온 확장 Me...
김지건
•
1999.05.11 20:54
이정욱 wrote: > 64k 이상을 넘지 못합니다. > 그럴때는 RichEdit을 사용하시는것이 좋습니다. > 아니면...
Heaven
1999.05.11 13:09
0
COMMENTS
/
0
LIKES
쿼리컴포넌트 사용시 DBGrid의 데이타 입력
송수정
•
1999.05.11 10:01
1
COMMENTS
/
0
LIKES
코딩으로 미리보기 화면 만들기
이정욱
•
1999.05.11 11:01
한델(http://www.delphi.co.kr) 강의실에 가보시면 인쇄에 관한 강좌가 있습니다. 참고하시구요.. TPrint...
엠마
•
1999.05.11 09:04
1
COMMENTS
/
0
LIKES
하윤철
•
1999.05.11 18:02
엠마 wrote: > 테이블에 insert한후에 조회하면은 insert한 자료는 조회가 되지 않습니다. > 테이블에 데...
강경중
•
1999.05.11 07:08
2
COMMENTS
/
0
LIKES
Taborder문제...
안치봉
•
1999.05.11 08:09
강경중 wrote: > 델파이의 폼에 콤포넌트를 추가하면 > 콤포넌트 마다 고유의 Taborder가 있습니다. > ...
강경중
•
1999.05.12 03:13
안치봉 wrote: > 강경중 wrote: > > 델파이의 폼에 콤포넌트를 추가하면 > > 콤포넌트 마다 고유의 Tabo...
강경중
•
1999.05.11 06:53
1
COMMENTS
/
0
LIKES
소켓에러 가로채기
이정욱
•
1999.05.11 10:08
에러를 가로챈다기 보다 무시하게 하면 됩니다. Try Except문으로 처리하세요. 델파이환경에서 Break on ...
강경중
•
1999.05.11 06:47
1
COMMENTS
/
0
LIKES
초보자라 답답합니다...
이정욱
•
1999.05.11 11:03
ImageList의 속성(Property)를 보시면 그림의 크기를 정하는곳이 있습니다. Width와 Height이죠. 그림은 ...
kim mi sen
•
1999.05.11 06:40
1
COMMENTS
/
0
LIKES
의류관리 매장에 관한 프로그램짜기
누군지
•
1999.05.11 10:12
이런 종류의 질문이....??? 스스로 노력을 하다가 문제가 생겼을 때 질문을 해야하는것이 적어도 성의가...
유대영
1999.05.11 04:56
0
COMMENTS
/
0
LIKES
질문 - 퀵리포트에서출력되는것을 이미지로?
영이...
•
1999.05.11 03:09
1
COMMENTS
/
0
LIKES
신인재님 답변감사..하나더...
이정욱
•
1999.05.11 20:32
안녕하세요? 제가 DB는 모르지만 언어적으로 해결을 하시려면... 하나씩 기억했다가 사용하면 어떨까요? ...
왕초보
•
1999.05.11 02:55
2
COMMENTS
/
0
LIKES
OnExit Event를 Override 하는 방법??
이정욱
•
1999.05.11 20:38
CM_EXIT 라는 컴포넌트 내부 메세지를 가로채면 됩니다. procedure CMExit(var Message: TCMExit); mess...
왕초보
•
1999.05.11 21:54
친절한 답변 감사드립니다... 이정욱 wrote: > CM_EXIT 라는 컴포넌트 내부 메세지를 가로채면 됩니다....
이호선
•
1999.05.11 01:57
1
COMMENTS
/
0
LIKES
이미지 로드하는 콤퍼넌트에 대하여...
이정욱
•
1999.05.11 20:50
BitBtn1.Glyph.LoadFromFile의 메소드가 잘 먹히는데요? 아래는 테스트 해본 코드입니다... var ...
왕초보
•
1999.05.11 01:35
2
COMMENTS
/
0
LIKES
dbedit상에서 숫자를 콤마로 display하는법??
왕초보
•
1999.05.11 02:54
Tfield의 EditMask에다가 #라고 쓰십시오...이게 무슨 뜻인지..? "#"으로만 editmask를 잡으면 1,234 와 ...
하윤철
•
1999.05.11 17:29
죄송합니다... TField에 EditFormat과 DisplayFormat 속성이 있을겁니다. DisplayFormat은 보여주는 ...
박상길
1999.05.11 00:41
0
COMMENTS
/
0
LIKES
(질문)CD-ROM 제거하는 방법
이현정
1999.05.11 00:21
0
COMMENTS
/
0
LIKES
데이타검색시 오류발생
김장섭
•
1999.05.10 20:57
2
COMMENTS
/
0
LIKES
컴포넌트 구합니다.
콤보 박스의 Item에 텍스트가 아닌 텍스트와 이미지가 들어가는 컴포넌트를 구합니다. (Source포함이고요....) 아시는 분 있으면 알려주세요.. 꼭, 꼭, 꼭....
글쎄요.
•
1999.05.10 23:16
영문으로 되 있는 데 참고하시는 데 그리 어려움이 없을 겁니다. 그럼 좋은 하루 되셔요. ////////// TI...
김영대
•
1999.05.10 22:27
김장섭 wrote: > 콤보 박스의 Item에 텍스트가 아닌 텍스트와 이미지가 들어가는 > 컴포넌트를 구합니다...
김장섭
1999/05/10 20:57
Views
325
Likes
0
Comments
2
Reports
0
Tag List
수정
삭제
목록으로
한델 로그인 하기
로그인 상태 유지
아직 회원이 아니세요? 가입하세요!
암호를 잊어버리셨나요?
그럼 좋은 하루 되셔요.
//////////
TI: Inserting graphics in Owner Drawn ListBoxes and ComboBoxes
The ability to place graphics inside ListBoxes and ComboBoxes
can improve the look of your application and set your user
interface apart from the others.
Q: How do I stick graphics in a Listbox or ComboBox???
Here is an step-by-step example.....
1. Create a form.
2. Place a ComboBox and Listbox component on your form.
3. Change the Style property of the ComboBox component to
csOwnerDrawVariable and the Style property of the ListBox to
lbOwnerDrawVariable.
An Owner-Draw TListBox or TComboBox allows you to display
both objects (ex. graphics) and strings as the items. For
this example, we are adding both a graphic object and a
string.
4. Create 5 variables of type TBitmap in the Form's VAR
section.
5. Create a Procedure for the Form's OnCreate event.
6. Create a Procedure for the ComboBox's OnDraw Event.
7. Create a Procedure for the ComboBox's OnMeasureItem.
8. Freee the resources in the Form's OnClose Event.
{START OWNERDRW.PAS}
unit Ownerdrw;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
ComboBox1: TComboBox;
ListBox1: TListBox;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
procedure ComboBox1MeasureItem(Control: TWinControl; Index: Integer;
var Height: Integer);
procedure ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
procedure ListBox1MeasureItem(Control: TWinControl; Index: Integer;
var Height: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
TheBitmap1, TheBitmap2, TheBitmap3, TheBittmap4,
TheBitmap5 : TBitmap;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
TheBitmap1 := TBitmap.Create;
TheBitmap1.LoadFromFile('C:delphiimagesbuttonsglobe.bmp');
TheBitmap2 := TBitmap.Create;
TheBitmap2.LoadFromFile('C:delphiimagesbuttonsvideo.bmp');
TheBitmap3 := TBitmap.Create;
TheBitmap3.LoadFromFile('C:delphiimagesbuttonsgears.bmp');
TheBitmap4 := TBitmap.Create;
TheBitmap4.LoadFromFile('C:delphiimagesbuttonskey.bmp');
TheBitmap5 := TBitmap.Create;
TheBitmap5.LoadFromFile('C:delphiimagesbuttonstools.bmp');
ComboBox1.Items.AddObject('Bitmap1: Globe', TheBitmap1);
ComboBox1.Items.AddObject('Bitmap2: Video', TheBitmap2);
ComboBox1.Items.AddObject('Bitmap3: Gears', TheBitmap3);
ComboBox1.Items.AddObject('Bitmap4: Key', TheBitmap4);
ComboBox1.Items.AddObject('Bitmap5: Tools', TheBitmap5);
ListBox1.Items.AddObject('Bitmap1: Globe', TheBitmap1);
ListBox1.Items.AddObject('Bitmmap2: Video', TheBitmap2);
ListBox1.Items.AddObject('Bitmap3: Gears', TheBitmap3);
ListBox1.Items.AddObject('Bitmap4: Key', TheBitmap4);
ListBox1.Items.AddObject('Bitmap5: Tools', TheBitmap5);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
TheBitmap1.Free;
TheBitmap2.Free;
TheBitmap3.Free;
TheBitmap4.Free;
TheBitmap5.Free;
end;
procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
Bitmap: TBitmap;
Offset: Integer;
begin
with (Control as TComboBox).Canvas do
begin
FillRect(Rect);
Bitmap := TBitmap(ComboBox1.Items.Objects[Index]);
if Bitmap <> nil then
begin
BrushCopy(Bounds(Rect.Left + 2, Rect.Top + 2, Bitmap.Width,
Bitmap.Height), Bitmap, Bounds(0, 0, Bitmap.Width,
Bitmap.Height), clRed);
Offset := Bitmap.width + 8;
end;
{ display the text }
TextOut(Rect.Left + Offset, Rect.Top, Combobox1.Items[Index])
end;
end;
procedure TForm1.ComboBox1MeasureItem(Control: TWinControl; Index:
Integer; var Height: Integer);
begin
height:= 20;
end;
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
Bitmap: TBitmap;
Offset: Integer;
begin
with (Control as TListBox).Canvas do
begin
FillRect(Rect);
Bitmap := TBitmap(ListBox1.Items.Objects[Index]);
if Bitmap <> nil then
begin
BrushCopy(Bounds(Rect.Left + 2, Rect.Top + 2, Bitmap.Width,
Bitmap.Height), Bitmap, Bounds(0, 0, Bitmap.Width,
Bitmap.Height), clRed);
Offset := Bitmap.width + 8;
end;
{ display the text }
TextOut(Rect.Left + Offset, Rect.Top, Listbox1.Items[Index])
end;
end;
procedure TForm1.ListBox1MeasureItem(Control: TWinControl; Index: Integer;
var Height: Integer);
begin
heeight:= 20;
end;
end.
{END OWNERDRW.PAS}
{START OWNERDRW.DFM}
object Form1: TForm1
Left = 211
Top = 155
Width = 435
Height = 300
Caption = 'Form1'
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'System'
Font.Style = []
PixelsPerInch = 96
OnClose = FormClose
OnCreate = FormCreate
TextHeight = 16
object ComboBox1: TComboBox
Left = 26
Top = 30
Width = 165
Height = 22
Style = csOwnerDrawVariable
ItemHeight = 16
TabOrder = 0
OnDrawItem = ComboBox1DrawItem
OnMeasureItem = ComboBox1MeasureItem
end
object ListBox1: TListBox
Left = 216
Top = 28
Width = 151
Height = 167
ItemHeight = 16
Style = lbOwnerDrawVariable
TabOrder = 1
OnDrawItem = ListBox1DrawItem
OnMeasureItem = ListBox1MeasureItem
end
end
{END OWNERDRW.DFM}