eCo Software Developer Connection


About DevCon
Subscription to DevCon
Budget of DevCon
FAQ


Roadmap
eCo Software runtime
eCo Software toolkit
Contacts

Message box

Enhanced message box. You can use it instead of original PM message boxes.

Goto Progress bar (Message box is impemented in progress.dll)

Main features of a new message box (Extended Message Box) are:

  • Using PNG images as icons
  • Icons could have any size. PROGRESS.DLL contains 32×32, 40×40, 64×64 and 80×80 icon sets.
  • Animation (you can specify a set of PNG images as an animated icon)
  • Besides title, two portions of text (captions) in the message box
  • Your own texts on the buttons
  • LANGE support
  • Message boxes without default button
  • Message boxes with minimize button

To use extended message box instead of standard OS/2 PM, use ExMessageBox() functions instead of WinMessageBox() in your application. The parameter list of ExMessageBox() is compatible with WinMessageBox(). All additional parameters are optional:

ULONG APIENTRY ExMessageBox(HWND    hwndParent,    // Parent window
          HWND    hwndOwner,     // Owner window
          PSZ     pszText,       // Message-box window message
          PSZ     pszCaption,    // Message-box title
          ULONG   idWindow,      // Message-box window identity
          ULONG   flStyle,       // Message-box window style
          [PSZ     pszComment,    // Comment text. Significant only if MB_COMMENT flag is specified
          [PSZ     pszButton1,    // Button 1 text. Significant only if MB_OWNCAPTIONS flag is specified
          [PSZ     pszButton2,    // Button 2 text. Significant only if MB_OWNCAPTIONS flag is specified
          [PSZ     pszButton3,    // Button 3 text. Significant only if MB_OWNCAPTIONS flag is specified
          [PSZ     pszButtonHelp, // "Help" button text. Significant only if MB_OWNCAPTIONS flag is specified
          [LANGE   hLange,        // LANGE handle, used to translate button text. Significant only if MB_OWNLANGE flag is specified
          [HMODULE hmodResource,  // Handle of resource DLL. Significant only if MB_OWNICON flag is specified
          [ULONG   ulID]]]]]]]]); // ID of the icon in the resource DLL. Significant only if MB_OWNICON flag is specified

As you can see, the parameter order is significant, so if, for example, pszButton* parameters are not used (MB_OOWNCAPTIONS flag is not specified), but hLange parameter is used (MB_OWNLANGE flag is specified), you cannot just ommit those parameters. Use NULL instead.

Be careful: you MUST specify a parameter if, an appropriate flag is set. If, for example, MB_OWNCAPTIONS flag is set, then:

  • If MB_OK flag is set, the message box contains only one button, so you have to specify only pszButton1 parameter.
  • If MB_YESNO flag is set, the message box contains two buttons, so you have to specify both pszButton1 and pszButton2 parameters.
  • If MB_ABORTRETRYIGNORE flag is set, the message box contains three buttons, so you have to specify pszButton1, pszButton2 and pszButton3 parameters.
  • IF MB_HELP flag is set, the message box contains “Help” button, so you have to specify pszButtonHelp parameter.

Here is the full list of new styles (must be OR'ed in flStyle parameter):

MB_BIGICON      // Use big icons. Otherwise, small icons are used. 
                   Big icons are 64x64 for LoRes (96dpi) screens and 
                   80x80 for HiRes (120dpi) screens. Ignored if MB_OWNICON 
                   flag is set.
                   
MB_ANIMATED     // Use animated icons.

MB_COMMENT      // MessageBoxt contains not only caption, but also comment, 
                   specified by pszComment parameter. Usually caption text 
                   is bold, and comment text is not.
                   
MB_MINBUTTON    // MessageBox contains "minimize" button.

MB_OWNLANGE     // Use your own NLS (specified by hLange parameter) to 
                   translate all the text in the MessageBox. Otherwise, 
                   PROGRESS.NLS is used.
                   
MB_OWNCAPTIONS  // Use own captions on the message box buttons (see above).

MB_OWNICON      // Use your own icon (icon set) instead of internal one (see 
                   below).
                   
MB_NODEFBUTTON	 // None of the buttons in the message box is marked as 
                   default. "ENTER" key will not press any buttons (unless 
                   you have selected one of them with arrow kwys, for example).
                   

Using your own icons:

When MB_OWNICON flag is set, both hmodResource and ulID parameters must be specified. If MB_ANIMATED flag is not set, PNG image stored in hmodResource with resource type = RT_PNG (defined in PROGRESS.H) and ID = ulID is loaded and used as an icon. If MB_ANIMATED flag is set, a set of PNG images stored in hmodResource with resource type = RT_PNG and IDs starting from ulID untill first ID which is not existed used as an icon.

  • If hmodResource = 0, resources are loaded from the executable of the application.
  • If hmodResource = -1, resources are loaded from PROGRESS.DLL.

Otherwise hmodResource is the handle of the DLL, obtained by DosLoadModule() function.

The list of resource IDs of the icons stored in the PROGRESS.DLL (defined in PROGRESS.H):

ID_PROGRESS_PNG_ICON_PERCENT  - A set of 21 images, used to display icon with percentage. Minimum 2 images, maximum 101 image.
D_PROGRESS_PNG_ICON          - A set of 12 images, used to display animated icon looop.

IDP_ICON_ERROR_32             - A set of 14 images: "Error"	- "X" icon 32x32
IDP_ICON_ERROR_40             - A set of 14 images: "Error"	- "X" icon 40x40
IDP_ICON_ERROR_64             - A set of 14 images: "Error"	- "X" icon 64x64
IDP_ICON_ERROR_80             - A set of 14 images: "Error"	- "X" icon 80x80

IDP_ICON_INFO_32              - A set of 14 images: "Information" - "i" icon 32x32
IDP_ICON_INFO_40              - A set of 14 images: "Information" - "i" icon 40x40
IDP_ICON_INFO_64              - A set of 14 images: "Information" - "i" icon 64x64
IDP_ICON_INFO_80              - A set of 14 images: "Information" - "i" icon 80x80

IDP_ICON_QUERY_32             - A set of 14 images: "Query" - "?" icon 32x32
IDP_ICON_QUERY_40             - A set of 14 images: "Query" - "?" icon 40x40
IDP_ICON_QUERY_64             - A set of 14 images: "Query" - "?" icon 64x64
IDP_ICON_QUERY_80             - A set of 14 images: "Query" - "?" icon 80x80

IDP_ICON_WARNING_32           - A set of 14 images: "Warning" - "!" icon 32x32
IDP_ICON_WARNING_40           - A set of 14 images: "Warning" - "!" icon 40x40
IDP_ICON_WARNING_64           - A set of 14 images: "Warning" - "!" icon 64x64
IDP_ICON_WARNING_80           - A set of 14 images: "Warning" - "!" icon 80x80

Useful hints and advices

  • MSG-BOX-1: It's a good idea to use your own captions on the buttons instead of the default. Always use verbs as captions: “Close window”, “Do not close”, “Overwrite file”, “Keep file” instead of “Yes”, “No”, “OK”, etc.
  • MSG-BOX-2: As a good tradition in OS/2(eCS) programming, when displaying errors, alarms and warnings, do not accurse user:
    • Do not write “You specified wrong file name”, use “File not found” instead.
    • Do not write “You selected invalid file type”, use “Couldn't recognize file type” etc.
  • MSG-BOX-3: Don't use Message box IF
    • if you want notify user. Use Status bar to show notifications. Example: user inserted flash disk. No need to popup Message box, show a banner in eCenter.
 
en/message_box.txt · Last modified: 2009/10/24 11:25 (external edit)

 
Recent changes RSS feed
© 2001 - 2009 eCo Software, All rights reserved