Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

Картинки в меню [D6, WinXP]


BelchonkH ©   (2005-01-07 18:04:00) 

Доброго Вам!!! Такой вот глюк с картинками в меню, если меню не белого цвета, то картинки сразу отображаются с искажёнными цветами... в VCL этого нет...


BelchonokH   (2005-01-09 22:18:00) [1]

Попробую поставить вопрос по другому, можно ли как-нибудь исказить цвет картинки для меню так, чтобы при наложении на меню они исказились обратно и получили первоначальные цвета?


BelchonokH   (2005-01-09 15:44:00) [2]

Can you have not understood me...
With a transparent color everything is all right...
Look please at a picture, I speak about it   http://www.redisog.com/menu.jpg


thaddy   (2005-01-09 12:02:00) [3]

// I am shure this can be done easier, but this works!
// Uses bitmap(per item) and imagelist

procedure NewForm1( var Result: PForm1; AParent: PControl );
begin
 New(Result,Create);
 with Result^ do
 begin
   Form:= NewForm(AParent,'KOLForm').SetSize(600,400).centeronparent.Tabulate;
   Applet:=Form;
   Form.Add2AutoFree(Result);
   Menu:=Newmenu(form,0,['&File','(','&Open','-','E&xit',')'],Domenu);
   ImgList:=NewImagelist(form);
   Imglist.ImgWidth:=14;
   Imglist.ImgHeight:=14;
   ImgList.LoadFromFile('bitmap1.bmp', clOlive,itBitmap);
   BitMap:=Newbitmap(14,14);
   Bitmap.Handle;
   ImgList.Draw(0,Bitmap.canvas.handle,0,0);
   Menu.Items[1].bitmap:=Bitmap.Handle;
   form.onpaint:=formpaint;
 end;
end;


thaddy   (2005-01-09 11:36:00) [4]

Can't you put them in a resource?
I have tested the code on 4 machines at that code works!
I will try to create an example with loadfromfile.
You might get lucky if you load it into a Imagelist! and use the
GetSysColor call to set the transparent color, although I have not tested this yet.


BelchonokH   (2005-01-08 23:48:00) [5]

2 thaddy [2]
>>for menu like this:

It does not work in my case. Images for menu I load from external files
Bmp.LoadFromFile()
and then
Form1.PopUpMenu1.ItemBitmap[ Form1.PopUpMenu1.Count-1 ] :=CopyImage( Bmp.Handle, IMAGE_BITMAP, 0, 0, 0);

Tried to correct CreateMappedBitmapEx... It does not work too.


thaddy   (2005-01-08 15:48:00) [6]

Background:

In Kol.pas the system colors like clMenu are calculated as:

 clMenu = TColor(COLOR_MENU or $80000000);

Which is not correct for at least Windows XP.
So you should use GetSysColor with the API declaration from windows.pas (see win32.hlp under GetSysColor for an overview.
Maybe this is a bug in kol? (and the VCL too..)


thaddy   (2005-01-08 15:39:00) [7]

for menu like this:
Assumes bitmap in resource

procedure NewForm1( var Result: PForm1; AParent: PControl );
var
 Map:array[0..1] of Tcolor;
begin
 New(Result,Create);
 with Result^ do
 begin
   Form:= NewForm(AParent,'KOLForm').SetSize(600,400).centeronparent.Tabulate;
   Applet:=Form;
   Map[0]:=clOlive;
   Map[1]:=GetSysColor(COLOR_MENU);
   Form.Add2AutoFree(Result);
   Menu:=NewMenu(Form,0,['&File','(','&Open','-','E&xit',')'],Domenu);
   Menu.ItemBitmap[1]:=LoadMappedBitmapEx(Result, hInstance, 'MYBITMAP', map);
 end;
end;


thaddy   (2005-01-08 15:14:00) [8]

There is a problem with the menu and also with the toolbar that I solve like this:
var
 MAP: array[0..1] of Tcolor;
begin
 Map[0]:=clOlive;// Your transparent color
 Map[1]:=GetSysColor(COLOR_BTNFACE);// Very Important to do this!!
 tb.TBAddBitmap(LoadMappedBitmapEx(Result, hInstance, 'MYBITMAP', map));

// similar code should be used for menu bitmaps


Наверх

Титульная страница Поиск, карта сайта Написать письмо