December 06, 2022, 11:08:44 AM

News:

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


Loading Scalable Image from ressource in the window background

Started by StormAce, March 08, 2016, 05:48:24 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

StormAce

Hi,
I'm trying to load a Scalable Image from ressource in my window background

Here's my code so far... can't seems to get it working



CImage BackGroundImage;

MyWindow::OnCreate(), int
{
     Unsigned int hImage = LoadImageA(GetModuleHandleA(null),"75",null,null,null,null); //is resource id
     BackGroundImage.Attach(hImage);
     ShowBackGroundImage();
}


MyWindow::ShowBackGroundImage()
{
    RECT size = GetClientRect();
    BackGroundImage.Render(this,0,0,size.right-size.left,size.bottom-size.top);
return;
}

MyWindow::OnPaint(),INT
{
ShowBackGroundImage();
return true;
}



this code will not compile as is... just an example of what im doing ;)


Andy

Hi,

In IWB you do it this way:

'In the project .rc file add a line like this - where 2 = an image number to use:
2 RTIMAGE "C:\\Project\\Enhanced\\something.jpg"

' Note - you can use Notepad to create / edit a project.rc file
' - AND you must name the .rc file THE SAME AS your project
' E.g. MyProject.iwp ---- .rc file is named MyProject.rc

'In your program - make room for imiages to be loaded.
INT hbmp[50]

'Load a scalable image
hbmp[2] = LOADIMAGE(2, @IMGSCALABLE) 'something.jpg

'Show image - note - Win = window, hbmp[2] - the image, @IMGSCALABLE - scalable - then coordinates.
SHOWIMAGE(Win,hbmp[2],@IMGSCALABLE,300,10,300,145)

'Remmeber - delete image on exit of program!!!!!!!
IF hbmp[2]  THEN DELETEIMAGE hbmp[2], @IMGSCALABLE


Hope this gives you a helping hand.

Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

StormAce

Sorry i was out for some days...
Thanks Andy i'll check that out :)

Andy

Hi,

No problem about being away!

Attached is a zip file, in it is an IWB project, with source code and an image for you to try.

I've used a .jpg file as the image to be loaded - It's just one a made quickly - so It's not the clearest - but it does show you it can be done.

I created a folder on my C: drive called MyImage, so...

1. Create a folder on your C: drive and name it MyImage
2. Unzip all the files to C:\MyImage
3. In IWB open a project and browse to C:\MyImage\MyImage.iwp and open it.
4. Compile and run the project.

If you want to put the files in a different folder then do so BUT then edit the MyImage.rc file (you can use Notepad to do so) from:

2 RTIMAGE "C:\\MyImage\\something.jpg"

to:

2 RTIMAGE "C:\\MyOtherFolder\\something.jpg" - note the path must be correct or you will get an error.

then you can compile and run the project.

Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.