Bonjour,
j'ai créé une icone dans la TrayBar et elle affiche un popupMenu lorsque je fais un clic droit. j'ai une fonction "OnTrayNotify(WPARAM wParam, LPARAM lParam)" qui me permet de gérer l'affichage avec la fonction "TrackPopupMenu" et de récupérer l'item du menu sur lequel j'ai cliqué.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 afx_msg LRESULT CCamSetupDlg::OnTrayNotify(WPARAM wParam, LPARAM lParam) { if ((UINT)wParam != 1) return 0 ; POINT pt; CMenu myMenu,*tmpMenu; int nCmd; switch (lParam) { case WM_RBUTTONDOWN: case WM_CONTEXTMENU: SetForegroundWindow(); GetCursorPos(&pt); myMenu.CreatePopupMenu(); myMenu.AppendMenu(MF_STRING|MF_POPUP,(UINT)this->m_FrameFormatMenu->m_Menu.GetSafeHmenu(),_T("Frame Format")); myMenu.AppendMenu(MF_STRING|MF_POPUP,(UINT)m_FrameRateMenu->m_Menu.GetSafeHmenu(),_T("Frame Rate")); myMenu.AppendMenu(MF_STRING|MF_POPUP,(UINT)this->m_FrameExposureMenu->m_Menu.GetSafeHmenu(),_T("Exposure Time")); myMenu.AppendMenu(MF_STRING,200,_T("Restore")); myMenu.AppendMenu(MF_STRING,201,_T("Exit"));*/ nCmd = myMenu.TrackPopupMenu(TPM_RETURNCMD|TPM_BOTTOMALIGN|TPM_LEFTBUTTON|TPM_RIGHTALIGN, pt.x, pt.y, this); PostMessage(WM_NULL, 0, 0); if (nCmd >0) { CString str; myMenu.GetMenuStringA(nCmd, str, MF_BYCOMMAND); if (str == _T("Exit")) AfxGetMainWnd()->PostMessage(WM_SYSCOMMAND,SC_CLOSE,0); else if (str == _T("Restore")) this->ShowWindow(SW_RESTORE); else { //mes fonctions } } myMenu.Detach(); break; case WM_LBUTTONDBLCLK: this->ShowWindow(SW_RESTORE); break; } return 0; }
les Menus "Frame Format" et "Frame Rate" sont créés dynamiquement au lancement du programme et peuvent etre modifiés par l'utilisateur.
l'affichage se passe bien lorsque je fais un clic droit. Par contre, lorsque je lis la value de "nCmd" dans le OnTrayNotify, j'ai des valeurs identiques pour les 2 menus, comme par exemple :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 m_FrameFormatMenu->m_Menu.CreatePopupMenu(); m_FrameFormatMenu->m_Menu.InsertMenuA(0, MF_BYPOSITION | MF_SEPARATOR, FRAME_FORMAT + m_FrameFormatMenu->m_NbItem++); m_FrameFormatMenu->m_Menu.InsertMenu(1, MF_BYPOSITION | MF_STRING, FRAME_FORMAT + m_FrameFormatMenu->m_NbItem++, _T("1280 x 1024")); m_FrameFormatMenu->m_Menu.InsertMenu(2, MF_BYPOSITION | MF_STRING, FRAME_FORMAT + m_FrameFormatMenu->m_NbItem++, _T("528 x 528"));
nCmd = 106 lorsque je clique sur le 2ème élément de "FRAME RATE" et la fonction "GetMenuStringA" me retourne le 4ème élément de "FRAME FORMAT".
si quelqu'un a une idée...
Partager