nomainwin
WindowWidth = 800
WindowHeight = 600
graphicbox #w.gb, 0, 0, 0, 0
open "Graphicbox resize" for window as #w
do
filedialog "Select a BMP file", "*.bmp", bmpfile$
#w.gb "cls; down; fill buttonface"
#w "refresh"
if bmpfile$ = "" then close #w : end
loadbmp "bitmap", bmpfile$
hbitmap = hbmp("bitmap")
struct bitmap, bmType as long, bmWidth as long, bmHeight as long, _
bmWidthBytes as long, bmPlanes as word, _
bmBitsPixel as word, bmBits as ptr
size = len(bitmap.struct)
calldll #gdi32, "GetObjectA", hbitmap as ulong, size as long, _
bitmap as struct, ret as long
width = bitmap.bmWidth.struct
height = bitmap.bmHeight.struct
xpos = int((WindowWidth - width) / 2)
ypos = int((WindowHeight - height) / 2)
#w.gb "locate ";xpos;" ";ypos;" ";width;" ";height
#w.gb "drawbmp bitmap 0 0"
#w "refresh"
loop until 0
wait
nomainwin
WindowWidth = 800
WindowHeight = 600
graphicbox #w.gb, 0, 0, 0, 0
open "Graphicbox resize" for window as #w
do
filedialog "Select a BMP file", "*.bmp", bmpfile$
#w.gb "cls; down; fill buttonface"
#w "refresh"
if bmpfile$ = "" then close #w : end
loadbmp "bitmap", bmpfile$
hbitmap = hbmp("bitmap")
struct bitmap, bmType as long, bmWidth as long, bmHeight as long, _
bmWidthBytes as long, bmPlanes as word, _
bmBitsPixel as word, bmBits as ptr
size = len(bitmap.struct)
calldll #gdi32, "GetObjectA", hbitmap as ulong, size as long, _
bitmap as struct, ret as long
width = bitmap.bmWidth.struct
height = bitmap.bmHeight.struct
xpos = int((WindowWidth - width) / 2)
ypos = int((WindowHeight - height) / 2)
#w.gb "locate ";xpos;" ";ypos;" ";width;" ";height
#w "refresh"
scan
#w.gb "drawbmp bitmap 0 0; flush"
loop until 0
wait