求助_GUIImageList_AddIcon加截ICO出现马赛克
本帖最后由 lhy6456210 于 2012-7-15 15:43 编辑代码#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work
_Main()
Func _Main()
Local $hImage, $hListView
GUICreate("ListView Set Outline Color", 800, 600)
$hListView = GUICtrlCreateListView("", 2, 2, 780,580)
GUICtrlSetStyle($hListView, $LVS_ICON)
; Enable extended control styles
_GUICtrlListView_SetExtendedListViewStyle($hListView, $LVS_EX_BORDERSELECT)
GUISetState()
; Load images
$hImage = _GUIImageList_Create(48,48,5)
_GUIImageList_Add($hImage, _GUIImageList_AddIcon($hImage,"d:\ico.ico"))
_GUICtrlListView_SetImageList($hListView, $hImage, 0)
; Add columns
_GUICtrlListView_AddColumn($hListView, "Items")
; Add items
_GUICtrlListView_AddItem($hListView, "A01", 0)
_GUICtrlListView_AddItem($hListView, "A02", 0)
_GUICtrlListView_AddItem($hListView, "A03", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
_GUICtrlListView_AddItem($hListView, "A01", 0)
_GUICtrlListView_AddItem($hListView, "A02", 0)
_GUICtrlListView_AddItem($hListView, "A03", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
; Set outline color
_GUICtrlListView_SetOutlineColor($hListView, 0x0000FF)
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main
ICO在附件里
继续等待,,等到花开花落 这个小弟不懂,琢磨着会不会是数值 的失误 _GUIImageList_Create(48,48,5)的问题。把48改成32试试。 21行 改为 _GUIImageList_AddIcon($hImage, "d:\ico.ico", 0, 1)
不过,_GUIImageList_Create 貌似最大只支持装入 32 * 32,大于该数值的都会被像素放大。如无特殊要求,应该使用 32 * 32,否则,应该载入位图,而非 Icon 在WGLM回了,这也补上吧:
代码:
**** Hidden Message ***** 回复 7# sliqi
都是抄来的{:face (84):} 按照位图解析了吧 。。。 看看需要回复的东西 本帖最后由 user3000 于 2012-7-16 07:11 编辑
回复学习下鬼下的相关代码.
(最近很懒, 几乎不想打字, 鬼鬼为什么还隐藏代码?)
补充:
没看到哪里有7楼有提到的跟 GDI 有关的代码. 回复sliqi
都是抄来的
benkel 发表于 2012-7-15 23:12 http://www.autoitx.com/images/common/back.gif
网盟群里你解释了半天。 五楼说的对。 回复 12# lpxx
L老师{:face (238):} 老鬼威武。。 #include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <winapiex.au3>
$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work
_Main()
Func _Main()
Local $hImage, $hListView
GUICreate("ListView Set Outline Color", 800, 600)
$hListView = GUICtrlCreateListView("", 2, 2, 780,580)
GUICtrlSetStyle($hListView, $LVS_ICON)
; Enable extended control styles
_GUICtrlListView_SetExtendedListViewStyle($hListView, $LVS_EX_BORDERSELECT)
GUISetState()
; Load images
$hImage = _GUIImageList_Create(48,48,5,1)
_GUIImageList_Add($hImage, __GUIImageList_AddIcon($hImage,"ico.ico",0))
_GUICtrlListView_SetImageList($hListView, $hImage, 0)
; Add columns
_GUICtrlListView_AddColumn($hListView, "Items")
; Add items
_GUICtrlListView_AddItem($hListView, "A01", 0)
_GUICtrlListView_AddItem($hListView, "A02", 0)
_GUICtrlListView_AddItem($hListView, "A03", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
_GUICtrlListView_AddItem($hListView, "A01", 0)
_GUICtrlListView_AddItem($hListView, "A02", 0)
_GUICtrlListView_AddItem($hListView, "A03", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
_GUICtrlListView_AddItem($hListView, "A04", 0)
; Set outline color
_GUICtrlListView_SetOutlineColor($hListView, 0x0000FF)
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main
Func __GUIImageList_AddIcon($hWnd, $sFile, $iIndex = 0)
Local $iRet
$iRet = _WinAPI_ShellExtractIcon($sFile, $iIndex, _GUIImageList_GetIconWidth($hWnd), _GUIImageList_GetIconWidth($hWnd))
If $iRet <= 0 Then Return SetError(-1, $iRet, 0)
Local $hIcon = $iRet
$iRet = _GUIImageList_ReplaceIcon($hWnd, -1, $hIcon)
_WinAPI_DestroyIcon($hIcon)
If $iRet = -1 Then Return SetError(-2, $iRet, 0)
Return $iRet
EndFunc ;==>__GUIImageList_AddIcon
页:
[1]
2