Click here to Skip to main content
15,890,506 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionresizing a group box control during runtime Pin
SWDevil26-May-07 22:01
SWDevil26-May-07 22:01 
AnswerRe: resizing a group box control during runtime Pin
Michael Dunn26-May-07 22:20
sitebuilderMichael Dunn26-May-07 22:20 
AnswerRe: resizing a group box control during runtime Pin
Arman S.27-May-07 1:42
Arman S.27-May-07 1:42 
AnswerRe: resizing a group box control during runtime Pin
SWDevil27-May-07 2:15
SWDevil27-May-07 2:15 
GeneralRe: resizing a group box control during runtime Pin
Arman S.27-May-07 3:06
Arman S.27-May-07 3:06 
QuestionOwner-drawn menu bar Pin
Perspx26-May-07 21:59
Perspx26-May-07 21:59 
AnswerRe: Owner-drawn menu bar Pin
Anurag Gandhi26-May-07 22:10
professionalAnurag Gandhi26-May-07 22:10 
GeneralRe: Owner-drawn menu bar Pin
Perspx26-May-07 22:26
Perspx26-May-07 22:26 
Well, basically, there is the main window, which is "captionless", then there is a child popup window on top of it, which is also captionless, which has the menu in it. When the menu is drawn in this second window, it spans the entire width of the window, so leaves some un-drawn areas which don;t get covered by the WM_DRAWITEM message.

This is the code to make the menu items owner-drawn, and this works fine for all of the menu items, and sub-items, but it DOESNT custom draw the actual menu bar which is left showing.

HMENU hMenu;

int i, x;

for(i=0;i<GetMenuItemCount(hMenu)+1;++i) {

buffer=malloc(10); //Allocates some memory for the menu item text

LPCTSTR text=(LPCTSTR)GlobalAlloc(GPTR, 10); // Allocates memory to set the itemData property of the menu item

GetMenuString(hMenu, i, buffer, 10, MF_BYPOSITION); //Gets the menu text

text=buffer; //puts the menu text into the LPCTSTR variable

ModifyMenu(hMenu, i, MF_BYPOSITION | MF_OWNERDRAW, 0, text); //Makes the menu item owner drawn and sets the itemData to the menu item text

hSubMenu=GetSubMenu(hMenu, i); //Finds the submenu of the menu item

if(IsMenu(hSubMenu)) { //Checks if it really is a submenu

for(x=0;x<GetMenuItemCount(hSubMenu)+1;++x) { //loops through all submenu items
subBuffer=malloc(30); //allocates some memory
GetMenuString(hSubMenu, x, subBuffer, 30, MF_BYPOSITION); //Gets the text
ModifyMenu(hSubMenu, x, MF_BYPOSITION | MF_OWNERDRAW, 0, (LPCTSTR)subBuffer); //Sets the owner drawn style
}

}

GlobalFree((LPSTR)text); //Frees memory

free(buffer); //Frees the memory

}

Thanks for your help!
--PerspX
QuestionBitmap bits Pin
bankai12326-May-07 21:35
bankai12326-May-07 21:35 
AnswerRe: Bitmap bits Pin
Chris Losinger27-May-07 5:10
professionalChris Losinger27-May-07 5:10 
QuestionHow to add menu when right click at client area? Pin
Max++26-May-07 20:23
Max++26-May-07 20:23 
AnswerRe: How to add menu when right click at client area? Pin
Anurag Gandhi26-May-07 22:08
professionalAnurag Gandhi26-May-07 22:08 
QuestionASSERT(m_pCtrlSite == NULL) error on activex addition Pin
shivditya26-May-07 18:59
shivditya26-May-07 18:59 
AnswerRe: ASSERT(m_pCtrlSite == NULL) error on activex addition Pin
Garth J Lancaster27-May-07 0:34
professionalGarth J Lancaster27-May-07 0:34 
QuestionRe: ASSERT(m_pCtrlSite == NULL) error on activex addition Pin
shivditya27-May-07 5:22
shivditya27-May-07 5:22 
AnswerRe: ASSERT(m_pCtrlSite == NULL) error on activex addition Pin
Garth J Lancaster27-May-07 12:15
professionalGarth J Lancaster27-May-07 12:15 
QuestionRe: ASSERT(m_pCtrlSite == NULL) error on activex addition Pin
shivditya27-May-07 16:56
shivditya27-May-07 16:56 
AnswerRe: ASSERT(m_pCtrlSite == NULL) error on activex addition Pin
Garth J Lancaster27-May-07 17:13
professionalGarth J Lancaster27-May-07 17:13 
QuestionRe: ASSERT(m_pCtrlSite == NULL) error on activex addition Pin
shivditya27-May-07 19:04
shivditya27-May-07 19:04 
Questionmap & pair Pin
C_Zealot26-May-07 18:33
C_Zealot26-May-07 18:33 
AnswerRe: map & pair Pin
Garth J Lancaster26-May-07 19:06
professionalGarth J Lancaster26-May-07 19:06 
AnswerRe: map & pair Pin
Michael Dunn26-May-07 20:42
sitebuilderMichael Dunn26-May-07 20:42 
QuestionBack Patching an EXE as a Post Build Step Pin
Jeffrey Walton26-May-07 17:14
Jeffrey Walton26-May-07 17:14 
AnswerRe: Back Patching an EXE as a Post Build Step Pin
Garth J Lancaster26-May-07 18:59
professionalGarth J Lancaster26-May-07 18:59 
GeneralRe: Back Patching an EXE as a Post Build Step Pin
Jeffrey Walton26-May-07 20:29
Jeffrey Walton26-May-07 20:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.