whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews ¦  misc ¦  forum
 kylix ¦  tutorials ¦  online shop ¦  photos ¦  Add&Win Game

Tips (1565)

Database (91)
Files (139)
Forms (113)
Graphic (116)
IDE (21)
Indy (5)
Internet / LAN (133)
IntraWeb (0)
Kylix (10)
Math (77)
Misc (128)
Multimedia (46)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (268)
VCL (246)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

58 Visitors Online


SwissDelphiCenter is a Borland Technology Partner
 
...combine two icons?
Autor: Geir Wikran
[ Print tip ]  

Tip Rating (2):  
     


{
  I want to combine 2 icons like Windows does with
  the links (the small arrow).
  Can anyone tell me how that works?
}

function CombineIcons(FrontIcon, BackIcon: HIcon): HIcon;
var
  
WinDC: HDC;
  FrontInfo: TIconInfo;
  FrontDC: HDC;
  FrontSv: HBITMAP;
  BackInfo: TIconInfo;
  BackDC: HDC;
  BackSv: HBITMAP;
  BmpObj: tagBitmap;
begin
  
WinDC := GetDC(0);

  GetIconInfo(FrontIcon, FrontInfo);
  FrontDC := CreateCompatibleDC(WinDC);
  FrontSv := SelectObject(FrontDC, FrontInfo.hbmMask);

  GetIconInfo(BackIcon, BackInfo);
  BackDC := CreateCompatibleDC(WinDC);
  BackSv := SelectObject(BackDC, BackInfo.hbmMask);

  GetObject(FrontInfo.hbmMask, SizeOf(BmpObj), @BmpObj);
  BitBlt(BackDC, 0,0,BmpObj.bmWidth, BmpObj.bmHeight, FrontDC, 0,0,SRCAND);

  SelectObject(BackDC, BackInfo.hbmColor);
  DrawIconEx(BackDC, 0,0,FrontIcon, 0,0,0,0,DI_NORMAL);

  Result := CreateIconIndirect(BackInfo);

  SelectObject(FrontDC, FrontSv);
  DeleteDC(FrontDC);
  SelectObject(BackDC, BackSv);
  DeleteDC(BackDC);
  ReleaseDC(0,WinDC);
  DeleteObject(FrontInfo.hbmColor);
  DeleteObject(FrontInfo.hbmMask);
  DeleteObject(BackInfo.hbmColor);
  DeleteObject(BackInfo.hbmMask);
end;

// Remember: The icon created with this function must be destroyed with
// DestroyIcon() function when finished using it.

 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners