It's interesting

eglo

Restorator: Editing Dialog Resources

Editing dialog windows is somewhat more complicated than editing menus. Many commands are used for this purpose, making it simply impossible to describe them all here. Instead, we will focus on the most important examples. Open the Dialog section in the resource tree and select resource number 200. You should see the dialog window form in the Resource Viewer window:

Viewing a dialog resource window
Viewing a dialog window form

You can switch into editing mode by selecting the Viewer/Edit Mode menu sequence. The source code of the dialog window number 200 is shown in the next code.

Dialog window source code

200 DIALOG 50, 50, 194, 168
STYLE DS_SETFONT | DS_3DLOOK | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU
MENU 118
CAPTION "Phone Dialer"
FONT 8, "MS Shell Dlg"
{
 CONTROL "", 224, "STATIC", SS_ETCHEDHORZ | WS_DISABLED, 0, 0, 194, 1
 LTEXT "&Number to dial:", 223, 7, 7, 90, 10
 COMBOBOX 201, 7, 21, 90, 104, CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT | 
      WS_VSCROLL | WS_GROUP
 DEFPUSHBUTTON "&Dial", 1, 7, 38, 90, 14, WS_DISABLED | WS_GROUP
 PUSHBUTTON "\n1", 202,6,62,27,20,BS_CENTER|BS_MULTILINE|NOT WS_TABSTOP
 PUSHBUTTON "ABC\n2",203,37,62,27,20,BS_CENTER|BS_MULTILINE | NOT WS_TABSTOP
 PUSHBUTTON "DEF\n3",204,69,62,27,20,BS_MULTILINE|NOT WS_TABSTOP
 PUSHBUTTON "GHI\n4",205,6,86,27,20,BS_CENTER|BS_MULTILINE|NOT WS_TABSTOP
 PUSHBUTTON "JKL\n5",206,37,86,27,20,BS_CENTER|BS_MULTILINE|NOT WS_TABSTOP
 PUSHBUTTON "MNO\n6",207,69,86,27,20,BS_CENTER|BS_MULTILINE|NOT WS_TABSTOP
 PUSHBUTTON "PRS\n7",208,6,110,27,20,BS_CENTER|BS_MULTILINE|NOT WS_TABSTOP
 PUSHBUTTON "TUV\n8",209,37,110,27,20,BS_CENTER|BS_MULTILINE|NOT WS_TABSTOP
 PUSHBUTTON "WXY\n9",210,69,110,27,20,BS_CENTER|BS_MULTILINE|NOT WS_TABSTOP
 PUSHBUTTON "\n*", 212,6,134,27,20,BS_CENTER|BS_MULTILINE|NOT WS_TABSTOP
 PUSHBUTTON "\n0", 211,37,134,27,20,BS_CENTER|BS_MULTILINE|NOT WS_TABSTOP
 PUSHBUTTON "\n#", 213,69,134,27,20,BS_CENTER|BS_MULTILINE|NOT WS_TABSTOP
 GROUPBOX "Speed dial", 222, 103, 7, 84, 154
 LTEXT "&1", 225, 109, 24, 7, 10
 PUSHBUTTON "", 214, 117, 21, 63, 14, BS_LEFT | WS_GROUP
 LTEXT "&2", 226, 109, 41, 7, 10
 PUSHBUTTON "", 215, 117, 38, 63, 14, BS_LEFT | WS_GROUP
 LTEXT "&3", 227, 109, 58, 7, 10
 PUSHBUTTON "", 216, 117, 55, 63, 14, BS_LEFT | WS_GROUP
 LTEXT "&4", 228, 109, 75, 7, 10
 PUSHBUTTON "", 217, 117, 72, 63, 14, BS_LEFT | WS_GROUP
 LTEXT "&5", 229, 109, 92, 7, 10
 PUSHBUTTON "", 218, 117, 89, 63, 14, BS_LEFT | WS_GROUP
 LTEXT "&6", 230, 109, 109, 7, 10
 PUSHBUTTON "", 219, 117, 106, 63, 14, BS_LEFT | WS_GROUP
 LTEXT "&7", 231, 109, 126, 7, 10
 PUSHBUTTON "", 220, 117, 123, 63, 14, BS_LEFT | WS_GROUP
 LTEXT "&8", 232, 109, 143, 7, 10
 PUSHBUTTON "", 221, 117, 140, 63, 14, BS_LEFT | WS_GROUP
}

A dialog window is defined as follows:

n DIALOG x, y, w, h
STYLE Style flags
MENU Menu number
CAPTION "Caption"
FONT size, "Font name"
{
// A description of the window's elements goes in here
}

where:

  • n - resource number
  • x - window's left position
  • y - window's top position
  • w - window's width
  • h - window's height

The window styles are defined in the next line. If a window has a menu, it is indicated in the following line by the MENU Number command. The window's caption is defined by the CAPTION "Caption text" command.

This is followed by the font description (size and name) and by a pair of curly brackets, inside of which the window's elements are defined. Let's examine how some main elements are defined in the window's source code.

Beginning with version 3, it became possible to edit windows in visual mode. To do this, first select the default resource view mode (menu sequence Viewer/Default view mode), and then switch into the edit mode (menu sequence Viewer/Edit mode). A property panel for the selected window element will appear in the resource view window and you will be able to use the mouse to move any element, change its size and review changes in the property panel.

The only shortcoming of the visual editor is the inconvenient method for adding components. This is done by writing code manually, which is not particularly convenient if you only need to add one image. It is better to add new using the Resource Workshop program, which we will discuss later.

Dialog window Icons

Icons allow you to add graphic images to dialog windows. Although this does not make them more effective, they do look more appealing. Icons are added with the following command:

ICON n, i, x, y, w, h 

where n is the icon number in the resource file. The number can only refer to an existing icon. For example, there are two icons in the Dialer program, numbered 1 and 116; either of these numbers can be used. You can add new icons, assign them numbers yourself, and then use them in dialog windows.

i is the index used by the program to access the icon. Do not change this index when editing an existing icon, as the program will then not be able to find the icon. When adding a new icon, its index can be given any number (preferably not one that conflicts with the indices of the window's other elements): the program will not be aware of the new icon and will not access it.

Size values:

  • x: the icon's left position
  • y: the icon's top position
  • w: the icon's width
  • h: the icon's height

Dialog labels

Labels are used to write explanations to controls. They are defined as follows:

LTEXT "Text", i, x, y, w, h 
where:"Text": label text in quotation marks

i is the index used by the program to access the label. Do not change this index when editing an existing label, as the program will then not be able to find it. When adding a new label, its index can be given any number (preferably not one that conflicts with the indices of another window's elements): the program will not be aware of the new label and will not access it.

Size values:

  • x: the label's left position
  • y: the label's top position
  • w: the label's width
  • h: the label's height

Dialog window buttons

Buttons are buttons everywhere. They are defined as follows:

PUSHBUTTON "Text", i, x, y, w, h, flags
where: "Text": button text in quotation marks

i is the index used by the program to access the button. Do not change this index when editing an existing button, as the program will then not be able to find the button. When adding a new button, its index can be given any number (preferably not one conflicting with the indices of other window elements): the program will not be aware of the new button and will not access it.

Size values:

  • x: the button's left position
  • y: the button's top position
  • w: the button's width
  • h: the button's height

Flags describe the button's properties. There can be several flags divided with | character. The main flags and their functions are the following

  • BS_CENTER: the button text is centered
  • BS_LEFT: the button text is left-aligned
  • BS_RIGHT: the button text is right aligned
  • BS_MULTILINE: the button has a multiline text
  • WS_DISABLED: the button is disabled
  • WS_GROUP: the button is grouped with other window buttons.

Decoration

Now, let's apply your newly acquired theoretical knowledge in practice and give the dialer dialog window some cosmetic treatment. First, widen it to 225 pixels. This is done by changing the third numerical parameter in the first line to 225, as follows:

200 DIALOG 50, 50, 225, 168

Then change the third line, the title: CAPTION "Horrific Dialer"

After this change, the window's title will read Horrific Dialer. Next, add an icon and a label. This is done by inserting the following two lines after the opening curly bracket:

FONT 8, "MS Shell Dlg"
{
 ICON 1, 0, 195, 5, 18, 20
 LTEXT "Copyright: Horrific", 223, 40, 1, 90, 10

 //The rest remains unchanged
}

Press the key. Here, the program may say that there is an error in the following line: CLASS DialerClass. If this happens, simply delete this entire line. If there is the CLASS command in the window definition, saving modifications often produces errors. In most cases, deleting this line will not affect the program's operation.

 Results of the window editing
Results of the window editing

If you are satisfied with the result, press <F8> to perform a final save of the resource, and then press <Ctrl> + <S> to save the entire file.




Save your comment

Can you use BBCode? You can use [quote] to quote, [b] and [i] for text decoration. You can't use any other codes.

Your name:

Comment:

Protection code:

Share |





Copyright © Flenov.net 2014. All rights reserved
www.flenov.net