Click here to Skip to main content
Click here to Skip to main content

Introduction to ResEdit

, 26 Jun 2009 CPOL
Rate this:
Please Sign up or sign in to vote.
An quick introduction to ResEdit resource editor

Introduction

This article in an introduction to a resource editor named ResEdit. It explains how to create a resource script with ResEdit and then how to use it in Visual Studio.

First you will need to download ResEdit from here.

Create a Script with ResEdit

Launch ResEdit.exe:

Insert a dialog

The first step is to create a new project in ResEdit. Click on "File>New Project" (or Ctrl-N), and choose a file to save to project.

Insert a dialog

Then you can create new resources. In this example, we will create an dialog box displaying an icon image. To insert a dialog box resource, right-click on the resource tree and select "Add resource>Dialog" (you can also use the Ctrl-D shortcut). A new dialog named IDD_DIALOG1 is created.

Insert a dialog

If you click in the toolbar button, you will see IDD_DIALOG is a symbolic indentifier for 100. You can change this value of the symbol by clicking on the "Modify" button.

Insert a dialog

Now, let's insert some controls in the dialog box. The Toolbox panel displays all the control types you can insert in a dialog box. For example we can insert a "Static text" control to display some text. Click on the "Static text" control in the toolbox, and make a selection in the dialog box. The static text has been created.

You can change the text value in the "Caption" property

Insert a dialog

Now, we are going to create an icon to display it in the dialog box. Right-click on the resource tree and select "Add resource>Icon". A dialog box asks you if you want to use an existing file, or create a new icon. Select "Create a new resource".

Insert a dialog

A new empty icon is created (a .ico file is created in your file system). A 32x32 pixel 32-bit image format is automatically added.

Insert a dialog

The icon editor is quite basic for now, you can only use a pen to draw something. Then, right click on the icon editor tab header and click on save to save your modifications in the .ico file.

Insert a dialog

Now we are going to display the icon we just created in the dialog box. Select the dialog box tab, select "Picture control" in the toolbox and create a control in the dialog. An empty picture is added in the dialog box. Now change the control type to "Icon" in the property panel. Then the "Image" property should be enabled. You can now select the icon you created in the "Image" property.

Insert a dialog

To have visual effects enabled in the program, we need to insert a manifest resource. Right click on the resource tree and select "Add resource>Manifest", and accept the default manifest file.

Insert a dialog

Now click on "File>Save" to save the resource script.

Using the Script with Visual Studio 2008

This parts explains how to use the script you created in the first part in a Visual Studio project. In this tutorial, I'm using Visual Studio 2008 but you can use an older version of Visual Studio either.

At the beginning, we have a simple Win32 project with a one source file which defines the WinMain function. Right-click on the project and select "Add>Existing item".

Insert a dialog - Click to enlarge image

Then choose the files your created with ResEdit (only the .rc file and resource.h).

In the main source file, you have to include "resource.h" to be able to use all symbol definitions. The following code will display the dialog box defined in the resource script.

#define _WIN32_WINNT 0x0600
#define _WIN32_IE 0x0700
#include <windows.h>
#include "resource.h"

#pragma comment(lib, "comctl32.lib")

BOOL CALLBACK AppDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  switch(uMsg)
  {
  case WM_INITDIALOG:
    SetClassLongPtr(hDlg, GCLP_HICON, (long)LoadIcon(0, IDI_APPLICATION));
    return 1;
  case WM_COMMAND:
    switch(wParam)
    {
    case IDOK:
      return 0;
    case IDCANCEL:
      EndDialog(hDlg, 0);
    }
  }
  return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
				LPSTR lpCmdLine, int nCmdShow)
{
  InitCommonControls();
  DialogBoxParam(hInstance, (LPCTSTR)IDD_DIALOG1, 0, AppDlgProc, 0);
  return 0;
}
Insert a dialog - Click to enlarge image

History

  • 26th July, 2009: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

resedit

France France
No Biography provided

Comments and Discussions

 
GeneralRe: ResEdit with VC 2008 PinmemberMeriInssi2-Jul-09 13:00 
GeneralBug in ResEdit PinmemberT800G30-Jun-09 7:00 
GeneralRe: Bug in ResEdit Pinmemberresedit30-Jun-09 10:06 
AnswerRe: Bug in ResEdit [modified] Pinmemberresedit30-Jun-09 11:00 
AnswerRe: Bug in ResEdit PinmemberT800G1-Jul-09 5:35 
GeneralRe: Bug in ResEdit Pinmembercnhnyu11-Nov-09 22:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411023.1 | Last Updated 26 Jun 2009
Article Copyright 2009 by resedit
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid