![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
hIcon и SpeedButton
IgoX © (2002-01-22 15:47:00)Привет каждому
Подскажите как если это можно имея hIcon поместить ее на SpeedButton
IgoX (2002-01-23 12:10:00) [1]Спасибо за отзыв
Serghei (2002-01-23 11:40:00) [2]Cм.
TCanvas.handle (Properties)
Specifies the Windows GDI handle to the device context for this canvas.
property Handle: HDC;
Description
Set Handle to the HDC for the device context the canvas must draw into. When a windowed control responds to a Windows paint message, the HDC for drawing is passed in to the PaintWindow method. In other cases, an HDC can be obtained for a window by calling the GetDeviceContext method of a control. Additionally, Windows provides API calls to obtain an HDC for a printer or for a memory image.
Read the Handle property to supplement the drawing services provided by the TCanvas object with API calls that require a handle to a device context. Most of the Windows GDI calls require an HDC.
С ДровИкон должно получиться но только он тебе отрисует иконку в 32х32 а не 16х16, а вот с этим ДровИконЕх и у меня были те же самые проблемы - рисовал рисовал а ничего так и не отрисовывалось! :o( Фиг его знает почему - значит придется наверное тебе остановится на том варианте что ты реализовал вчера!
Удачи!
IgoX (2002-01-23 11:32:00) [3]Я попробывал но ни чего не вышло DrawIcon(SpeedButton1->Glyph->Canvas->Handle,0,0,FileInfo.hIcon);
GetLastError() выдает 0
Serghei (2002-01-23 11:24:00) [4]Не помню уже где читал но точно помню что там было сказано что DC это эквивалентно Canvas.Handle - а тебе ведь именно это и надо, ведь ты рисуешь не самой кнопке а используя ее свойство Glyph которое при этом является TBitmap-ом и имеет ведь свойство Canvas.Handle что равно DC.
IgoX (2002-01-23 11:04:00) [5]Specifies the Windows GDI handle to the device context for this canvas.
__property HDC Handle = {read=GetHandle, write=SetHandle, nodefault};
Set Handle to the HDC for the device context the canvas must draw into. When a windowed controlresponds to a Windows paint message, the HDC for drawing is passed in to the PaintWindow method. In other cases, an HDC can be obtained for a window by calling the GetDeviceContextmethod of a control. Additionally, Windows provides API calls to obtain an HDC for a printer or for a memory image.
Из help видно что это только для windowed control а SpeedButton таким не является, GetDeviceContext это одно и тоже что API функция GetDC(hwnd) а у SpeedButton нет hwnd
Serghei (2002-01-23 09:52:00) [6]Да, и еще одно - не знаю как СпеедБатон а обычную кнопку ТБатон можно приделать с заголовком, с кнопками минимайз, максимайз, клоуз как и у нормального окна, то есть можно сделать из нее что-то вроде окна и передвигать ее по форме, изменять размеры. Это делается при помощо функции GetWindowLong i SetWindowLong. Так что фактически она и является окном!
Удачи!
Serghei (2002-01-23 09:41:00) [7]Почему ГетДС для окна, этот ДС ты получаешь для кнопкп, точнее
DrawIconEx(SpeedButton1.Glyph.Canvas.Handle,....)
Или я ошибаюсь?
Object.Canvas.Handle и есть тот самый ДС для обжекта (SpeedButton) насколько я помню!
IgoX (2002-01-22 18:36:00) [8]Через DrawIcon я пробывал но в GetDC я должен указать handle окна а SpeedButton таким не является, я прорисовал на обычную кнопку но после нажатия она исчезает
Вот я надыбал но несовсем то т.к. не все иконки нормально получаются
ICONINFO inf;
GetIconInfo(FileInfo.hIcon,&inf);
SpeedButton1->Glyph->Handle = inf.hbmColor;
Serghei (2002-01-22 18:09:00) [9]Opiati ia!
Vspomnil escio odno sredstvo!
Porabotai s DrawIcon ili DrawIconEx risua ee na Glyph.Canvas dlia SpeedButton
Udaci!
Serghei (2002-01-22 18:01:00) [10]Tac ietio i esti nevizualiniie componenti! :o)
TIcon i TImageList!
Citobi ne zagrujati svoi proceduri v proge, mojeshi sozdati functiu cotoraia vhodnim parametrom imeet iconcu, vernee ee handl a vihodnim - bitmap cotorii prisvaivaeshi svoemu SpeedButton.
Cioto tipa
SB.Glipgh:=IcoToBmp(_HI : HICON);
A po drugomu ia ne znaiu kak, ne proboval!
Udaci!
IgoX (2002-01-22 17:55:00) [11]Спасибо все работает а можно как нибудь без каких либо других
визуальных компонентов.
Serghei (2002-01-22 16:09:00) [12]Сорри, можно и не создавать дополнительный битмап просто пишешь
ImageList1.GetBitmap(indexbitmapa, SpeedButton1.Glyph);
Если получится, сообщи!
Удачи!
Serghei (2002-01-22 16:01:00) [13]По моему так:
Var tmp_Icon : TIcon;
ImageList : TImageList;
tmp_BMP : TBitMap;
begin
tmp_Icon:=TIcon.Create;
ImageList:=TImageList.Create;
tmp_BMP:=TBitmap.Create;
//tmp_Icon.Handle:=LoadIcon ili ExtractAssociatedIcon(...)
//SpeedButton1.Glyph.Canvas.Loa
ImageList1.AddIcon(tmp_Icon);
ImageList1.GetBitmap(indexbitmapa, tmp_bmp);
SpeedButton1.Glyph.Assign(tmp_bmp);
end;
Serghei (2002-01-22 15:55:00) [14]Один метод но не самый лучший наверное и достаточно длинный!
Создаешь TImageList, в него запихиваешь свой Hicon при помощи метода AddIcon потом рисуешь это изображение на Glyph для кнопки.