Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Oct 20, 2018 2:26 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Use External file for ICON set in windows
PostPosted: Wed Apr 18, 2012 6:13 am 
Offline

Joined: Tue Dec 27, 2011 8:54 am
Posts: 139
Location: India
Hi All,

Is there any way to set the icon in the application bar or title bar of the windows dynamically using the external file and it should work for both MAC and Win Os.


Thanks,
Prakash

_________________
PK Pothal
Software Developer in REAL STUDIO 2011r4.3, ASP.NET, VB.NET, C# AND SQL SERVER 2005/08
OS:WINDOWS N MAC


Top
 Profile  
Reply with quote  
 Post subject: Re: Use External file for ICON set in windows
PostPosted: Wed Apr 18, 2012 3:28 pm 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
For Mac, the icon is generally set in the plist file for the application. For windows you will need to use API to change the icon in the EXE's resource header.

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
Reply with quote  
 Post subject: Re: Use External file for ICON set in windows
PostPosted: Tue May 29, 2012 6:12 pm 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
There's not a way I know of to do this in a cross-platform-friendly way. You will need to use conditional compilation. For Windows, this should do what you want:

Sub SetIcon(Extends TargetWindow As Window, IconFile As FolderItem)
//Only works for .ICO, .CUR, and .ANI files as IconFile

Declare Function SendMessageW Lib "User32" (HWND As Integer, Message As Integer, _
WParam As Integer, LParam As Integer) As Integer
Declare Function GetSystemMetrics Lib "User32" (nIndex As Integer) As Integer
Declare Function LoadImageW Lib "User32" (ModuleHandle As Ptr, Path As WString, _
Type As Integer, cx As Integer, cy As Integer, LoadFrom As Integer) As Integer

Const LR_LOADFROMFILE = &h00000010
Const WM_SETICON = &h0080

Dim SM_CXICON As Integer = GetSystemMetrics(11)
Dim SM_CYICON As Integer = GetSystemMetrics(12)
Dim hIcon As Integer = LoadImageW(Nil, IconFile.AbsolutePath, 1, SM_CXICON, SM_CYICON, LR_LOADFROMFILE)

Call SendMessageW(TargetWindow.Handle, WM_SETICON, 0, hIcon)
End Sub

_________________
Boredom Software


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group