Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun May 28, 2017 7:20 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: WINDOWS ICON EXTRACTOR
PostPosted: Tue Dec 13, 2011 5:46 pm 
Offline
User avatar

Joined: Sat May 27, 2006 3:27 pm
Posts: 480
Hello everyone i wanted to share a code that extract all your windows system32 icons on to a canvas !

I hope this helps when you want to use an external icons from the system :p!!

1. Drag a canvas and a button onto your Window
3. Make a Module with a Global Integer named IconNumber

Module Code

Sub Function GetSystemIcon() As Picture
'http://msdn.microsoft.com/en-us/library/windows/desktop/ms648069%28v=vs.85%29.aspx

Try
#if TargetWin32
Soft Declare Function ExtractIconExA Lib "Shell32" ( lpszFile As CString, ByVal nIconIndex As Integer,phiconLarge As ptr, phiconSmall As ptr, ByVal nIcons As Integer ) As Integer
Soft Declare Function ExtractIconExW Lib "Shell32" ( lpszFile As WString, ByVal nIconIndex As Integer,phiconLarge As ptr, phiconSmall As ptr, ByVal nIcons As Integer ) As Integer
Declare Function DrawIconEx Lib "user32" ( hDC As Integer, xLeft As Integer, yTop As Integer,hIcon As Integer, cxWidth As Integer, cyWidth As Integer, istepIfAniCur As Integer,hbrFlickerFreeDraw As Integer, diFlags As Integer ) As Integer
Declare Function DestroyIcon Lib "user32" ( hIcon As Integer ) As Integer

Const DI_COMPAT = &H4
Const DI_DEFAULTSIZE = &H8
Const DI_IMAGE = &H2
Const DI_MASK = &H1
Const DI_NORMAL = &H3

Dim hIcon As Integer

Dim M As New MemoryBlock(4)
If System.IsFunctionAvailable( "ExtractIconExW", "Shell32" ) Then
hIcon = ExtractIconExW(SpecialFolder.System.Child("shell32.dll ").AbsolutePath, IconNumber, m, m, 1) 'WINDOWS/System32
Call ExtractIconExW(SpecialFolder.System.Child("shell32.dll ").AbsolutePath, IconNumber, m, m, 1)
IconNumber=IconNumber+1
Else
hIcon = ExtractIconExA(SpecialFolder.System.Child("shell32.dll ").AbsolutePath, IconNumber, m, m, 1) 'WINDOWS/System32
Call ExtractIconExA(SpecialFolder.System.Child("shell32.dll ").AbsolutePath, IconNumber, m, m, 1)
IconNumber=IconNumber+1
End if

If hIcon = 2 Then
Dim P As New Picture(24,24,32) '24x24 32 bits
Call DrawIconEx(P.Graphics.Handle(1) , 0, 0, M.Long(0) ,24, 24, 0, 0 , DI_NORMAL)
Call DestroyIcon( M.Long(0) )
Return P

ElseIf hIcon = 0 Then
MsgBox Str( IconNumber ) + " images found."
IconNumber=0
End
#endif
Catch Err As NilObjectException
Exit
Catch Err As OutOfBoundsException
Exit
End Try


Button Code

Canvas1.Backdrop = GetSystemIcon
Me.Caption = "Next ("+Str(IconNumber)+")"


Last edited by sinner on Thu Dec 15, 2011 1:21 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: WINDOWS ICON EXTRACTOR
PostPosted: Tue Dec 13, 2011 8:04 pm 
Offline

Joined: Fri Sep 30, 2005 10:49 pm
Posts: 504
Thanks,
But suppose I want to extract the icon of a folderitem how do I do that?
Lennox


Top
 Profile  
 
 Post subject: Re: WINDOWS ICON EXTRACTOR
PostPosted: Wed Dec 14, 2011 8:30 am 
Offline
User avatar

Joined: Sat May 27, 2006 3:27 pm
Posts: 480
lenpartico wrote:
Thanks,
But suppose I want to extract the icon of a folderitem how do I do that?
Lennox


use a folderitem same way i got the system32 icons

"untested"

Sub Function GetSystemIcon( f As FolderItem ) As Picture
'Call ExtractIconExW(SpecialFolder.System.Child("shell32.dll ").AbsolutePath, IconNumber, m, m, 1)

Call ExtractIconExW(f.AbsolutePath, IconNumber, m, m, 1)
End Sub


Call It like this

Dim f As FolderItem = SpecialFolder.System.Child("shell32.dll ")
Canvas1.Backdrop = GetSystemIcon( f )


Top
 Profile  
 
 Post subject: Re: WINDOWS ICON EXTRACTOR
PostPosted: Wed Dec 14, 2011 11:10 am 
Offline

Joined: Fri Sep 30, 2005 10:49 pm
Posts: 504
Thanks,
I will try it later.
Lennox


Top
 Profile  
 
 Post subject: Re: WINDOWS ICON EXTRACTOR
PostPosted: Wed Dec 14, 2011 5:40 pm 
Offline

Joined: Fri Sep 30, 2005 10:49 pm
Posts: 504
Tried it but was unsuccessful

I don't know if it was done correctly, but the project can be downloaded here

http://www.mediafire.com/?f2516mmw26bi607

Any suggestions?

Thanks again.

Lennox


Top
 Profile  
 
 Post subject: Re: WINDOWS ICON EXTRACTOR
PostPosted: Thu Dec 15, 2011 12:12 am 
Offline
User avatar

Joined: Sat May 27, 2006 3:27 pm
Posts: 480
Try this

http://hotfile.com/dl/137542620/4450408 ... n.rbp.html


Top
 Profile  
 
 Post subject: Re: WINDOWS ICON EXTRACTOR
PostPosted: Thu Dec 15, 2011 9:30 am 
Offline

Joined: Fri Sep 30, 2005 10:49 pm
Posts: 504
Thanks sinner,

Absolutely fantastic for .exe

Would it be too much to ask for it to be modifies to accommodate, files, folders and aliases?

If not, it would be greatly appreciated.

Thanks again.

Lennox


Top
 Profile  
 
 Post subject: Re: WINDOWS ICON EXTRACTOR
PostPosted: Fri Jun 29, 2012 6:45 am 
Offline
User avatar

Joined: Thu Jun 28, 2007 9:09 am
Posts: 14
Location: Belfast, N.Ireland
I know im gonna get grilled for this, but how do make a Module with a Global Integer named IconNumber? :oops:

_________________
C:/Program Run... C:/Program Crash... C:/Programmer Quit!


Top
 Profile  
 
 Post subject: Re: WINDOWS ICON EXTRACTOR
PostPosted: Sun Jul 08, 2012 12:59 am 
Offline

Joined: Mon Aug 15, 2011 10:25 pm
Posts: 293
- click on the "Project" tab
- right-click and select Add to Project > Module
- open the module
- add a property named "IconNumber" as Integer


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

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group