Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- M E W E L - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

You can load a resource at the time when your application actually needs to
use that resource. First, you must open the binary resource file by calling
OpenResourceFile(). The file name that you pass to OpenResourceFile() does
not need to contain the .RES extension; the RES extension is assumed. If
you have appended your RES file to the end of your application's EXE file,
then you need to pass NULL to OpenResourceFile() instead of the resource
file name. Here is some code to open a resource file:

WORD hModule;
hModule = OpenResourceFile("DESKTOP")

Once the resource file is open, you can load a string, an accelerator table,
a dialog box, or a menu. The functions to do this are:
  LoadString()
  LoadAccelerators()
  LoadDialog()
  LoadMenu()

These functions are discussed in depth in the chapters where each of these
objects are introduced. The first argument to each of these functions is
the resource file handle obtained by OpenResourceFile().

When you are finished loading resources from that resource file, you must
call CloseResourceFile(). You must remember to close your resource files or
else your application might run out of file handles if you do a lot of file
manipulation.

Here is an example of some code to load a string, a menu, and an accelerator
table into your application. Other examples can be found in the demo
programs on the MEWEL distribution disk.

  char  buf[120];
  HWND  hMain;
  HMENU hMenu;
  HACCEL hAccel;
  WORD  hRes;

  ........

  if ((hRes = OpenResourceFile("DESKTOP")))
  {
    LoadString(hRes, ID_ERRSTR, buf, sizeof(buf));

    if ((hAccel = LoadAccelerators(hRes, 1)))
    {
      AcceleratorSetFocus(hAccel);
      AcceleratorSetWnd(hMain);
    }

    if ((hMenu = LoadMenu(hRes, ID_MYMENU, hMain)) != NULLHWND)
      SetMenu(hMain, hMenu);

    CloseResourceFile(hRes);
  }

See Also: LoadString LoadAccelerators LoadMenu LoadDialog

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson