Click here to Skip to main content
16,011,120 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to get HWND of my application window ? Pin
Amarelia26-Aug-05 1:08
Amarelia26-Aug-05 1:08 
AnswerRe: How to get HWND of my application window ? Pin
Jack Puppy26-Aug-05 1:41
Jack Puppy26-Aug-05 1:41 
AnswerRe: How to get HWND of my application window ? Pin
MailtoGops26-Aug-05 3:28
MailtoGops26-Aug-05 3:28 
QuestionCmdUpdateUI Pin
Joel Holdsworth26-Aug-05 1:05
Joel Holdsworth26-Aug-05 1:05 
AnswerRe: CmdUpdateUI Pin
Roger Allen26-Aug-05 2:45
Roger Allen26-Aug-05 2:45 
AnswerRe: CmdUpdateUI Pin
David Crow26-Aug-05 3:13
David Crow26-Aug-05 3:13 
GeneralRe: CmdUpdateUI Pin
Joel Holdsworth26-Aug-05 4:39
Joel Holdsworth26-Aug-05 4:39 
GeneralRe: CmdUpdateUI Pin
David Crow26-Aug-05 4:48
David Crow26-Aug-05 4:48 
Joel Holdsworth wrote:
Much more elegant!

Agreed. Here's how I did it:

BEGIN_MESSAGE_MAP(CMyView, CListView)
    //{{AFX_MSG_MAP(CMyView)
    ON_NOTIFY_REFLECT(NM_RCLICK, OnRclick)
    ON_UPDATE_COMMAND_UI(ID_ITEM_DELETE, OnUpdateItemDelete)
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()
 
void CMyView::OnRclick(LPNMHDR, LRESULT* pResult) 
{
    CListCtrl   &ctrlList = GetListCtrl();
    CPoint      pt;
    CMenu       menu,
                *pSubMenu;
 
    if (ctrlList.GetNextItem(-1, LVIS_SELECTED) != -1)
    {
        menu.LoadMenu(IDR_ITEM_MENU);
        pSubMenu = menu.GetSubMenu(0);
 
        // where was the mouse clicked?
        pt = GetMessagePos();
 
        pSubMenu->TrackPopupMenu(TPM_LEFTALIGN, pt.x, pt.y, this);
    }
 
    *pResult = 0;
}
 
void CMyView::OnUpdateItemDelete(CCmdUI* pCmdUI) 
{
    CListCtrl   &ctrlList = GetListCtrl();

    pCmdUI->Enable(ctrlList.GetNextItem(-1, LVIS_SELECTED) != -1);	
}
Now the Delete item in the main menu, the toolbar button, and the context menu is enabled/disabled correctly.


"One must learn from the bite of the fire to leave it alone." - Native American Proverb


GeneralRe: CmdUpdateUI Pin
Joel Holdsworth29-Aug-05 22:20
Joel Holdsworth29-Aug-05 22:20 
GeneralRe: CmdUpdateUI Pin
Joel Holdsworth29-Aug-05 23:22
Joel Holdsworth29-Aug-05 23:22 
QuestionDynamically allocated strings Pin
Anonymous26-Aug-05 0:40
Anonymous26-Aug-05 0:40 
AnswerRe: Dynamically allocated strings Pin
Bob Ciora26-Aug-05 1:08
Bob Ciora26-Aug-05 1:08 
GeneralRe: Dynamically allocated strings Pin
Cedric Moonen26-Aug-05 1:13
Cedric Moonen26-Aug-05 1:13 
GeneralRe: Dynamically allocated strings Pin
sunit526-Aug-05 1:09
sunit526-Aug-05 1:09 
AnswerRe: Dynamically allocated strings Pin
oleg6326-Aug-05 4:38
professionaloleg6326-Aug-05 4:38 
QuestionCStatic Pin
Nishad S26-Aug-05 0:35
Nishad S26-Aug-05 0:35 
AnswerRe: CStatic Pin
Jack Puppy26-Aug-05 1:55
Jack Puppy26-Aug-05 1:55 
QuestionHow to use CMonthCalCtrl to get the Selected Date == Urgent need Pin
parims26-Aug-05 0:20
parims26-Aug-05 0:20 
AnswerRe: How to use CMonthCalCtrl to get the Selected Date == Urgent need Pin
Rage26-Aug-05 0:30
professionalRage26-Aug-05 0:30 
QuestionRe: How to use CMonthCalCtrl to get the Selected Date == Urgent need Pin
David Crow26-Aug-05 3:28
David Crow26-Aug-05 3:28 
QuestionHow to Retrieve all user names from Administrators Group??? Pin
Supriya Tonape25-Aug-05 23:11
Supriya Tonape25-Aug-05 23:11 
AnswerRe: How to Retrieve all user names from Administrators Group??? Pin
Steve S25-Aug-05 23:49
Steve S25-Aug-05 23:49 
GeneralRe: How to Retrieve all user names from Administrators Group??? Pin
Supriya Tonape28-Aug-05 23:34
Supriya Tonape28-Aug-05 23:34 
GeneralRe: How to Retrieve all user names from Administrators Group??? Pin
sunit526-Aug-05 0:52
sunit526-Aug-05 0:52 
AnswerRe: How to Retrieve all user names from Administrators Group??? Pin
David Crow26-Aug-05 3:35
David Crow26-Aug-05 3:35 

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.