Icon

Share your ZGE-development tips and techniques here!

Moderator: Moderators

Post Reply
User avatar
Kjell
Posts: 1715
Joined: Sat Feb 23, 2008 11:15 pm

Icon

Post by Kjell » Tue Feb 15, 2011 9:11 pm

:idea:

For those that don't want to mess around with the source code .. attached is a simple method ( Windows-only ) to set the icon of your window.

Image

Bit ugly*, as it requires you to distribute the icon file with your exe + it switches the icon during run-time after the window has already been created .. but it's better then nothing.

*Unless you want to do fancy real-time icon tricks, then this is the way to go 8)

K
Attachments
Icon.zip
(4.96 KiB) Downloaded 416 times

User avatar
VilleK
Site Admin
Posts: 2025
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK » Wed Feb 16, 2011 8:40 am

Nice workaround. I haven't managed to do the same with ZApp.Icon because for some reason I cannot get the handle to the icon using FindResource, LoadIcon etc.

User avatar
Kjell
Posts: 1715
Joined: Sat Feb 23, 2008 11:15 pm

Re: Icon

Post by Kjell » Fri Sep 23, 2016 11:30 am

:roll:

Silly 2011-Kjell ... below is a workaround that uses the internal icon / resource instead.

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="Icon" CustomScreenWidth="640" CustomScreenHeight="360" MouseVisible="255" FileVersion="2">
  <OnLoaded>
    <ZExternalLibrary ModuleName="kernel32" Source="int GetModuleHandleA(string lpModuleName){}"/>
    <ZExternalLibrary ModuleName="user32">
      <Source>
<![CDATA[int LoadIconA(int hInstance, string lpIconName){}
int SendMessageA(int hWnd, int Msg, int wParam, int lParam){}]]>
      </Source>
    </ZExternalLibrary>
    <ZExpression>
      <Expression>
<![CDATA[// Resource id

int id = 1;

// Load resource & update window icon

int hInstance = GetModuleHandleA(null);
int hIcon = LoadIconA(hInstance, reinterpret_cast<string>(id));
SendMessageA(App.WindowHandle, 0x80, 0, hIcon);]]>
      </Expression>
    </ZExpression>
  </OnLoaded>
  <OnRender>
    <UseMaterial Material="PointMaterial"/>
    <RenderNet XCount="7" YCount="7">
      <RenderVertexExpression>
<![CDATA[//

Vertex.X += sin(App.Time*0.9+Vertex.Y);
Vertex.Y += cos(App.Time*0.7+Vertex.X);]]>
      </RenderVertexExpression>
    </RenderNet>
  </OnRender>
  <Content>
    <Material Name="PointMaterial" Shading="3" Light="0" ZBuffer="0"/>
  </Content>
  <Icon>
<![CDATA[78DAED5D0D4C53D717EFC20831C6A0218410421821448D31CE1842FCBB652A03C7F08B6F0A94B6F403999BC89C43440404E4FBA37C15640B634E9C28A2F257A60E5BD08D31FFFC1DF257740C5118A222C3C26AADB5F47FEEEB2D3C11A4400BAD7B24BFBCFB0EE7BE7BCE79E7DC7BDFFD2A8DF616ED6DDAC28534F87B87B6ED6D1ACD0DA5DE51DF7F0FF493407BF75D7CEF48A3F959D2686BD7AAEF97ACA7D186FF45A32D81BB85048506CF2332D3D6BE4D7BE54FA552BDF5264156C839222BE0B813E902CED770BF692AF99FE4B2A214426ED97321D7F58980950CE963F222EE07CF0A3876DAE4BF9DE0E7A810F2FA86F2D8A50021A407240296E07911376BB2BCF7520297BE28E6353D2DE034F767333320DDFCB420B411D28990EE982CFFF943E9F37AB398C23B6921BCBB19AC20489774A433D95D996C464F2633BF397B87AD4824321B2F2FD03D014322915809578C71D332C08671F29F06A8B444F838F97D01522DF27E0D309D40870F26C9DB03B09FC87EF0BF0580BE71F295239D01E693BD03E071C1E568F222BB2C988A0FA27704580570D077BCA01A60265882EB98B5A47A267EE19B5FCF50A0A04B0CE43037A94AF83DD2FC503A99FE3093F1FEF0217E37B40361FA2CBF3D29204C7588AF82F6B2914C6F8DF3F11E2EE1AB9E15729AF5597EED0E771B686715CA629EA2F320DD46433F15EE660EEDA114645076A5062ED5A70C8FB3431AE11DA806F3D8E18F32194E506607F421988F32436A10FD695E680CB4D18EC325BC36E80F44EBBAFCCE647A047A0760EBF337E27C7D51996093965B097E416A3AB7A969CFD60F94253C15F4277ADB1303E6E9AA6CB0BB19BC033B284F0E7D0D69F35E2F7B8DDDAFEFF77102BF902B8BF98ABB07E90E4F04EC7B4836F0CD753AB17B16D31D7C5C0265843DCE665E46CFFE3B8FCD00BBD71276CF0FDDDD978DD305A1110F3218A5C81E9016E8A27CB02F1DDBBAF96E4AE06E1C07B5BF27FA33B1DD2FDF490E08C7EFA6AE29DAD315C504BC83EEB6043FD399967F66FB8645D0EF9482AFA97EDDB36503D401483759FDAE8D8BC11715B28250C52F519B9D8770FA5A8CA703F8EA439051753785EE3293B2A18F6122AAAF5F54F179C0CA8A086FE7AAAC7DB615113E4E153BBC9C4F1FCAB6AE88F45F55B1C3DBF9644E9CAD265D9D9F6C73F44BC672C47F2269A73DCA0FCF593451BFEC3565AF01DC002844E27AB91A62F9485A2422A5C563D2E2D134E25303F5BB5CB42CDB1AD03F853EABB6B8A165F91C3D948D20D1B27C9E9ECAAFD1B27CF42D22D161B9E8DB2407603105FF7307B4E3BC332D1FF99EC9B4E24F244AD341F9B133A80322665876C954637F4CF92BA7F80E0E034A013100675DB401F09CB35A96DD0698A7EBB61FD747ED93948DBE4D57E8ABFF03CFB6C476958F135B3580C5B3D11786726C0074C06E5C4F3A52DF08C60DDA1CFFA1710A3464CA228F533852E314142850A040E19F89C75921B6F2426EB9AA84DFFE771E9BD79EE4FFCA37CC830C86D5B3428E60B8847FFB6941E8AE8EE400334391BF272DC8E5690167088FC75CED4E0DB21F675E6DD5501EFB1EE25108B9ADDDA9818B0D45FEFFC5FBAEFC2B97751B8D3F298A79BDFDD94CCFB13CCD315E8E8FB3998D48FE17C5BCBEBF7298744391FF7CC4C78B1E658694298BF94A900F8D4F65807FCC27F39C0A779B0F3E9403FA010F4F85E665EF1EA42F3204F9ABB6B99A7426D33F7B56C41D52A9C7B92F3ECC64D8DD4F6798823FA13160CE9080ED7033C197212BE4F6AB79B8CDFDD9214BBB52024D807FA9B298C77E5610BAAA2B35C8642E74F8396ACBFBD27C7607E143425EBF44C0767994C970941572EA40FE01D0E3C84F5F6E711A14B05B118F52C8930EE6B2FC212E6CA405A147108FA2887B1E62C7612EE4AF0E779B773F2DB80A8DAF22F924B9ACB4DB07FC570CE4B2089DC0E7BB1F6787B877240514221E140710CFE5CD7B3D1DD1983D8E8B8127B92C5EFB01FF39790757F77A86A37179F51835E76AC3179BADFBB242AA212E54409781CF47C13BF0075F51613FEB847BCBDE8CE07C880B051A677F3A0771F142C89B07F2989DFDF423BBC13CF6D030D8176494FF9114B0ECCFB4A018B9902747F6055F3AF65BACF7E2815CE6107E074A54F7DE8CF70D921569E282D304ED89E32CB65D686EAA17DE7D23F8C3F2BB29816791ACD887E21AA3B6BA48F343EFE1B8E881385E0D75D3610D0FFCAFF0C7488F6510172D48A717282E042CEFD990FDC7C88D260FD283CB34FE2C11B0A2EE24D3232056513D8AE6222EFE1AEDE9003E7451636FE08904FF08023B2B88B6AC88DBD896E067DF7930B05CF31C90BF6CB6EC7F7DBF7734B2E3B07A5EE62788D9D50302760FB6F7BDBECC10971B713E091AD9C0DE35B712FC507BD749C4B510E23A2BC4FD0A8A8B92D1B8009DE6CD86FC67B66F7018CC63C920FE90BC4AA84FD63DCA0A39FA5CC8553D07BF873A35F6E24E0F27D04DA950CFB9499BF66C59FE2023B85CAEE6514AF3D859A2C88D567DD9217D88073DEB5E0A7D567CA822E43D93967DDE0288D52A842B5F6E76BD1EEB1DF47BA27F553BE046BC4F046A9F5BF7FB94133C406BD8BD79CDB57D5E9EB713FD8FA9797C63C0FE16FFD9EB19FB47923FF11CB00343CFE37B26A286067391586C733C75B743652CDF11E19430CDEE7471865DE5FE6DC47D557AB4FD857F9FB2399E14093C6104ED744996DD99AF04B695719F10F72752763B5C3873D2E6646E829DFA39618E27B363ED2F89C5D6220491C8E6D2A54B9633199F26C96D8AC65FE179A7F1DC915C54DF201B45BD4C24AE7FF95E2496BDC4231ECB8368E29769E206195E672583B2D07508AECD78BECC64DA3617899C013FE969DE6752800E97E1BA749AF25BA0790678864247B24C390D188034739AF2AF0074E0E7BCF2FCD9901F8FEBEF9AA6FCABF5345F3A15CCC4FE688EA95387BE3C9DF4D519F8BF253CA30CCD95CF81FF3CC4F33FD35E7F03CF32C1EB33AFCDB2CF28F0BCF0221DD5FF48873AEC8BCA59B0FFB47D7E92B600B58B227DCB0F40B6B2D5431FC20CFBA43E7DA757DBF524D37C07A5FAB23F5CDB00F4E9F617B4D42148130353AD0F49E8C77D92667C3D0660A3F9F059986746FDC28E19AE39398AD694E3F52C5613ADAFD7A30E31E436618AF6EF066CD2A78F68D12EA07E9D00AED229CA2F817BCE5CCA3E662D538696EB999420F73DB846C1D5D450C671F1FA3D268E41C504F697038E025CE17EBE21CE67A0B539209F138E0BB44EA81AEF1909072CA7E67C2850A0F0FA754A686F13759D8BEB12BC972C9EB44E8BB69E5AA7458102050A142850A04081028599A12F2BC4555512D6A83AC46F7992CB9A748EA5379DB172B8845F07FCAD4379EC4863D6FDD7BD9EF307D13EEE43612AB43EE7791157D29EE46F3511FF2FD15B4DC05E75AA5235FF8B629EAA23396099B1EA7FEA13B745BD198C3E421FB41E0CECD09316BC7DE275A26EA61D49014D64FEFBE9C1BB8CD907AEC57A9791F519C865BD76EFEECF7BB6C60E978CF24B04ACCB37E37D4D8C55FF0B3B3DBC15429E4A1D03612806FA6F1D9838064E7FB2C1F9690147391203429EA23D31C068C794ABB6B95A424CF78FF800A02B35F0D5B56B87F8C43C4525FF4333F8FF6D55E9B6D7C600D8C5D4586C7023DEF72C3906FA739823EB27EFA7331CA0BEAF023469CE65F965CFD642C25F30FF90807DF9F744F59AE3AE94407385908BF6495C93177292BB5283CC0C5DFF4B9F6F0C7B21E48EC4801C62E076A2BF256E1F6B34BE8ECEFEB875C0CFB176C7C7ABC1164A4DBBA18418B8934C5F81F75924937DE9CFD420BAA1EB5F1DEE66DD9FC51C20CB0D7A107B3040AF6B64DF7890C188C3EFB96D0C3D02D15B62BDCBC9F4BF7298D5461203352FC540365388E88D515B93C9BE8ECEA2C36BDDF3C9FCD08F388BE817777AD0C17F08BFC0F5E910D48F7686DF0E7CCC53B7036AB965859CF6E6182F93B39FBA3BA33359467CBD982FBFBEDFC7E6428487FBF3222EB9DD90DC8CF7B3AA56EF73E925D78FE02B6C43D419F49D0F325A68DA81475921237DA161750CB8D67CFA9109D461ED647D7AD283C3CEED7037FB332DE821D9077A33823F23FA14FBBC0F93F921068E189AEEA0AB07E8D80EF2F5435D16AD3EE7CAB79A2CF7400EB384E827477B969263E0EFBCD03A1C032564FDE17BA056BDAEDF838DFAC61ADF7856C8E9F923296081A1E80E316D3690C36AD1D4EBE85DB7C6F9D8377CB199A3D99B82E56E87FEA109D4F7AE2FC58090276FDDEF6B0BB1BE61340688F5FE033713FC2CC0676C1E6731A5645F8218F0379C3E8F9B29C8D332A61F1F097D411BF05539596EA8FF5D511EF0F58E97BE1320066A21061E6692BE1F00DDA941BE443BB0DFE7F44BED4036F3A821F93FF8AE80ECD310038DEA76C0AF8E1C03D00E1031F0DF18AFD231F5FD71F5FE0F9FEA31EDDD6144AFFB7C238E81115FEA694BF0333714FDC147D7A03D1DAAAF4057220EC294D0762F16EDDAC426EC8268F03FF0E9CEDFF6F998A0EF8417A87D40FC008893FE6BFBBC1640AC3346E8A5045D027A5A566F73B37E9C0D31F0357E3EA02BCD70FA4215CCF74C6FC5FBB60D0A58AA27394CD5602E4BD516EF13756A9B8BCDFDB440B4778AA03FC90951B5ECF35A531DB6DEFC4E92FF9004F34B7299AA1B71DE6127F9EBE777260748C8F49B713EC4DE91AB7BB6D48CD259AABB07030CAA2F54C65EBFFA3B8E0BE33BEE8700174639CF6D35A29787AEF754D3009CF58C6FF8EEC49EC86F425D5C47E9C0CF75731A8FFE0D6F03D1172EE37FB418E5D7FCEF5BF63A0F43581B25BE7CC55E24163BD69E3C667DF6D8B716E78E1DB640D71FAA2BADEB2E9CB73F5779C412D108FAF7DF5A9C3F536D7BE9529D7D6DD5F7562374E0AFADAEB4A9BB78C1BEF6C4512B32FF0FA74ED8C0F3ED219F0DBAD7FCEF5CE5775675753FDA13E5ABD74B3A6058CE82DEE680447C769314EDB711375C96822C5271C3157C85FBFA7AF5B58144AF6F40FCD271F9C5F5E3D2097EC83742C710013F3EE3980C74A6D371809D9E74477BA01AE778DF863668D5F59A5FB4461170DE0874D72045C7FAD38D487784161DEB5F6D64FAF7E958FF0E23D3BFFD1FAEFF611DEB5F6B44BA4B747596E32C9CB1AA73BF1FEF371574A0FF02036FFBD17E546F6D7E5761063658ACC5B99A7385DED9D82F84FBDBF978FFABCC80F4AF9AE5EF1F140F4E784FA521E8EF3107DF800B747CEEF27471642EF66E61FDBBE758F73A7DD6795AEC3B9DAB364189CF8A369FE37110819EDB34C9E8EF26A1DF5422CEB81702D619C2D817AE03E57AD23F0DEF875C8DCF2BB19BED3DB15ADAE0B89EFAB00EC630E78B7F5F4AAA63FD8D6A4D1CDEEFAA2BDD8FEBE28CA139B0C12EF27EDF69A2DA50F7036B6903EF697E2348F1D92246ABFB9871E2D831BF5DF73ABDD1B907ABDEB435C1F80C077F40213E93A2179F7F83C692AA00DB01CBDE34BD2950A040810205E339A781FAFBA7FEFD1F628F6DC7]]>
  </Icon>
</ZApplication>
I recommend using a .ico that contains a couple of sizes ( when you don't care about file-size ).

- 16x16 is generally used for the window.
- 32x32 is generally used in the Alt-Tab menu.
- 48x48 ( or bigger ) is generally used on the desktop.

K

User avatar
Rado1
Posts: 771
Joined: Wed May 05, 2010 12:16 pm

Re: Icon

Post by Rado1 » Fri Sep 23, 2016 1:15 pm

Kjell, this is smart solution. Cannot it be integrated into ZGE; why to have this code in (almost) every windows project?

User avatar
Kjell
Posts: 1715
Joined: Sat Feb 23, 2008 11:15 pm

Re: Icon

Post by Kjell » Sun Sep 25, 2016 4:01 pm

Hi Rado1,
Rado1 wrote:Cannot it be integrated into ZGE?
No .. this is only a ( imperfect ) workaround. It still shows the incorrect / original ( IDI_APPLICATION ) icon in the Alt+Tab menu on Windows XP ( due to how icons are cached ) and does so for a couple of frames on ( for example ) Windows 7 as well.

K

Post Reply