【HSP3.x 移植版】『HSPの裏技』イメージリストを使ってみる

『HSPの裏技』イメージリストを使ってみる(HSP2.x 版)をHSP3.x バージョンへ書き換えたものです。
http://chokuto.ifdef.jp/urawaza/imagelist.html

※このサンプルで読み込まれるビットマップファイル iconlist.bmp は上記URLで公開されているものを使用することを仮定しています。

『HSPの裏技』イメージリストを使ってみる(HSP2.x 版)をHSP3.x バージョンへ書き換えたものです。
http://chokuto.ifdef.jp/urawaza/imagelist.html

※このサンプルで読み込まれるビットマップファイル iconlist.bmp は上記URLで公開されているものを使用することを仮定しています。

  • タグ:
  • タグはありません
;HSP3.x
;HSP使
; http://chokuto.ifdef.jp/urawaza/imagelist.html
; ※ iconlist.bmp URL使
;
; []Advanced HSP
; http://chokuto.ifdef.jp/advanced/bitmapobject.html
#module ;###### #########
#uselib "gdi32.dll"
#cfunc CreateCompatibleDC "CreateCompatibleDC" int
#cfunc CreateCompatibleBitmap "CreateCompatibleBitmap" int, int, int
#func SelectObject "SelectObject" int, int
#func BitBlt "BitBlt" int, int, int, int, int, int, int, int, int
#func DeleteDC "DeleteDC" int
#func DeleteObject "DeleteObject" int
#define SRCCOPY 0x00CC0020
; DIB
#defcfunc CreateDIB int px, int py, int sx, int sy
; DIB
hBitmap = CreateCompatibleBitmap(hdc, sx, sy)
;
hdcMemory = CreateCompatibleDC(hdc)
;
SelectObject hdcMemory, hBitmap
hOldBitmap = stat
; HSP
BitBlt hdcMemory, 0, 0, sx, sy, hdc, px, py, SRCCOPY
;
SelectObject hdcMemory, hOldBitmap
;
DeleteDC hdcMemory
; (DIB)
return hBitmap
; DIB
#deffunc DeleteDIB int hbmp
;
DeleteObject hbmp
return
#global ;############# ########################
#module ;########### ##############
#uselib "comctl32.dll"
#cfunc ImageList_Create "ImageList_Create" int,int,int,int,int
#func ImageList_Destroy "ImageList_Destroy" int
#func ImageList_AddMasked "ImageList_AddMasked" int,int,int
#func ImageList_Draw "ImageList_Draw" int,int,int,int,int,int
#define global ILC_COLOR 0x0000
#define global ILC_COLOR4 0x0004
#define global ILC_COLOR8 0x0018
#define global ILC_COLOR16 0x0010
#define global ILC_COLOR24 0x0018
#define global ILC_COLOR32 0x0020
#define global ILC_COLORDDB 0x00FE
#define global ILC_MASK 0x0001
#define ILD_TRANSPARENT 0x0001
;
#defcfunc CreateImageList int sx, int sy, int type, int num
return ImageList_Create(sx, sy, type, num, 0)
;
#deffunc DestroyImageList int handle
ImageList_Destroy handle
return
;
#deffunc AddImageListItem int handle, int cx, int cy, int sx, int sy, int maskColor
; DIB
hDIB = CreateDIB(cx, cy, sx, sy)
;
ImageList_AddMasked handle, hDIB, maskColor
firstItemIndex = stat
; DIB
DeleteDIB hDIB
return firstItemIndex
;
#deffunc DrawImageListItem int handle, int index, int cx, int cy
ImageList_Draw handle, index, hdc, cx, cy, ILD_TRANSPARENT
return
#global ;############# ########################
;
buffer 2,,, 0 ;
picload "iconlist.bmp"
; 24bit DIB ()
hImgList1 = CreateImageList(32, 32, ILC_COLOR24, 4)
AddImageListItem hImgList1, 0, 0, 32*4, 32
; 24bit DIB ()
hImgList2 = CreateImageList(32, 32, ILC_COLOR24 | ILC_MASK, 4)
AddImageListItem hImgList2, 0, 0, 32*4, 32, 0xF0CAA6
gsel 0
cls 3 ;
pos 20, 10 : mes ""
repeat 4
DrawImageListItem hImgList1, cnt, 40*cnt+30, 30
loop
pos 20, 80 : mes ""
repeat 4
DrawImageListItem hImgList2, cnt, 40*cnt+30, 100
loop
redraw ; redraw
onexit goto *OnExitApp
stop
*OnExitApp
;
DestroyImageList hImgList1
DestroyImageList hImgList2
end
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX