|
I think I saw an article I think it was nearly your answer but I dont know I saw it on the codeproject or other place.
|
|
|
|
|
Hi all,
i m using this code for creating a menu on Right Button Down of Mouse.
HMENU hMenu = ::CreatePopupMenu();
if (NULL != hMenu)
{
// add a few test items
::AppendMenu(hMenu, MF_STRING, 1, "Item 1");
::AppendMenu(hMenu, MF_STRING, 2, "Item 2");
::AppendMenu(hMenu, MF_STRING, 3, "Item 3");
ClientToScreen(&point);
int sel = ::TrackPopupMenuEx(hMenu,
TPM_CENTERALIGN | TPM_RETURNCMD,
point.x,
point.y,
m_hWnd,
NULL);
::DestroyMenu(hMenu);
it works but i dot no how can take action on its items.
Anyone can help me about this.
Thanks in advance.
|
|
|
|
|
Yeah, sure. The 1, 2 & 3 (3rd parameter) are used as the commandIDs.
When a particular menu option is chosen, this commandID will be sent to your windowProcedure in LOWORD of wParam.
So, what you need to do with the above code is look for 1, 2 or 3 as being the ID of the control that generated a WM_COMMAND message. An rough example may be seen in this code I just ripped out of a class, just pay attention to the way the messages are created and caught.
LRESULT WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_COMMAND:
switch LOWORD(wParam)
{
case <code>IDM_LargeIcons</code>:
SetIconStyle(LARGE);
break;
case <code>IDM_SmallIcons</code>:
SetIconStyle(SMALL);
break;
case <code>IDM_Details</code>:
SetIconStyle(DETAIL);
break;
case <code>IDM_List</code>:
SetIconStyle(LIST);
break;
}
break;
case WM_RBUTTONDOWN:
POINT CurPos;
GetCursorPos(&CurPos);
HMENU hPopupMenu = CreatePopupMenu();
InsertMenu(hPopupMenu, 0, MF_BYPOSITION | MF_STRING, <code>IDM_LargeIcons</code>, "Large Icons");
InsertMenu(hPopupMenu, 1, MF_BYPOSITION | MF_STRING, <code>IDM_SmallIcons</code>, "Small Icons");
InsertMenu(hPopupMenu, 2, MF_BYPOSITION | MF_STRING, <code>IDM_List</code>, "List");
InsertMenu(hPopupMenu, 3, MF_BYPOSITION | MF_STRING, <code>IDM_Details</code>, "Details");
SetForegroundWindow(GetHwnd());
TrackPopupMenu(hPopupMenu, TPM_TOPALIGN | TPM_LEFTALIGN, CurPos.x, CurPos.y, 0, GetHwnd(), NULL);
DestroyMenu(hPopupMenu);
return 0;
}
return WndProcDefault(hWnd, uMsg, wParam, lParam);
}
The easiest way to make the world a better place is to refuse to help those that wreck it....
|
|
|
|
|
Can you use of context menu,did you declare functions for these id menus.
|
|
|
|
|
Hi all,
I want to find files which are present in a particular folder.
how can i do it???
Thanks in advance
|
|
|
|
|
You may use FindFirstFile and FindNextFile functions, see [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hi Experts,
If a process is locked by another process how can I unlock it?
|
|
|
|
|
Hi,
If u are looking for some softs there is Unlocker, u can donload it on http://ccollomb.free.fr/unlocker/unlocker1.8.6.exe[^]
Or if u can exec the command "taskkill /F /Num PID" but u need to enter the appropriate PID Of the process. I don't know how u can get the PID of the process but may be if u look more under the Dos commands u will find it.
"The Ultimate Limit Is Only Your Imagination."
|
|
|
|
|
Hi,
I am writing an automatic email sending/receiving module. I'm not using MFC for this. It's actually remarkably simple without MFC. Now I want to send along Attachments. The MIME Spec is in Text Form (as in Notepad) and does not facilitate searches.
I've been scouring the MIME specs for an indication as to how to designate data held in a buffer to be sent as an attachment to an email. (i.e.: MIME Header Entries to Name the Data as a File on the Client Side, and Info to identify the Buffer).
Anyone there swith some knowledge about this.
Kind Regards
Bram van Kampen
|
|
|
|
|
Hi guys,
I have a problem: two child windows inside a parent, one normal, one with wndTopMost set
When I pass the mouse over the normal child's controls, they overwhelm the wndTopMost child and cause bad-redrawing
-> This screenshot better explains the problem:
http://img257.imageshack.us/img257/7740/topmostprobss0.jpg
Can you please help me solving the problem?
---
|
|
|
|
|
What if you use the WS_CLIPSIBLINGS style on the windows?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark, thank you very much
Using WS_CLIPSIBLINGS on the child window that should be topmost places it behind all child windows
That could be a solution also if it isn't what I was looking for
---
|
|
|
|
|
I don't understand the design of your dialog. You have controls overlapping... maybe something is missing in your example screenshot?
|
|
|
|
|
I agree with Moak - I don't understand the design. You're pretty much getting the behavior you
ask for there.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Uhm, how about creating a child window that act like a split window?
Could it be a solution?
---
|
|
|
|
|
4288 wrote: Could it be a solution?
Depends on what you want to do. How about describing your problem from a different angle? Instead of picking a specific implementation/layout maybe tell instead about the wanted functionality and user experience.
|
|
|
|
|
Id like to muse a child window as a splitter window on the right
The problem is that this child window can be taken (by resizing right side)over another child window with controls.. and the problem above rises
Maybe moving the child on right and preventing user from moving it..?
---
|
|
|
|
|
For me a splitter window would resize controls in a window... so if the controls didn't overlap in the beginning they also will not later (after the splitter bar was moved).
If you haven't looked into a splitter window implementation here on CodeProject (or another MFC variant), I would suggest trying that.
Hope it helps
/M
|
|
|
|
|
I will try it, any problem I will let you know.
And if my project will be good, I'll post it here on cp
---
|
|
|
|
|
Mark Salsbery wrote: Mark Salsbery
Microsoft MVP - Visual C++
Mark, what is the secret behind making the nice coffee smiley? Hmm... :coffee:
|
|
|
|
|
if I told you it wouldn't be a secret *cough*java*cough*
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
:cappuccino: :espresso: :caffeine: ...
Thx
|
|
|
|
|
Is there a way to remove the maximize box from the view title bar in a multidoc app? I used DeleteMenu(*) or ModifyStyle(*) to disable the maximize button but these do not remove the button from the title bar. Thanks in advance.
|
|
|
|
|
When you create the window dont set the WS_MAXIMIZEBOX style, if your using MFC check under the CWnd::PreCreateWindow method of your windows class and you can change the style from there before the window is created.
Gavin Taylor
|
|
|
|
|
Hmmm, I tried that in the CMainFrame::PreCreateWindow(CREATESTRUCT& cs) by setting:
cs.style &= ~WS_MAXIMIZEBOX
before the call to CMDIFrameWnd::PreCreateWindow(cs) which disabled the maximize box but did not remove the button from the title bar. Am I doing that wrong?
|
|
|
|