-1

How can this be done using Visual C++ 2008 Express?

Picture must be into executable.

I found i can modify background of borderless window using these lines:

WNDCLASSEX wcx;
/*fill up other wcx members*/
wcx.hbrBackground=CreatePatternBrush((HBITMAP) LoadImage(0,_T("background.bmp"),
                                 IMAGE_BITMAP,0,0,
                                 LR_CREATEDIBSECTION|LR_LOADFROMFILE));

or

WNDCLASSEX wcx;
/*fill up other wcx members*/
wcx.hbrBackground=CreatePatternBrush((HBITMAP) LoadImage(GetModuleHandle(0),
                                  MAKEINTRESOURCE(ID_BACK_BMP),
                                 IMAGE_BITMAP,0,0,
                                 LR_CREATEDIBSECTION);

but i got a problem:

First example is used to get pictures from existing files. Second one uses resorces. But I can not find an option how to add a resource (i think this is impossible for native projects)! Is there any workaround?

Please help!

PS. Sorry for bad english!

BalticMusicFan
  • 653
  • 1
  • 8
  • 21

2 Answers2

0

The express versions of Visual Studio do not include a resource editor. But you can use a 3rd party resource editor:

Creating a ".rc" file in Visual Studio 2010 Express

Community
  • 1
  • 1
ScottMcP-MVP
  • 10,337
  • 2
  • 15
  • 15
0

You don't need a resource editor to compile resources into an executable image. The resource editor is merely a graphical editor for resource script files (.rc). Resource script files can be authored in any text editor. The file format is documented in the MSDN (About Resource Files).

To add a bitmap image resource you have to add a BITMAP resource definition statement to your resource script and create a unique resource ID in a header file (resource IDs for bitmaps must be in the range from 0 to 32767):

resource.h:

#define IDB_BACK_BMP 1

MyApp.rc:

#include "resource.h"
IDB_BACK_BMP BITMAP "background.bmp"

Assuming that your project is properly set up to invoke the Resource Compiler for resource script files you can load the bitmap image from the executable image using:

HBITMAP hBM = (HBITMAP)LoadImage(GetModuleHandle(NULL),
                                 MAKEINTRESOURCE(IDB_BACK_BMP),
                                 IMAGE_BITMAP,
                                 0, 0,
                                 LR_DEFAULTCOLOR);

Note that you do not need to specify the LR_CREATEDIBSECTION flag unless you want to send the image to a printer. For rendering to a display device context a device-dependent bitmap suffices.

IInspectable
  • 46,945
  • 8
  • 85
  • 181