whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

30 Visitors Online


 
...combine two icons?
Autor: Geir Wikran
[ Print tip ]  

Tip Rating (6):  
     


{
  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