The Window Message Object Pro's Help Files
By Matt Galanto

Index

Disclaimer

The author of this extension makes no claims concerning the fitness of this extension for any purpose whatsoever, and makes no gurantees, written or implied, of its level of security and safety to authors or to end users in any respect. You agree to use this extension at your own risk and to hold the author harmless in any event.

The Basics

This object's main feature is the interception and generation of Windows messages (things like WM_SYSCOMMAND). If you don't know anything about Windows messages, check out the two links contained in the help. They tell you how to do certain things. Other than that, having a decent knowledge of Windows messages is required to use that particular aspect of the object to its fullest. This object also allows you to tinker with the window itself. You can set the caption text, remove the caption, disable minimize and maximize buttons, and change border styles to name a few.

A Word About Sub-Applications

At first glance, it seems that this object will be useful when used in conjunction with sub-applications. Indeed, this was my intent. Unfortunately, there is a bug in MMF that will sometimes result in a crash when using this object with sub-application objects. I have been unable to attain adequate details about the bug to suggest proper workarounds for the problem, but it seems that holding off creation of any WinMessPro objects until after all sub-applications are created (at run-time) may prevent the crash. However, I cannot confirm this for all cases.

Useful Menu IDs

The following is a list of the menu item IDs of the default menu options in MMF:
1009 = Quit
1010 = New
1011 = Password
1012 = Pause
1013 = Players
1020 = Play samples
1021 = Play musics
1022 = Hide the menu
1023 = Contents
1024 = About...

If you add your own options to the menu, MMF starts assinging IDs with 2001 and assigns them sequentially in the order that you add them to the menu. It seems that if you close and re-open the menu editor and add a new item, that item ID skips a value. In any case, the ID assignment system works similar to that. To be safe, I'd recommend determining the assinged IDs by intercepting messages of type 273 and see what the wParams are for those when you select your menu items.

Conditions

Is There a Message for the Window?
This condition returns true if the current Message Type is equal to the specified type. Events with this condition are executed immediately upon the availability of a message. Using this condition does not affect the message in any way. The window will still receive the message. Cool Messages to Intercept

Does Window have Focus?
This conditin returns true if the specified window has focus.

Does Window have Visible Menu?
This condition returns true if the specified window has a menu and if that menu is visible.

Does Menu Item have a Submenu?
This condition returns true if the specified menu item of the specified window has a submenu. That is, does item open up another submenu?

Has an Error Occured?
Events with this condition are executed immediately whenever the object encounters an error in an ACTION. For errors in a condition or in an expression, use the "Get Last Expression Error Code".

Actions

Start Intercepting Messages
This action tells the object to start intercepting messages intended for the main window. In other words, 'Is There a Message for the Window?' conditions now have an effect.

Stop Intercepting Messages
This action tells the object to stop intercepting messages intended for the main window. In other words, 'Is There a Message for the Window?' conditions no longer have an effect.

Set Current Message as Handled
This action tells the object to prevent the message from being passed on to the main window or to any other extensions.

Set Current Message as Caught
This action tells the object to prevent the message from being passed on to any other extensions. The message will still be passed on to the main window.

Set Current Message to be Handled by Windows
This action tells the object to have Windows run the default routine for handling the particular message.

Send Message to the Window
This action allows you to send a message to the specified window. If you send to the main or edit windows, your object will intercept this message, so be careful not to create any infinite loops, which may crash your application. This action will halt the application until the message is finish being handled.
Cool Ways to Use Send and Post

Post Message to the Window
This action allows you to post a message to the specified window. If you send to the main or edit windows, your object will intercept this message, so be careful not to create any infinite loops, which may crash your application. This action does not wait for the message to be handled.
Cool Ways to Use Send and Post

Set Window Border State (Disabling Turns off Caption)
This action allows you to enable or disable the Window border of the specified window. Disabling the border disables the Window Caption.

Set Window Caption State (Enabling Turns on Border Until Disabled)
This action allows you to enable or disable the Window Caption (i.e. titlebar) of the specified window. While the caption is on, the Window border will be displayed whether or not it is enabled.

Set Dialog Border Style State (Turns off Caption)
This action allows you to enable or disable the dialog box border style of the specified window. Using this action disables the Window Caption.

Set Maximize Button State
This action allows you to enable or disable the maximize button of the specified window. If both the minimize and maximize buttons are disabled, they will disappear.

Set Minimize Button State
This action allows you to enable or disable the minimize button of the specified window. If both the minimize and maximize buttons are disabled, they will disappear.

Set Thick Frame State
This action allows you to enable or disable the thick frame around the specified window. Having a think frame will allow the user to resize the window.

Set Window System Menu State (Enabling Turns on Caption)
This action allows you to enable or disable the window system menu on the caption (i.e the icon and buttons on the titlebar) of the specified window. Enabling the window system menu enables the Window Caption.

Set Custom Window Style
This action allows you to set the window style as if a SetWindowLong(hWnd, GWL_STYLE, Style) call was being made.

Set Taskbar State
I have no idea what this does. :-)

Set Sunken Border State
This action allows you to enable or disable the sunken border of the specified window.

Set Help Context Button State (Enabling Turns off Min and Max Buttons)
This action allows you to enable or disable the help context button of the specified window. Enabling the button disables the minimize and maximize buttons.

Set Double Border State
This action allows you to enable or disable the double border of the specified window.

Set 3D Border State
This action allows you to enable or disable the three-dimensional border effect of the specified window.

Set Tool Window State
This action allows you to enable or disable the tool window style of the specified window. The Tool Window style shrinks the Window Caption and only has a shrunken close button.

Set Raised Border State
This action doesn't seem to do anything. :-)

Set Custom Extended Window Style
This action allows you to set the extended window style as if a SetWindowLong(hWnd, GWL_EXSTYLE, Style) call was being made.

Set Window Caption Text
This action allows you to set the specified window's caption text (i.e. the titlebar text).

Set Window Position
This action sets the (x,y) position of the specified window.

Set Window Size
This action sets the size of the specified window.

Set Window Client Size
This action sets the client size of the specified window. The window size is adjusted to accomodate the new client size.

Set Window Z Order
This action sets the specified window to be above the other specified window, or it sets the first specified window's Z order based on the specified code:
-> 0 (HWND_TOP): Places the window at the top of the Z order.
-> 1 (HWND_BOTTOM): Places the window at the bottom of the Z order. If the hWnd parameter identifies a topmost window, the window loses its topmost status and is placed at the bottom of all other windows.
-> -1 (HWND_TOPMOST): Places the window above all non-topmost windows. The window maintains its topmost position even when it is deactivated.
-> -2 (HWND_NOTOPMOST): Places the window above all non-topmost windows (that is, behind all topmost windows). This flag has no effect if the window is already a non-topmost window.
(The Z order codes and functions were taken from the MSDN library's topic on SetWindowPos.)

Set Window Visibility
This action sets the visibility of the specified window. Entering 0 hides the window, while anything else shows it.

Flash Window
This action flashes the specified window and taskbar icon. Each call of this action performs just ONE step in the flash. To flash repeatedly, you must call this action repeatedly.

Restore Window from Flashed State
This action restores the specified window and taskbar icon from a flashed state.

Redraw the Menu Bar of a Window
This actions redraws the menu bar of the specified window. You should use this action if you have modified the menu bar in anyway. It will not automatically redraw itself.

Reset the System Menu of a Window
This action resets the system menu of a window back to its default state. The system menu of a window is the menu that pops up when the application icon in the top-left corner of the window is right-clicked.

Add an Item to the Menu
This action adds a menu item with the specified text (use &Letter to underline a letter and use a tab chracter to right-justify some of the text) and the specified ID to the menu of the specified window or specified menu (the object can determine whether the specified handle is a window or a menu). The item is added before the other specified menu item. If you want to add an item as the last item on a submenu, use the "Add an Item to a Submenu" or "Add an Item to a Menu by Position" action. Once you add a menu item, the user can choose this option. If this option is chosen, a message type 273 is sent to the main window. It's wParam will be the ID of the menu item selected. The lParam should be 0.

Add an Item to a Submenu
This action adds a menu item with the specified text (use &Letter to underline a letter and use a tab chracter to right-justify some of the text) and the specified ID to the specified submenu (this should be a menu item ID) of the specified window or specified menu (the object can determine whether the specified handle is a window or a menu). If the specified submenu is just a menu item without a submenu, a submenu will be attached to it. The position for this action is a numeric position and not an ID. I believe 0 makes the new item first on the submenu, 1 makes it second, 2 makes it third, etc.

Add an Item to a Menu by Position
This action adds a menu item with the specified text (use &Letter to underline a letter and use a tab chracter to right-justify some of the text) and the specified ID to the menu of the specified window or specified menu (the object can determine whether the specified handle is a window or a menu). The item is added in the specified position (0 makes the new item first on the menu, 1 makes it second, 2 makes it third, etc.). Once you add a menu item, the user can choose this option. If this option is chosen, a message type 273 is sent to the main window. It's wParam will be the ID of the menu item selected. The lParam should be 0.

Add a Separator to the Menu
This action adds a menu separator with the specified ID to the menu of the specified window or specified menu (the object can determine whether the specified handle is a window or a menu). The item is added before the specified menu item.

Add a Separator to a Submenu
This action adds a menu separator with the specified ID to the specified submenu (this should be a menu item ID) of the specified window or specified menu (the object can determine whether the specified handle is a window or a menu). If the specified submenu is just a menu item without a submenu, a submenu will be attached to it. The position for this action is a numeric position and not an ID. I believe 0 makes the new item first on the submenu, 1 makes it second, 2 makes it third, etc.

Add a Separator to a Menu by Position
This action adds a menu separator with the specified ID to the menu of the specified window or specified menu (the object can determine whether the specified handle is a window or a menu). The item is added in the specified position (0 makes the new item first on the menu, 1 makes it second, 2 makes it third, etc.).

Change a Menu Item's Text
This action changes the text of the specified menu item of the specified window or specified menu (the object can determine whether the specified handle is a window or a menu). Use &Letter to underline a letter, and use a tab chracter to right-justify some of the text.

Delete an Item from the Menu
This action deletes the specified menu item from the menu of the specified window or specified menu (the object can determine whether the specified handle is a window or a menu).

Delete a Submenu from a Menu Item
This action removes the submenu attached to the specified menu item. It does NOT remove the menu item itself.

Set an Item's Checked State
This action alters whether or not the specified menu item of the specified window or specified menu (the object can determine whether the specified handle is a window or a menu) has a checkmark next to it. Entering a 0 removes the check while anything else adds the check.

Set an Item's Enabled State
This action alters whether or not the specified menu item of the specified window or specified menu (the object can determine whether the specified handle is a window or a menu) can be selected. Disabled menu items become grayed. Entering a 0 disables the item while anything else enables it.

Set an Item's Highlighted State
This action alters whether or not the specified menu item of the specified window or specified menu (the object can determine whether the specified handle is a window or a menu) is highlighted. Highlighted items return to normal after they are hovered over by the user.. Entering a 0 dehighlights the item while anything else highlights it.

Clear Expression Error
This action sets the Expression Error Code back to 0.

Expressions

Get Window Handle of Last/Current Message
LastWindowHandle(Object Name)
Returns the handle of the window to receive the last message. This will be the handle of either the main window or the edit window.

Get Type of Last/Current Message
MessageType(Object Name)
Returns the type of the last message intercepted by the object.

Get wParam of Last/Current Message
wParam(Object Name)
Returns the wParam associated with the last message intercepted by the object.

Get lParam of Last/Current Message
lParam(Object Name)
Returns the lParam associated with the last message intercepted by the object.

Get Main Window Handle
MainWindowHandle(Object Name)
Returns the handle of the main application window. This should be used for most actions you would like to perform on your application window.

Get Edit Window Handle
EditWindowHandle(Object Name)
Returns the handle of the main application window. This should be used for most actions you would like to perform on your application window.

Get Related Window Handle
RelatedWindowHandle(Object Name, Window Handle, Relationship)
Returns the handle of the window returned by calling GetWindow(hWnd, Relationship), where hWnd is the specified window handle. Possible values for Relationship:
- 0 (GW_HWNDFIRST): The retrieved handle identifies the window of the same type that is highest in the Z order. If the specified window is a topmost window, the handle identifies the topmost window that is highest in the Z order. If the specified window is a top-level window, the handle identifies the top-level window that is highest in the Z order. If the specified window is a child window, the handle identifies the sibling window that is highest in the Z order.
- 1 (GW_HWNDLAST): The retrieved handle identifies the window of the same type that is lowest in the Z order. If the specified window is a topmost window, the handle identifies the topmost window that is lowest in the Z order. If the specified window is a top-level window, the handle identifies the top-level window that is lowest in the Z order. If the specified window is a child window, the handle identifies the sibling window that is lowest in the Z order.
- 2 (GW_HWNDNEXT): The retrieved handle identifies the window below the specified window in the Z order. If the specified window is a topmost window, the handle identifies the topmost window below the specified window. If the specified window is a top-level window, the handle identifies the top-level window below the specified window. If the specified window is a child window, the handle identifies the sibling window below the specified window.
- 3 (GW_HWNDPREV): The retrieved handle identifies the window above the specified window in the Z order. If the specified window is a topmost window, the handle identifies the topmost window above the specified window. If the specified window is a top-level window, the handle identifies the top-level window above the specified window. If the specified window is a child window, the handle identifies the sibling window above the specified window.
- 4 (GW_OWNER): The retrieved handle identifies the specified window's owner window, if any.
- 5 (GW_CHILD): The retrieved handle identifies the child window at the top of the Z order, if the specified window is a parent window; otherwise, the retrieved handle is NULL. The function examines only child windows of the specified window. It does not examine descendant windows.
- 6 (GW_ENABLEDPOPUP): Windows NT 5.0 and later: The retrieved handle identifies the enabled popup window owned by the specified window (the search uses the first such window found using GW_HWNDNEXT); otherwise, if there are no enabled popup windows, the retrieved handle is that of the specified window.
(The relationship values and functions were taken from the MSDN library's topic on GetWindow.)

Get Window Style
WindowStyle(Object Name, Window Handle)
Returns the window style as if a GetWindowLong(hWnd, GWL_STYLE) call was being made, where hWnd is the specified window handle.

Get Extended Window Style
WindowStyleEx(Object Name, Window Handle)
Returns the window style as if a GetWindowLong(hWnd, GWL_EXSTYLE) call was being made, where hWnd is the specified window handle.

Get Window Caption Text
CaptionText$(Object Name, Window Handle)
Returns the current text of the specified window's caption (i.e. titlebar text).

Get X Position of Window
XPosition(Object Name, Window Handle)
Returns the X position of the specified window.

Get Y Position of Window
YPosition(Object Name, Window Handle)
Returns the X position of the specified window.

Get Width of Window
Width(Object Name, Window Handle)
Returns the width of the specified window.

Get Height of Window
Height(Object Name, Window Handle)
Returns the height of the specified window.

Get Client Width of Window
ClientWidth(Object Name, Window Handle)
Returns the client width of the specified window.

Get Client Height of Window
ClientHeight(Object Name, Window Handle)
Returns the client height of the specified window.

Get Visibility of Window
Visibility(Object Name, Window Handle)
Returns 1 if the specified window is visible. Returns 0 if it is not.

Get Text of a Menu Item
MenuItemText$(Object Name, Window Handle, Menu Item ID)
Returns the text of the specified menu item of the specified window or specified menu (the object can determine whether the specified handle is a window or a menu).

Get Checked State of a Menu Item
MenuItemChecked(Object Name, Window Handle, Menu Item ID)
Returns the checked state of the specified menu item of the specified window or specified menu (the object can determine whether the specified handle is a window or a menu). Returns 1 if checked and 0 if not checked.

Get Enabled State of a Menu Item
MenuItemEnabled(Object Name, Window Handle, Menu Item ID)
Returns the enabled state of the specified menu item of the specified window or specified menu (the object can determine whether the specified handle is a window or a menu). Returns 1 if enabled and 0 if disabled..

Get Highlighted State of a Menu Item
MenuItemHighlighted(Object Name, Window Handle, Menu Item ID)
Returns the highlighted state of the specified menu item of the specified window or specified menu (the object can determine whether the specified handle is a window or a menu). Returns 1 if highlighted and 0 if not highlighted.

Get Menu Handle of a Window
WindowMenuHandle(Object Name, Window Handle)
Returns the handle of the menu of the specified window.

Get System Menu Handle of a Window
SystemMenuHandle(Object Name, Window Handle)
Returns the handle of the system menu of the specified window. The system menu of a window is the menu that pops up when the application icon in the top-left corner of the window is right-clicked.

Get Last Error Code
ErrorCode(Object Name)
Returns the last error code from an error ocurring in an action or condition.

Get Last Expression Error Code
ExpressionErrorCode(Object Name)
Returns the last error code from an error ocurring in an expression.

Get Last Windows Error Code
WindowsErrorCode(Object Name)
Returns the last error code from an error ocurring in a Windows function (in actions, in conditions, or in expressions). These are the same codes used by Windows' GetLastError() function. Their meaning can be found, among other places, in the MSDN library.

Get Environment Variable
EnvironmentVar$(Object Name, Variable Name)
Returns the environment variable Variable Name.

HIWORD
HIWORD(Object Name, Number)
Returns the high word of Number. The high word is the number stored in the upper two bytes of the four byte Number.

LOWORD
LOWORD(Object Name, Number)
Returns the low word of Number. The low word is the number stored in the lower two bytes of the four byte Number.

Go Back to Matt's MMF Objects

Go to Clickteam's Web Site

Go to Bumderland