| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Menus on Dialogs |
-=> Quoting Gary Chambers to All <=-
GC> Hi All...
Hi back...
GC> I'm trying to create a dialog to be used instead of the default window
GC> created by WinCreateStdWindow. While this is no problem in itself,
GC> adding a menu to this dialog is eluding me.
I've just figured it out myself, so I'll be happy to pass on that
knowledge (it now seems obvious). First, the concepts. One thing that
differentiates dialogs from frames (regular windows), is that they repaint
themselves. When you load up a dialog (WinLoadDlg), the dialog paints
itself automatically. But when you add something to the dialog, like, oh,
lets say a menu, you need to tell the dialog that something has changed, and
that it needs to repaint itself. So the answer to the question is to send
the WM_UPDATEFRAME message. In my program, I've decided to add the menu when
the dialog is initialized. So here's my code:
MRESULT EXPENTRY MyDialogFunction(HWND hdlg, ULONG msg, MPARAM ...){
HWND hmenu;
switch(msg){
case WM_INITDLG:
hmenu=WinLoadMenu(hdlg, 0, IDD_MENU);
WinSendMsg(hdlg, WM_UPDATEFRAME, 0, 0);
...
It almost seems simple now that I know the answer. Here's some
additional info that might be useful. If you want to know the state of a
menu item, use:
WinSendMsg(hmenu, //menu handle
MM_QUERYITEMATTR, //message
MPFROM2SHORT(ID_MENUITEM, //which menuitem to check on
TRUE), //search submenus for menuitem
or just the base menu
MPFROM2SHORT(attribute, //report on which attribute
0)); //unused
For example, if you wanted to check on MIA_DISABLED, this function
would return TRUE if the menuitem was disabled, and false if the menuitem
was ?functional? (not sure of the correct term).
And if you want to set an attribute, use:
WinSendMsg(hmenu,
MM_SETITEMATTR,
MPFROM2SHORT(ID_MENUITEM,
TRUE),
MPFROM2SHORT(attribute, //which attribute to change
set)); //change attribute to what
For example, if you wanted to clear MIA_DISABLE, you would use:
WinSendMsg(hmenu, MM_SETITEMATTR, MPFROM2SHORT(ID_MENUITEM, TRUE),
MPFROM2SHORT(MIA_DISABLED, 0);
And if you wanted to check it, then you would replace 0 with MIA_DISABLED.
Related functions also allow you to insert, remove, and delete
menuitems. But I don't need that functionality, so I haven't gone over it
yet.
Stephane [TEAM OS/2]
... Brought to you by the letters O and S, and by the number 2
--- Blue Wave/OS2 v2.20
* Origin: Juxtaposition BBS (1:167/133)SEEN-BY: 50/99 78/0 270/101 620/243 711/401 409 410 413 430 808 809 934 955 SEEN-BY: 712/407 515 517 628 713/888 800/1 7877/2809 @PATH: 167/133 116 90 92 270/101 712/515 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.