| |

VerySource

 Forgot password?
 Register
Search
View: 568|Reply: 4

Problems with self-drawing for multiple document menus? ? ? ? ? ? , Very anxious. Please master

[Copy link]

2

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-4 21:50:01
| Show all posts |Read mode
Continuous asked several times, and have never had a viable answer.
I would like to draw from the menu program. Before self-painted, you must first get a handle on the current window menus.
According to the handle and then, self-drawing property. And reload the OnDrawItem () and OnMeasureItem () two functions, specifically provided from painted.
But I get the menu using the following two handles, always wrong. (May CMainFrame class)
However, in view OnInitUpdate () function used in error:
CMenu * pMenu = GetMenu (); // pointer can be obtained
HMENU hMenu = pMenu-> GetSafeHmenu (); // get a handle when mistakes? ? ?

My intention is when opening a new document, you get the current menu and then overloads the above two functions, using the obtained handles settings from the painting property, but does not work.
problem:
(1) Why get a pointer to the menu, but the menu was not handle.
(2) When you open a document (click New). No matter what time of the currently loaded document. You can get the current menu, and set the self-painted property. How to achieve? ? ? Thank you
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 United States

Post time: 2020-1-5 11:15:01
| Show all posts
void CMainFrame :: OnInitMenu (CMenu * pMenu)
{
CFrameWnd :: OnInitMenu (pMenu);
Ranch
CMenu * pSubMenu;
UINT nCount, nSubCount, nID;
nCount = pMenu-> GetMenuItemCount (); // Number of columns of submenu
for (UINT i = 0; i <nCount; i ++)
{
pSubMenu = pMenu-> GetSubMenu (i);
nSubCount = pSubMenu-> GetMenuItemCount (); // The number of menu menu items in this column
for (UINT j = 0; j <nSubCount; j ++)
{
nID = pSubMenu-> GetMenuItemID (j);
// Add MF_OWNERDRAW flag to all menus in the frame menu
pSubMenu-> ModifyMenu (j, MF_BYPOSITION | MF_OWNERDRAW, nID);
}
}
}
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-5 11:21:02
| Show all posts
GetSubMenu function
Reply

Use magic Report

2

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-1-5 15:42:02
| Show all posts
If you follow the steps above, the first time (without opening a sub-window) is to draw the main frame menu. After opening the sub-window, the menu changes. At this time, the program does not execute the DrawItem function to redraw itself (it has already been drawn once when displaying the main menu). Only displayed when the mouse moves over it
Reply

Use magic Report

0

Threads

18

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-8-3 09:45:01
| Show all posts
Learn.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list