Forum > Carbon

Changing/Overlay Dock Icon

(1/1)

rajivsoft:
After some headache i'd digget out how to programmatically change dock icon:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses  ... MacOSAll ...  procedure TFrm_Main.FormCreate(Sender: TObject);begin  ...  FResPath := TrimFilename(ExtractFilePath(Application.ExeName) + PathDelim + 'Resource');  ...end; procedure TFrm_Main.SomeEventWhenOverlay(SomeVar: Integer);var  temp_ImagePath: String;  temp_CGDataProvider: CGDataProviderRef;  temp_Float32Ptr: Float32Ptr;  temp_CGImage: CGImageRef;  temp_CGContext: CGContextRef;begin  temp_ImagePath := TrimFilename(FResPath + PathDelim + 'Image' + PathDelim + 'overlay_image.png'); // image must be same size as icon, if not, will be deformed  if (FileExists(temp_ImagePath)) then  begin    temp_CGDataProvider := CGDataProviderCreateWithFilename(PChar(temp_ImagePath));    temp_Float32Ptr := nil;    temp_CGImage := CGImageCreateWithPNGDataProvider(temp_CGDataProvider, temp_Float32Ptr, 1, kCGRenderingIntentDefault);    CGDataProviderRelease(temp_CGDataProvider);    // Draw image    temp_CGContext := BeginCGContextForApplicationDockTile;    //SetApplicationDockTileImage(temp_CGImage);    OverlayApplicationDockTileImage(temp_CGImage);    CGImageRelease(temp_CGImage);    EndCGContextForApplicationDockTile(temp_CGContext);  end;   end; procedure TFrm_Main.SomeOtherEventWhenRestore();begin  //This will not work if you use SetApplicationDockTileImage  RestoreApplicationDockTileImage;end;  

Navigation

[0] Message Index

Go to full version