 |
|
 |
Hi I'm in need of a sidebar for my win32 traymenu. and Found your article and code. It is nice and works as a breeze. Thanks. Great work.
Can you please let me know how to use this in my win32 program which is not an mfc app.
Regards,
Kumar S
|
|
|
|
 |
|
 |
Hi
Thanks for your evaluation.
Yea, it is possible to make it work for non-MFC projects. We need to do a bit of extra work for that. Following is a very brief code that might help you to achieve the result. Please note that, the flag MFT_OWNERDRAW should be set to the MENUITEMINFO.fType.
BOOL CALLBACK DialogProc(
HWND hwndDlg, // handle to dialog box
UINT uMsg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // pointer to command line
int nCmdShow // show state of window
)
{
HWND hWindow = CreateDialog( hInstance, MAKEINTRESOURCE(IDD_DIALOG1),, 0, DialogProc );
ShowWindow( hWindow, SW_SHOW );
HMENU hMnu = CreatePopupMenu();
MENUITEMINFO stMenu;
memset( &stMenu, 0, sizeof( stMenu ));
stMenu.cbSize = sizeof( stMenu );
stMenu.fMask = MIIM_TYPE;
stMenu.fType = MFT_STRING; // | MFT_OWNERDRAW;
stMenu.dwTypeData = "Hello";
InsertMenuItem( hMnu, 0, TRUE, &stMenu );
stMenu.dwTypeData = "Hi";
InsertMenuItem( hMnu, 0, TRUE, &stMenu );
BOOL bRet = SetMenu( hWindow, hMnu );
MSG msg;
while (GetMessage (&msg, NULL, 0, 0))
{
if (!IsDialogMessage( hWindow, &msg ))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
}
return 0;
}
BOOL CALLBACK DialogProc(
HWND hwndDlg, // handle to dialog box
UINT uMsg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
POINT Point;
switch( uMsg )
{
case WM_RBUTTONDOWN:
{
HMENU hMnu = GetMenu( hwndDlg );
Point.x = LOWORD(lParam);
Point.y = HIWORD(lParam);
ClientToScreen(hwndDlg, &Point);
TrackPopupMenu( hMnu, TPM_CENTERALIGN , Point.x, Point.y, 0, hwndDlg, 0 );
break;
}
case WM_MEASUREITEM:
{
// Handle the drawing code here.
int ab = 0;
break;
}
case WM_COMMAND:
{
if( IDOK == wParam || IDCANCEL == wParam )
{
PostQuitMessage( 0 );
}
}
}
return FALSE;
}
Best regards
Nisam
"Silence will create respect and dignity; justice and fair play will bring more friends;
benevolence and charity will enhance prestige and position; courtesy will draw benevolence;
service of mankind will secure leadership and good words will overcome powerful enemies"
Ali (Peace be upon him)
|
|
|
|
 |
|
 |
Hi
Great article thanks.
However if the menus support current os theme, they would look real.
Any idea of how theme support can be added?
Regards
|
|
|
|
 |
|
 |
I have included the sidebarmenu.cpp and *.h files into a simple dialog
project, but can't compile due to the following:
c:\mydlgmenu\sidebarmenu.cpp(310) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Would appreciate any suggestions...
Thanks.
|
|
|
|
 |
|
 |
Hi thompsons
Please put the line '#include "stdafx.h"' on the top of the file named 'sidebarmenu.cpp'
|
|
|
|
 |
|
 |
Mohd,
Not every article has to be a lengthy confusing mass of switch statements and extra complications that alot of programmers seem to think they need to get a high rating. Your article does what it says and I was able to convert it to straight c in a matter of a few minutes. WHAT MORE COULD YOU ASK....It also seems some people always think that you should do all the work for them and then have the nerve to leave bad feedback. KEEP UP THE GOOD WORK.
|
|
|
|
 |
|
|
 |
|
 |
I checked out your project on Win2000 SP4, VC++ 6.0 SP5. It is impressive work. I have one doubt though-In this demo, if you click an item in the sidebar area, the corresponding menu event goes off. I want this to be avoided (Sidebar area should not respond to mouse clicks, something like what you see in Win2000 start menu sidebar).
Thanx in advance.
Anash
|
|
|
|
 |
|
 |
I appriciate your suggestion. I've been very busy. To implement what you said involves a little bit task. Anyway I will do it within a few days.
Regards
"The key is available to those who wish but turning it up to the requirement is the ability"
|
|
|
|
 |
|
 |
Hai nisam,i want some help from your side.That is, how to get the hadle of the default context menu when i right clicked on an edit box.I have subclassed my edit control and want the undo,cut,copy,paste messages should be enabled and disabled automatically if my own menu displays as trackpopupmenu.Plz help.
After the getting the menu's handle i will add my own items to that default context menu.So that it would be great.I need to implement it in my project.
Please give me reply as early as possible.
|
|
|
|
 |
|
 |
The only thing you have to do is override the function 'OnContextMenu(CWnd *pWnd,CPoint point)' of your ownner drawn Edit control and write the popup menu creation code there.
I have sent a demo application to your email address. So check it out.
"The key is available to those who wish but turning the key up to the requirement is the ability"
|
|
|
|
 |
|
 |
Mohd,
Nice job on the menu and I like the look and feel of it, but I am experiencing a few problems that I hope you can help with.
The first is with separators. When I add a separator like this:
caseOwnerPop.InsertMenu(6,MF_BYPOSITION | MF_OWNERDRAW | MF_SEPARATOR,0,"");
it does not display at all. If I remove the MF_OWNERDRAW then it displays the separator but it is surrounded by gray (from the original microsoft drawing code).
The second is the menu does not seem to size correctly (width) for longer text strings and ends up truncating the item string.
Thanks,
Doug
Doug Knudson
|
|
|
|
 |
|
 |
Dear Doug
Greatful to your evaluation. As you mentioned I have updated my class to include menu seperators. As for the second problem ie the width, I have solved it but it won't be an optimal one. So checkout the latest.
Thanks,
Mohd Nisamudheen.
The key is available to those who wish but turning the key with respect to the requirement is the ability
|
|
|
|
 |
|
 |
Because you said your sample didn't include any AppWizard statements, I wanted to see what your code looked like. Apart from it looking as though it could use a bit of tiding up, it looked, OK.
Then I began examining the code, and unless you didn't give everything, when I ran the sample, all it produced was an empty dialog (even when I typed in the statement, "CSideBarMenu mnuSideBar;" you left out).
No gradient, no menu item options, no anything; just an empty dialog with an "OK" button.
If that's what your sample is offering, I think I'll stick with AppWizard.
William
Fortes in fide et opere!
|
|
|
|
 |
|
 |
Perhaps while you were looking at the code, you might have noticed a 'Right-Click' handler? Hmmmm...
Doug Knudson
|
|
|
|
 |
|
 |
Yes, I did see it, but after having inserted one statement already, I felt I was seeing code that was incomplete and perhaps might need debugging if I ever got it to compile (for which I wasn't incline to do).
In any case, it was more curiosity than necessity that made me looked at the code.
William
Fortes in fide et opere!
|
|
|
|
 |
|
 |
Dear William
It is unlikely that the demo didn't work. Tell me which OS you are using. Even though my example was not that descriptive, I have updated it. For these kind of things, I repeat there is no need of AppWizard support.
Thanks
Mohd Nisamudheen
The key is available to those who wish but turning the key with respect to the requirement is the ability
|
|
|
|
 |
|
 |
Win2K.
William
Fortes in fide et opere!
|
|
|
|
 |
|
 |
Dear William
I think you might not have right clicked on the dialog box. So try it and let me know the outcome.
Thanks,
Mohd Nisamudheen
The key is available to those who wish but turning the key with respect to the requirement is the ability
|
|
|
|
 |
|
 |
With no offense to you, I've already put in too much time on this sample, and the bottom line is that it still doesn't work (despite my having downloaded the sample twice).
The first time it didn't work was because statements were missing, which shouldn't have happened. The second time I downloaded it, one file was missing which I subsequently copied from the first download. It compiled and linked, but still didn't work. (BTW, statements that were missing in the first download, were still missing in the second download; you didn't even correct that.)
Suggestions you're making about right clicking the mouse was one of the several things done initially. Then, as now, the program crashed due to an "Assertion Failure".
To be honesst, I don't want to spend anymore time on this sample because it will require me to want to gain something for the time I will have put into it, which means I will find myself doing debugging work (which is exactly what I DON'T want to do).
William
Fortes in fide et opere!
|
|
|
|
 |
|
 |
Dear William
Do'nt be desperate. Since this my debut article. I can assure you that it will never happen it future articles. I had tested the demo by downloading it. One problem that I found was the missing of the icon file. This time I have corrected it and tested it again, it works just fine.
You told that some statements are missing, plese tell me which were those statements.
The key is available to those who wish but turning the key with respect to the requirement is the ability
|
|
|
|
 |
|
 |
Why did you need this code? What problem did it solve in a real-world application you wrote? Promising "more stuff" in the future is bullsh*t, and implies that the article isn't complete.
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
 |
|
 |
Dear John
I needed this code as part of our company's video player project. That's why I developed this code. I can tell you - "One thing that is for ever is change".
Thanks
Mohd Nisamudheen
The key is available to those who wish but turning the key with respect to the requirement is the ability
|
|
|
|
 |
|
 |
Uh, I think the problem he solved was "Putting a graidient on the side of a menu". Given that menus aren't real-world things, I don't think your complaint applies.
|
|
|
|
 |
|
 |
John Simmons / outlaw programmer wrote:
What problem did it solve in a real-world application you wrote?
maybe you don't, but i personnaly find it useful, and was happy to see his piece of code there...
John Simmons / outlaw programmer wrote:
Promising "more stuff" in the future is bull****, and implies that the article isn't complete.
nop, not at all. A perfect program can be fully ended, but the programmers thought while coding to future features to implement later...
You voted 1 for the article because you don't like its content, i voted 1 your post for the same reasons...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
 |