$ filename "Windows_Icons.exe"
'uses rtl32
'uses rtl64
uses WinUtil
% SM_CXICON=11
% SM_CYICON=12
% LVS_ICON=0
% LVIF_TEXT=1
% LVIF_IMAGE=2
% LVSIL_NORMAL=0
% LVM_SETIMAGELIST=4099
% LVM_INSERTITEM=4103
% LVM_DELETEALLITEMS=4105
% LVM_ARRANGE=4118
% ILC_COLOR32=32
% ILC_MASK=1
% LVA_ALIGNTOP=2
type LVITEM
uint mask
int iItem
int iSubItem
uint state
uint stateMask
char* pszText
int cchTextMax
int iImage ' index of the list view item's icon
sys lParam ' 32-bit value to associate with item
int iIndent
int iGroupId
uint cColumns
uint *puColumns
int *piColFmt
int iGroup
end type
typedef LVITEM LV_ITEM
' create a structure of INITCOMMONCONTROLSEX
INITCOMMONCONTROLSEXt iccex
iccex.dwSize=sizeof(iccex)
'Register Common Controls
iccex.dwICC= 0xffff
'Menu Ids
% IDM_EXIT=1000
% ID_DLLs=2000
% ID_EXEs=3000
sys hListView=0
string DllFiles[]={
"Shell32.dll", "MorIcons.dll", "ImageRes.dll", "IeFrame.dll", "Netshell.dll",
"GameUx.dll", "User32.dll", "Cryptui.dll", "AccessibilityCpl.dll", "mmcndmgr.dll",
"mmres.dll", "netCenter.dll", "networkexplorer.dll", "pifmgr.dll", "pniDui.dll",
"remotepg.dll", "sdcpl.dll", "setupAPI.dll", "SensorsCpl.dll", "shellbrd.dll",
"Actioncenter.dll", "DDORes.dll"
}
string ExeFiles[]={
"Explorer.exe", "Control.exe", "Mobsync.exe", "WinLogon.exe"
}
declare function initMenu(sys hWnd) as sys
declare sub DisplayIcons(sys hListView, string ResFile)
sys hInstance=inst
MainWindow 580,460,WS_OVERLAPPEDWINDOW
function WndProc(sys hwnd, uMsg, wParam, lParam) as sys callback
select uMsg
case WM_CREATE
SetWindowText(hwnd, "View Windows System Icons")
sys hMenu = InitMenu(hWnd)
if SetMenu( hWnd, hMenu ) = 0 then mbox "SetMenu hMenu failed!"
'create a list view control
hListView=CreateWindowEx(WS_EX_CLIENTEDGE, 'extended styles
"SysListView32", 'class
null, 'title
WS_CHILD + WS_VISIBLE + LVS_ICON, 'window style
0,0,0,0, 'left, top, width, height
hwnd, 'parent window handle
null, 'handle to menu
hInstance, 'application instance
null) 'user defined data
if hListView=0 then mbox "Could not create ListView"
case WM_COMMAND
sys id=loword(wParam)
'sys event=hiword(wParam)
int dlo=ID_DLLs+1
int dhi=ID_DLLs+countof(DllFiles)
int elo=ID_EXEs+1
int ehi=ID_EXEs+countof(ExeFiles)
select id
case IDM_EXIT
Sendmessage(hwnd, WM_CLOSE, 0,0)
case dlo to dhi
sys idx=id-ID_DLLs
DisplayIcons(hListView, DllFiles[idx])
case elo to ehi
sys idx=id-ID_EXEs
DisplayIcons(hListView, ExeFiles[idx])
end select
case WM_SIZE
'resize list view to fill client area of parent
MoveWindow( hListView,0,0,loword(lParam),hiword(lParam), true )
'arrange items
SendMessage( hListView,LVM_ARRANGE,LVA_ALIGNTOP,0 )
case WM_CLOSE
DestroyWindow(hwnd)
case WM_DESTROY
PostQuitMessage(0)
case else
return DefWindowProc(hwnd, uMsg, wParam, lParam)
end select
return 0
end function
==========================================================
function initMenu(sys hWnd) as sys
sys hMenu, hMenupopup
int x, id
hMenu = CreateMenu
hMenuPopup = CreateMenu
AppendMenu hMenu, MF_POPUP, hMenuPopup, "&File"
AppendMenu hMenuPopup, MF_STRING, IDM_EXIT, "E&xit"
hMenuPopup = CreateMenu
AppendMenu hMenu, MF_POPUP, hMenuPopup, "&DLL Files"
id=0
for x=1 to countof(DllFiles)
id++
AppendMenu hMenuPopup, MF_STRING, id+ID_DLLs, DllFiles[id]
next x
hMenuPopup = CreateMenu
AppendMenu hMenu, MF_POPUP, hMenuPopup, "&Exe Files"
id=0
for x=1 to countof(ExeFiles)
id++
AppendMenu hMenuPopup, MF_STRING, id+ID_EXEs, ExeFiles[id]
next x
return hMenu
end function
sub DisplayIcons(sys hListView, string ResFile)
indexbase 0
int numIcons
numIcons = ExtractIcon( null, ResFile, -1 )
if numIcons=null then
mbox "No Icons in " ResFile " or " ResFile " does not exist"
exit sub
end if
redim int resource_icons(0)
redim int resource_icons(numIcons)
int iIcon
for iIcon = 0 to <numIcons
resource_icons[iIcon] = ExtractIcon(null, ResFile, iIcon)
next iIcon
static sys hIcons
if hIcons then
SendMessage(hListView, LVM_DELETEALLITEMS, 0,0)
ImageList_Destroy(hIcons)
end if
'create the new image lists
'hIcons=ImageList_Create( GetSystemMetrics( SM_CXICON ), GetSystemMetrics( SM_CYICON ), ILC_COLOR32 | ILC_MASK,1,1 )
hIcons=ImageList_Create( 48, 48, ILC_COLOR32 | ILC_MASK,1,1 )
'add icons to imagelists.
LV_ITEM lvi
int i
for i = 0 to <numIcons
ImageList_AddIcon( hIcons,resource_icons[i] )
DestroyIcon( resource_icons[i] )
next i
'attach image lists to list view common control
SendMessage( hListView, LVM_SETIMAGELIST, LVSIL_NORMAL, hIcons )
'add the items to the the list view common control
lvi.mask = LVIF_TEXT | LVIF_IMAGE
for i=0 to <numIcons
'the zero-based item index
lvi.iItem=i
'convert item index to string (+1)
string pText=str(i+1)
lvi.pszText = pText
lvi.cchTextMax = len(pText)
lvi.iImage = i
SendMessage( hListView,LVM_INSERTITEM,0, &lvi )
next i
SetWindowText(GetParent(hListView), ResFile)
end sub