IonicWind Software

IWBasic => General Questions => Topic started by: Andy on September 08, 2018, 06:26:04 AM

Title: Resource and region button
Post by: Andy on September 08, 2018, 06:26:04 AM
I'm trying to add in to my exe file all the bitmaps, and that's gone okay.

But I have a region button:

if LoggedIn = 1
hrgn3 = RGNFROMBITMAP(getstartpath() + "menulogout.bmp")
else
hrgn3 = RGNFROMBITMAP(getstartpath() + "menulogin.bmp")
endif

SETCONTROLCOLOR mainmenu,BUT_login,RGB(0,0,0),RGB(0,0,0)
SETBUTTONRGN mainmenu,BUT_login,hrgn3

if LoggedIn = 1
   SETBUTTONBITMAPS mainmenu,BUT_login,LOADIMAGE(getstartpath() + "menulogout.bmp",@IMGBITMAP),0,0
               else
   SETBUTTONBITMAPS mainmenu,BUT_login,LOADIMAGE(getstartpath() + "menulogin.bmp",@IMGBITMAP),0,0
               endif


Is there a way to get the above code to use:

1012 BITMAP "c:\\hairdressing\\MenuLogin.bmp"
1014 BITMAP "c:\\hairdressing\\MenuLogout.bmp"


from my resource file instead?

i.e. use say 1012 instead of getstartpath.......

Can't seem to get it to work.

Thanks,
Andy.
:)
Title: Re: Resource and region button
Post by: fasecero on September 08, 2018, 07:43:32 AM
The code from Brian's post should work

EXTERN _hinstance as uint

sub load_bitmap(imgno:int,w:int,h:int),uint
string bname
uint hBitmap2
hBitmap2=0
bname="#"+ltrim$(str$(imgno))
hBitmap2 = LoadImageA(_hinstance, bname, IMAGE_BITMAP, w,h, 0)
return hBitmap2
endsub


' Non-tested code
int width = ...
int height = ...
UINT hbit = load_bitmap(1012,width,height)
SETBUTTONBITMAPS mainmenu,BUT_login,hbit,0,0
Title: Re: Resource and region button
Post by: Andy on September 09, 2018, 03:17:41 AM
Fasecero,

Thanks!

Yes that worked, and now my program has all the images embedded into the exe itself, so that's much more tidy.

Thanks again.

Andy.
:)