Mega Code Archive

 
Categories / Delphi / Graphic
 

Add cool icons to your application

Title: Add cool icons to your application Question: Answer: Maybe you've already asked yourself, how you get Delphi to accept two (or more) Icons ? A 16x16 icon for when the small icon is required for display (ie. small icons in Explorer), or a 32x32 icon for display when the large one is required (ie. large icons in Explorer). Also, if you peek in M$ (and other) applications, you will see multiple icons of differing sizes and palettes all under the same title. Just check for the current resolution and change the icon handle of the application... Of course, you have to create new icons in your resource (for this "how to", please see tip "How to store "everything" in your EXE file"). Put this in the project (.DPR) file of your application source: Application.Initialize; Application.CreateForm(TForm1, Form1); CASE GetDeviceCaps(GetDC(Form1.Handle), HORZRES) of 640 : Application.Icon.Handle := LoadIcon (hInstance, 'ICON640'); 800 : Application.Icon.Handle := LoadIcon (hInstance, 'ICON800'); 1024 : Application.Icon.Handle := LoadIcon (hInstance, 'ICON1024'); 1280 : Application.Icon.Handle := LoadIcon (hInstance, 'ICON1280'); END; Application.Run; Well, that's all ! (Tip found in a msg of Gerry Jacobs. () )