Click here to Skip to main content
15,914,447 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: executing files ie file manager Pin
Joaquín M López Muñoz21-Nov-01 8:06
Joaquín M López Muñoz21-Nov-01 8:06 
QuestionSeeking in CMemFile...? Pin
21-Nov-01 7:29
suss21-Nov-01 7:29 
GeneralToolbars and MDI Apps Pin
Chambers21-Nov-01 6:20
Chambers21-Nov-01 6:20 
GeneralRe: Toolbars and MDI Apps Pin
Roger Allen21-Nov-01 7:17
Roger Allen21-Nov-01 7:17 
GeneralRe: Toolbars and MDI Apps Pin
Chambers21-Nov-01 7:58
Chambers21-Nov-01 7:58 
GeneralUsing Word Doc on CHtmlView. Pin
21-Nov-01 5:35
suss21-Nov-01 5:35 
GeneralContext Menus w/o Doc/View Pin
John Clump21-Nov-01 4:28
John Clump21-Nov-01 4:28 
GeneralRe: Context Menus w/o Doc/View Pin
Roger Allen21-Nov-01 7:25
Roger Allen21-Nov-01 7:25 
You can do this quite easily. First Create a menu resource

MyPopup->Item 1
         Item 2
         ...


Then handle the NM_RCLICK message for the list control and add code such as this

CMenu menu ;
CMenu *pPopup ;
CPoint point ;
int item_selected ;

GetCursorPos(&point) ;

menu.LoadMenu(IDR_MENU_RESOURCE_ID) ;
pPopup = menu.GetSubMenu(0) ; // you need this or the popup does not work properly
item_selected = ::TrackPopupMenuEx(pPopup->m_hMenu, TPM_RETURNCMD | TPM_NONOTIFY, point.x, point.y, m_hWnd, NULL) ;

switch (item_Selected)
{
case ID_MENU_ITEM1 :
 ...
 break ;
 // etc
}



You use the TPOM_RETURNCMD flag so that you don;t have to handle the command as WM_COMMAND message. This allows you to keep all the code together for the different menu options in one place. You also don;t have to write all the ON_COMMAND macros and function prototypes Smile | :)

EnjoyCool | :cool:

Roger Allen
Sonork 100.10016
GeneralCome on you all, WMI can't be the only solution!!!!! Pin
Tommy H D Svensson21-Nov-01 3:42
Tommy H D Svensson21-Nov-01 3:42 
GeneralI have an error while executing Win32 Release application! Pin
mabang21-Nov-01 2:52
mabang21-Nov-01 2:52 
GeneralRe: I have an error while executing Win32 Release application! Pin
Bernhard21-Nov-01 3:24
Bernhard21-Nov-01 3:24 
GeneralI want to recommend an application Pin
er21-Nov-01 1:39
er21-Nov-01 1:39 
GeneralRe: I want to recommend an application Pin
21-Nov-01 3:48
suss21-Nov-01 3:48 
QuestionHow to draw a part of Desktop Pin
21-Nov-01 1:38
suss21-Nov-01 1:38 
AnswerRe: How to draw a part of Desktop Pin
Roger Allen21-Nov-01 7:29
Roger Allen21-Nov-01 7:29 
GeneralCWinApp::OnIdle in Dll - is NOT called Pin
DataPrasad21-Nov-01 1:05
DataPrasad21-Nov-01 1:05 
GeneralRe: CWinApp::OnIdle in Dll - is NOT called Pin
Michael Dunn21-Nov-01 6:20
sitebuilderMichael Dunn21-Nov-01 6:20 
GeneralDialog buttons Pin
et20-Nov-01 23:17
et20-Nov-01 23:17 
GeneralRe: Dialog buttons Pin
Christian Graus21-Nov-01 0:39
protectorChristian Graus21-Nov-01 0:39 
GeneralScope of try...catch constructions (over threads) Pin
EiSl20-Nov-01 21:42
EiSl20-Nov-01 21:42 
GeneralRe: Scope of try...catch constructions (over threads) Pin
Joaquín M López Muñoz20-Nov-01 23:11
Joaquín M López Muñoz20-Nov-01 23:11 
GeneralRe: Scope of try...catch constructions (over threads) Pin
Rui Lopes20-Nov-01 23:15
Rui Lopes20-Nov-01 23:15 
QuestionCFindFile? Pin
20-Nov-01 20:57
suss20-Nov-01 20:57 
AnswerRe: CFindFile? Pin
Rassman20-Nov-01 22:03
Rassman20-Nov-01 22:03 
GeneralOwndraw scrollbars question Pin
Osykin Roman20-Nov-01 20:40
Osykin Roman20-Nov-01 20:40 

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.