I have created some images to use as buttons.
They are not displaying exactly as they should.
I am displaying them from a .dll file, as shown by SKAN, here:
http://www.autohotkey.com/forum/viewtopic.php?t=9980&postdays=0&postorder=asc&start=15
Code:
addcheckbox(cb_var,cb_color,options,cb_on =false,cb_gui =1,cb_subroutine ="togglecheckboxpng")
{
global
static handlecount
if handlecount<1
handlecount=1
handlecountplus:=handlecount+1
cb_temppic1:="cb_pic" . handlecount
cb_temppic2:="cb_pic" . handlecountplus
Gui, %cb_gui%:Add, Text,g%cb_subroutine% v%cb_var%onn %options% +0xE hWnd%cb_temppic1% ; +0xE is SS_BITMAP
cbt1:=%cb_temppic1%
Gui, %cb_gui%:Add, Text,g%cb_subroutine% v%cb_var%off %options% xp yp +0xE hWnd%cb_temppic2% ; +0xE is SS_BITMAP
displaypng(%cb_temppic1%,%cb_color%checkboxoniconum)
displaypng(%cb_temppic2%,%cb_color%checkboxofficonum)
if cb_on
{
guicontrol,hide,% cb_var . "off"
%cb_var%:=true
}
handlecount+=2
return
}
displaypng(pic,resourceno) ; DISPLAYS A PNG FROM A RESOURCE FILE
{
global hModule
LoadResourceImage(resourceno,pic,hModule)
return
}
LoadResourceImage(ResNo,hImage,ByRef hModule,x =0,y =0)
{
global hBitmap
;msgbox,,,%hBitmap%::%resno%::%hImage%:::%hModule%
DllCall( "DeleteObject", UInt,hBitmap )
hJpegData := GetResource( hModule, ResNo, 10, nSize, hresData )
DllCall( "FreeResource", UInt,hResData )
hBitmap := gdiBitmap( hJpegData, nSize, wxh )
if ((x<>0) or (y<>0))
{
new_hBitmap := DllCall("CopyImage",UInt, hBitmap,UInt,0,Int,x,Int,y, UInt,0)
hBitmap:=new_hBitmap
new_hBitmap:=""
}
SendMessage, 0x172, 0x0, hBitmap,, ahk_id %hImage%
Return
}
GetResource( hModule, rName, rType, ByRef nSize, ByRef hResData ) {
hResource := DllCall( "FindResource", UInt,hModule, UInt,rName, UInt,rType )
nSize := DllCall( "SizeofResource", UInt,hModule, UInt,hResource )
hResData := DllCall( "LoadResource", UInt,hModule, UInt,hResource )
Return DllCall( "LockResource", UInt, hResData )
}
gdiBitmap( Buffer, nsize, byref wxh ) {
; Sean : http://www.autohotkey.com/forum/viewtopic.php?p=147029#147029
hData := DllCall("GlobalAlloc", UInt,2, UInt, nSize )
pData := DllCall("GlobalLock", UInt,hData )
DllCall( "RtlMoveMemory", UInt,pData, UInt,Buffer, UInt,nSize )
DllCall( "GlobalUnlock", UInt,hData )
DllCall( "ole32\CreateStreamOnHGlobal", UInt,hData, Int,True, UIntP,pStream )
DllCall( "gdiplus\GdipCreateBitmapFromStream", UInt,pStream, UIntP,pBitmap )
DllCall( "gdiplus\GdipCreateHBITMAPFromBitmap", UInt,pBitmap, UIntP,hBitmap, UInt,8 )
DllCall( "gdiplus\GdipGetImageWidth" , "Uint", pBitmap, "UintP", nW)
DllCall( "gdiplus\GdipGetImageHeight", "Uint", pBitmap, "UintP", nH), wxh := nW "x" nH
DllCall( "gdiplus\GdipDisposeImage", UInt,pBitmap )
return hbitmap
}
Here is what it should look like:
And here is what it displays as:
