well, i'm trying to convert this, http://www.blitzbasic.com/Community/posts.php?topic=46784 ,to Max but it isn't working too well.
Strict Import PUB.Win32 'Must load images with the DYNAMICIMAGE flag AutoImageFlags(MASKEDIMAGE | FILTEREDIMAGE | DYNAMICIMAGE) Local window:TGadget=CreateWindow("Button Image Test",0,0,640,480,Null,WINDOW_TITLEBAR) Local testbutton:TGadget=CreateButton("Click Here",10,10,100,50,window) Repeat WaitEvent() Select EventID() Case EVENT_WINDOWCLOSE End Case EVENT_GADGETACTION Select EventSource() Case testbutton Local file$=RequestFile("Select image load","Image Files:bmp,jpg,png") Local image:TImage=LoadImage(file$,DYNAMICIMAGE) If image If Not SetButtonImage(testbutton,image,True) Notify "Failed to set button's image" Else Notify "Failed to load image" EndIf End Select End Select Forever ?Win32 Extern "win32" Function SetWindowLong(hWnd ,nIndex,lNewLong )= "SetWindowLongA@12" Function GetModuleHandle:Int(lMod)="GetModuleHandleA@4" Function GetWindowLong(hWnd ,nIndex)="GetWindowLongA@8" Function CreateBitmap(nWidth,nHeight,cPlanes,cBitsPerPixel,lpvBits:Byte Ptr) Function LoadBitmap(hInstance,lpBitmapName:Byte Ptr)="LoadBitmapW@8" Function GetBitmapDimensionEx(hBitmap,lpDimension:Byte Ptr) Function DeleteObject(obj) End Extern Const BM_SETIMAGE=247 Const IMAGE_BITMAP=0 Const IMAGE_ICON=1 Const BS_BITMAP=128 Const GWL_STYLE=-16 Const LR_DEFAULTSIZE=64 Const LR_LOADFROMFILE=16 Const LR_SHARED=32768 ? Rem bbdoc: Set the image of a TWin32Gadget returns: #brl.blitz.True if successful, #brl.blitz.False if not. End Rem Function SetButtonImage(button:TGadget,image:TImage,resize=True) ?MacOS Return False ?Linux Return False ?Win32 Local hbutton=QueryGadget(button,QUERY_HWND) Local flags=GetWindowLong(hbutton,GWL_STYLE) If image<>Null If flags&BS_BITMAP=0 SetWindowLong hbutton,GWL_STYLE,flags|BS_BITMAP Else If flags&BS_BITMAP SetWindowLong hbutton,GWL_STYLE,flags-BS_BITMAP Return EndIf Local w=ImageWidth(image) Local h=ImageHeight(image) Local ibuffer:TPixmap=LockImage(image,0,True,True) Local pixels:TBank=CreateBank(w*h*4) For Local y=0 To h-1 For Local x=0 To w-1 PokeInt pixels,4*((y*w)+x)+0,ReadPixel(ibuffer,x,y) Next Next UnlockImage image Local i=CreateBitmap(w,h,1,32,pixels) If Not i Return If resize SetGadgetShape button,GadgetX(button),GadgetY(button),w,h EndIf Local oldimage=SendMessageA(hbutton,BM_SETIMAGE,IMAGE_BITMAP,i) If oldimage DeleteObject(oldimage) Return True ? End Function