December 07, 2019, 09:50:51 pm

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


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:

Code Select
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:

Code Select
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

Code Select
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


Code Select
' 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.