Introduction to ResEdit

guclusat

Tanınmış Üye
Süper Moderatör
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:
resedit.png

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.
save_project.png

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_dialog.png

If you click in the
symbol_list_button.png
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.

symbol_list.png

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
change_static_caption.png

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".
create_new_resource.png

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.
new_icon.png

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.
save_icon.png

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.
set_icon_image.png

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.
new_manifest.png

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".

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.

PHP:
#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;
}

 
Geri
Yukarı