March 28, 2024, 02:21:05 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Resource and region button

Started by Andy, September 08, 2018, 06:26:04 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

September 08, 2018, 06:26:04 AM Last Edit: September 08, 2018, 06:28:07 AM by Andy
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.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

fasecero

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

Andy

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.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.