#include once "window9.bi"

Function ImageGadget(ByVal gadget As Long, _
                    ByVal x As Long, ByVal y As Long, _
                    ByVal w As Long, ByVal h As Long, _
                    ByVal imageId As Any ptr, _
                    byval ExStyle As Long, _
                    byval Style As Long) As HWND Export
    var hWin= CreateWindowEx(iif(ExStyle,WS_EX_CLIENTEDGE,0), "static", 0, SS_NOTIFY Or WS_CHILD Or WS_VISIBLE Or Style, x,y,w,h, win9GetCurrent(), Cast(HMENU,CInt(gadget)), 0, 0)
    If imageId<>0 Then 
        If Style = SS_BITMAP Then
            SendMessage(hWin, STM_SETIMAGE, IMAGE_BITMAP, Cast(LPARAM,imageId))
        Else
            SendMessage(hWin, STM_SETIMAGE, IMAGE_ICON, Cast(LPARAM,imageId))
        EndIf
    EndIf
    win9AddNewGadget(gadget,hWin)
    Return hWin
End Function
