Jump to content

Introduction to PM Programming - Apr 1995: Difference between revisions

From EDM2
mNo edit summary
Ak120 (talk | contribs)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Written by [[Larry Salomon Jr.]]
''Written by [[Larry Salomon Jr.]]''


<h2>Introduction</h2>
==Introduction==
The purpose of this column is to provide the readers out there who are not familiar with PM application development the information necessary to satisfy their curiosity, educate themselves, and give them an advantage over the documentation supplied by IBM. Of course, much of this stuff could probably be found in one of the many books out there, but the problem with books in general is that they don't answer the questions you have after you read the book the first time through.


<p>The purpose of this column is to provide the readers out there who are not
I will gladly entertain feedback from the readers about what was "glossed over" or what was detailed well, what tangential topics need to be covered and what superfluous crap should have been removed. This feedback is essential in guaranteeing that you get what you pay for. <grin>
familiar with PM application development the information necessary to
satisfy their curiosity, educate themselves, and give them an advantage
over the documentation supplied by IBM. Of course, much of this stuff
could probably be found in one of the many books out there, but the problem
with books in general is that they don't answer the questions you have
after you read the book the first time through.


<p>I will gladly entertain feedback from the readers about what was &quot;glossed
It should be said that you must not depend solely on this column to teach you how to develop PM applications; instead, this should be viewed as a supplement to your other information storehouses (books, the network conferences, etc.). Because this column must take a general approach, there will be some topics that you would like to see discussed that really do not belong here. Specific questions can be directed to me via email and I will do my best to answer them in a timely fashion.
over&quot; or what was detailed well, what tangential topics need to be covered
and what superfluous crap should have been removed.  This feedback is
essential in guaranteeing that you get what you pay for. &lt;grin&gt;


<p>It should be said that you must not depend solely on this column to teach
==The Menu Class==
you how to develop PM applications; instead, this should be viewed as a
The menu class (WC_MENU) provides the most widely used functionality of any of the window classes, save the frame window. It is, simply put, a user-interface for a tree structure that is defined by the application. Each node on the tree, whether a leaf or branch node, has various characteristics, such as text and display attributes.
supplement to your other information storehouses (books, the network
conferences, etc.).  Because this column must take a general approach,
there will be some topics that you would like to see discussed that really
do not belong here.  Specific questions can be directed to me via email and
I will do my best to answer them in a timely fashion.


<h2>The Menu Class</h2>
Some definitions need to be noted:


<p>The menu class (WC_MENU) provides the most widely used functionality of any
Leaf nodes (menu items) are end-selectable, a term I'll use to describe that the selecting action is terminated after the selection is made, and the identifier representing the menu item is returned to the application via the appropriate message.
of the window classes, save the frame window.  It is, simply put, a
user-interface for a tree structure that is defined by the application.
Each node on the tree, whether a leaf or branch node, has various
characteristics, such as text and display attributes.


<p>Some definitions need to be noted:
Branch nodes differ from leaf nodes in that they lead to other parts of the tree. In PM parlance, branch nodes are items with sub menus associated with them and are not end-selectable.


<p>Leaf nodes (menu items) are end-selectable, a term I'll use to describe
Menu item - a single entity within the menu tree. This term is used to describe leaf nodes.
that the selecting action is terminated after the selection is made, and
the identifier representing the menu item is returned to the application
via the appropriate message.


<p>Branch nodes differ from leaf nodes in that they lead to other parts of the
Submenu - a single entity within the menu tree. This term is used to describe branch nodes.
tree. In PM parlance, branch nodes are items with sub menus associated
with them and are not end-selectable.


Pulldown - another term for submenu, since they (typically) are "pulled-down".


<p>Menu item - a single entity within the menu tree.  This term is used to
Pullright - another term for submenus that exist within submenus, since they (typically) are "pulled-right".
describe leaf nodes.


<p>Submenu - a single entity within the menu tree.  This term is used to
Menu item button - a menu item with the MIS_BUTTONSEPARATOR style that acts like a button on the action bar.
describe branch nodes.


<p>Pulldown - another term for submenu, since they (typically) are
Action bar - this is a horizontal bar that usually is as wide as its parent. On this bar are menu items which may or may not contain submenus. To the right of the action bar there may be one or two menu item buttons.
&quot;pulled-down&quot;.


<p>Pullright - another term for submenus that exist within submenus, since
Popup menu - this term describes a menu without an action bar which is accessed by a mouse action or keystroke. The menu "pops up" and looks like a pulldown with one or more pullrights.
they (typically) are &quot;pulled-right&quot;.


<p>Menu item button - a menu item with the MIS_BUTTONSEPARATOR style that acts
Each node has a set of styles and attributes associated with it. Styles differ from attributes in that they describe what the "type" of the node is are not meant to be changed once set. Examples of styles are "submenu", "text", and "bitmap". Attributes, on the other hand, also describe appearance characteristics, but may vary from time-to-time and are frequently changed by the application in response to the state of the application. Examples of attributes are "checked" and "disabled".
like a button on the action bar.


<p>Action bar - this is a horizontal bar that usually is as wide as its
==Styles and Attributes==
parent. On this bar are menu items which may or may not contain submenus.
Menu item styles (MIS_) are listed below:
To the right of the action bar there may be one or two menu item buttons.
{|class="wikitable"
!Style||Description
|-
|MIS_BITMAP||Display a bitmap instead of text.
|-
|MIS_BREAK||Start a new column beginning with this item.
|-
|MIS_BREAKSEPARATOR||Same as MIS_BREAK except that a vertical rule is drawn to separate the columns.
|-
|MIS_BUTTONSEPARATOR||Positions the item at the end of the action bar and draws a vertical separator. The focus cannot be given to this item, but it may be selected with the mouse. Any menu control may have a maximum of two items with this style.
|-
|MIS_GROUP||This is a new style in Warp for which there is no documentation.
|-
|MIS_HELP||Selecting this menu item sends a WM_HELP message.
|-
|MIS_MULTMENU||This is a new style in Warp for which there is no documentation.
|-
|MIS_OWNERDRAW||This menu item is to be drawn by the application.
|-
|MIS_SEPARATOR||This menu item is a separator only. It is drawn as a horizontal line.
|-
|MIS_SINGLE||This is a new style in Warp for which there is no documentation
|-
|MIS_STATIC||This menu item is for informational purposes only and is not selectable.
|-
|MIS_SUBMENU||This menu item has a submenu associated with it.
|-
|MIS_SYSCOMMAND||Selecting this menu item sends a WM_SYSCOMMAND message.
|-
|MIS_TEXT||Display text instead of a bitmap.
|}


<p>Popup menu - this term describes a menu without an action bar which is
Menu item attributes (MIA_) are listed below:
accessed by a mouse action or keystroke. The menu &quot;pops up&quot; and looks like a pulldown with one or more pullrights.
{|class="wikitable"
!Attribute||Description
|-
|MIA_CHECKED||Place a checkbox to the left of the menu item
|-
|MIA_DISABLED||Do not allow the menu item to be selected
|-
|MIA_FRAMED||Draw a frame around the menu item
|-
|MIA_HILITED||Highlight the menu item when drawn
|-
|MIA_NODISMISS||Do not dismiss the submenu when a menu item has been selected
|}


<p>Each node has a set of styles and attributes associated with it. Styles
==From the Resource File==
differ from attributes in that they describe what the &quot;type&quot; of the node is
The general form of the menu template within a resource file is shown below:
are not meant to be changed once set. Examples of styles are &quot;submenu&quot;,
<pre>
 
&quot;text&quot;, and &quot;bitmap&quot;. Attributes, on the other hand, also describe
appearance characteristics, but may vary from time-to-time and are
frequently changed by the application in response to the state of the
application.  Examples of attributes are &quot;checked&quot; and &quot;disabled&quot;.
 
<h2>Styles and Attributes</h2>
 
<p>Menu item styles (MIS_) are listed below:
 
<p><table BORDER=1>
<tr>
<th>Style</th>
 
<th>Desctiption</th>
</tr>
<tr>
<td>MIS_BITMAP</td>
<td>Display a bitmap instead of text.</td>
</tr>
<tr>
<td>MIS_BREAK</td>
<td>Start a new column beginning with this item.</td>
</tr>
<tr>
<td>MIS_BREAKSEPARATOR</td>
 
<td>Same as MIS_BREAK except that a vertical rule is drawn
to separate the columns.</td>
</tr>
<tr>
<td>MIS_BUTTONSEPARATOR</td>
<td>Positions the item at the end of the action bar and
draws a vertical separator.  The focus cannot be given to this item, but it
may be selected with the mouse.  Any menu control may have a maximum of two
items with this style.</td>
</tr>
<tr>
<td>MIS_GROUP</td>
<td>This is a new style in Warp for which there is no documentation.</td>
</tr>
<tr>
<td>MIS_HELP</td>
 
<td>Selecting this menu item sends a WM_HELP message.</td>
</tr>
<tr>
<td>MIS_MULTMENU</td>
<td>This is a new style in Warp for which there is no documentation.</td>
</tr>
<tr>
<td>MIS_OWNERDRAW</td>
<td>This menu item is to be drawn by the application.</td>
</tr>
<tr>
<td>MIS_SEPARATOR</td>
 
<td>This menu item is a separator only.  It is drawn as a
horizontal line.</td>
</tr>
<tr>
<td>MIS_SINGLE</td>
<td>This is a new style in Warp for which there is no documentation</td>
</tr>
<tr>
<td>MIS_STATIC</td>
<td>This menu item is for informational purposes only and is not
selectable.</td>
</tr>
<tr>
<td>MIS_SUBMENU</td>
 
<td>This menu item has a submenu associated with it.</td>
</tr>
<tr>
<td>MIS_SYSCOMMAND</td>
<td>Selecting this menu item sends a WM_SYSCOMMAND message.</td>
</tr>
<tr>
<td>MIS_TEXT</td>
<td>Display text instead of a bitmap.</td>
</tr>
</table>
 
<p>Menu item attributes (MIA_) are listed below:
 
<p><table BORDER=1>
<tr>
<th>Attribute</th>
<th>Description</th>
</tr>
<tr>
<td>MIA_CHECKED</td>
<td>Place a checkbox to the left of the menu item</td>
</tr>
<tr>
<td>MIA_DISABLED</td>
 
<td>Do not allow the menu item to be selected</td>
</tr>
<tr>
<td>MIA_FRAMED</td>
<td>Draw a frame around the menu item</td>
</tr>
<tr>
<td>MIA_HILITED</td>
<td>Highlight the menu item when drawn</td>
</tr>
<tr>
<td>MIA_NODISMISS</td>
 
<td>Do not dismiss the submenu when a menu item has been selected</td>
</tr>
</table>
 
<h2>From the Resource File</h2>
 
<p>The general form of the menu template within a resource file is shown
below:
 
<pre><small>
menuitem:=
menuitem:=
   MENUITEM &quot;text&quot;, id [, style [, attribute ]]
   MENUITEM "text", id [, style [, attribute ]]


menublock:=
menublock:=
Line 197: Line 92:


submenu:=
submenu:=
   SUBMENU &quot;text&quot;, id
   SUBMENU "text", id
   BEGIN
   BEGIN
menublock
menublock
Line 207: Line 102:
menublock
menublock
   END
   END
</small></pre>
</pre>
 
<p>My compiler teacher would kill me for writing a recursive grammer like
that, but at least she can't flunk me anymore. <grin>
 
<p>You can see that the top level items do not have to be submenus, even
though this is not a common occurance.
 
<h2>Using Menus</h2>
 
<p>Menus are typically loaded in one of two fashions, depending on their
purpose.  Action bar menus are loaded by the WinCreateStdWindow function.
All that you need to do is specify the FCF_MENU flag in the third parameter
and insure that the id of the MENU itself matches the value specified by
the eighth parameter.  Popup menus are loaded using the WinLoadMenu
function:


<pre><small>
My compiler teacher would kill me for writing a recursive grammar like that, but at least she can't flunk me anymore. <grin>
    (HWND)WinLoadMenu(HWND hwndParent,HMODULE hmModule,ULONG ulId)
</small></pre>


<p>hwndParent, although the documentation states that this must be a frame
You can see that the top level items do not have to be submenus, even though this is not a common occurrence.
window, is the window to own the menu.  For action bar menus, it should
indeed be a frame, but for popup menus, you should specify HWND_OBJECT.
This is because the function automatically attaches the menu to the window
specified which would display an action bar on the frame even though you
were going to use it as a popup menu. hmModule is the handle of the DLL
containing the menu resource. ulId specifies the id of the menu resource to
be loaded.


<p>Menu items send to the client either a WM_COMMAND, WM_SYSCOMMAND, or
==Using Menus==
WM_HELP message depending on the style of the item. After receiving one of
Menus are typically loaded in one of two fashions, depending on their purpose. Action bar menus are loaded by the WinCreateStdWindow function. All that you need to do is specify the FCF_MENU flag in the third parameter and insure that the id of the MENU itself matches the value specified by the eighth parameter. Popup menus are loaded using the WinLoadMenu function:
these messages, you perform the action associated with the menu item.  Why
(HWND)WinLoadMenu(HWND hwndParent,HMODULE hmModule,ULONG ulId)
would you use WM_SYSCOMMAND or WM_HELP instead of WM_COMMAND?
WM_SYSCOMMAND is a &quot;system command&quot; such as &quot;close the window&quot; or &quot;size the
window&quot; and is sent by the system menu (FCF_SYSMENU). WM_HELP is used by
help related items such as &quot;general help&quot; or &quot;help index&quot;.


hwndParent, although the documentation states that this must be a frame window, is the window to own the menu. For action bar menus, it should indeed be a frame, but for popup menus, you should specify HWND_OBJECT. This is because the function automatically attaches the menu to the window specified which would display an action bar on the frame even though you were going to use it as a popup menu. hmModule is the handle of the DLL containing the menu resource. ulId specifies the id of the menu resource to be loaded.


<h2>Conclusion</h2>
Menu items send to the client either a WM_COMMAND, WM_SYSCOMMAND, or WM_HELP message depending on the style of the item.  After receiving one of these messages, you perform the action associated with the menu item.  Why would you use WM_SYSCOMMAND or WM_HELP instead of WM_COMMAND? WM_SYSCOMMAND is a "system command" such as "close the window" or "size the window" and is sent by the system menu (FCF_SYSMENU). WM_HELP is used by help related items such as "general help" or "help index".


<p>This month we began looking at the menu control and the basic things that we need to know before moving onto the messages that the menu control accepts and sends. This will be the topic of the next column or two which will be accompanied by a sample program (or two).
==Conclusion==
This month we began looking at the menu control and the basic things that we need to know before moving onto the messages that the menu control accepts and sends. This will be the topic of the next column or two which will be accompanied by a sample program (or two).


[[Category: PM Articles]]
[[Category: PM Articles]]

Latest revision as of 11:23, 2 March 2018

Written by Larry Salomon Jr.

Introduction

The purpose of this column is to provide the readers out there who are not familiar with PM application development the information necessary to satisfy their curiosity, educate themselves, and give them an advantage over the documentation supplied by IBM. Of course, much of this stuff could probably be found in one of the many books out there, but the problem with books in general is that they don't answer the questions you have after you read the book the first time through.

I will gladly entertain feedback from the readers about what was "glossed over" or what was detailed well, what tangential topics need to be covered and what superfluous crap should have been removed. This feedback is essential in guaranteeing that you get what you pay for. <grin>

It should be said that you must not depend solely on this column to teach you how to develop PM applications; instead, this should be viewed as a supplement to your other information storehouses (books, the network conferences, etc.). Because this column must take a general approach, there will be some topics that you would like to see discussed that really do not belong here. Specific questions can be directed to me via email and I will do my best to answer them in a timely fashion.

The Menu Class

The menu class (WC_MENU) provides the most widely used functionality of any of the window classes, save the frame window. It is, simply put, a user-interface for a tree structure that is defined by the application. Each node on the tree, whether a leaf or branch node, has various characteristics, such as text and display attributes.

Some definitions need to be noted:

Leaf nodes (menu items) are end-selectable, a term I'll use to describe that the selecting action is terminated after the selection is made, and the identifier representing the menu item is returned to the application via the appropriate message.

Branch nodes differ from leaf nodes in that they lead to other parts of the tree. In PM parlance, branch nodes are items with sub menus associated with them and are not end-selectable.

Menu item - a single entity within the menu tree. This term is used to describe leaf nodes.

Submenu - a single entity within the menu tree. This term is used to describe branch nodes.

Pulldown - another term for submenu, since they (typically) are "pulled-down".

Pullright - another term for submenus that exist within submenus, since they (typically) are "pulled-right".

Menu item button - a menu item with the MIS_BUTTONSEPARATOR style that acts like a button on the action bar.

Action bar - this is a horizontal bar that usually is as wide as its parent. On this bar are menu items which may or may not contain submenus. To the right of the action bar there may be one or two menu item buttons.

Popup menu - this term describes a menu without an action bar which is accessed by a mouse action or keystroke. The menu "pops up" and looks like a pulldown with one or more pullrights.

Each node has a set of styles and attributes associated with it. Styles differ from attributes in that they describe what the "type" of the node is are not meant to be changed once set. Examples of styles are "submenu", "text", and "bitmap". Attributes, on the other hand, also describe appearance characteristics, but may vary from time-to-time and are frequently changed by the application in response to the state of the application. Examples of attributes are "checked" and "disabled".

Styles and Attributes

Menu item styles (MIS_) are listed below:

Style Description
MIS_BITMAP Display a bitmap instead of text.
MIS_BREAK Start a new column beginning with this item.
MIS_BREAKSEPARATOR Same as MIS_BREAK except that a vertical rule is drawn to separate the columns.
MIS_BUTTONSEPARATOR Positions the item at the end of the action bar and draws a vertical separator. The focus cannot be given to this item, but it may be selected with the mouse. Any menu control may have a maximum of two items with this style.
MIS_GROUP This is a new style in Warp for which there is no documentation.
MIS_HELP Selecting this menu item sends a WM_HELP message.
MIS_MULTMENU This is a new style in Warp for which there is no documentation.
MIS_OWNERDRAW This menu item is to be drawn by the application.
MIS_SEPARATOR This menu item is a separator only. It is drawn as a horizontal line.
MIS_SINGLE This is a new style in Warp for which there is no documentation
MIS_STATIC This menu item is for informational purposes only and is not selectable.
MIS_SUBMENU This menu item has a submenu associated with it.
MIS_SYSCOMMAND Selecting this menu item sends a WM_SYSCOMMAND message.
MIS_TEXT Display text instead of a bitmap.

Menu item attributes (MIA_) are listed below:

Attribute Description
MIA_CHECKED Place a checkbox to the left of the menu item
MIA_DISABLED Do not allow the menu item to be selected
MIA_FRAMED Draw a frame around the menu item
MIA_HILITED Highlight the menu item when drawn
MIA_NODISMISS Do not dismiss the submenu when a menu item has been selected

From the Resource File

The general form of the menu template within a resource file is shown below:

menuitem:=
   MENUITEM "text", id [, style [, attribute ]]

menublock:=
   menublock | submenu | menuitem

submenu:=
   SUBMENU "text", id
   BEGIN
	menublock
   END

menu:=
   MENU id
   BEGIN
	menublock
   END

My compiler teacher would kill me for writing a recursive grammar like that, but at least she can't flunk me anymore. <grin>

You can see that the top level items do not have to be submenus, even though this is not a common occurrence.

Using Menus

Menus are typically loaded in one of two fashions, depending on their purpose. Action bar menus are loaded by the WinCreateStdWindow function. All that you need to do is specify the FCF_MENU flag in the third parameter and insure that the id of the MENU itself matches the value specified by the eighth parameter. Popup menus are loaded using the WinLoadMenu function:

(HWND)WinLoadMenu(HWND hwndParent,HMODULE hmModule,ULONG ulId)

hwndParent, although the documentation states that this must be a frame window, is the window to own the menu. For action bar menus, it should indeed be a frame, but for popup menus, you should specify HWND_OBJECT. This is because the function automatically attaches the menu to the window specified which would display an action bar on the frame even though you were going to use it as a popup menu. hmModule is the handle of the DLL containing the menu resource. ulId specifies the id of the menu resource to be loaded.

Menu items send to the client either a WM_COMMAND, WM_SYSCOMMAND, or WM_HELP message depending on the style of the item. After receiving one of these messages, you perform the action associated with the menu item. Why would you use WM_SYSCOMMAND or WM_HELP instead of WM_COMMAND? WM_SYSCOMMAND is a "system command" such as "close the window" or "size the window" and is sent by the system menu (FCF_SYSMENU). WM_HELP is used by help related items such as "general help" or "help index".

Conclusion

This month we began looking at the menu control and the basic things that we need to know before moving onto the messages that the menu control accepts and sends. This will be the topic of the next column or two which will be accompanied by a sample program (or two).