000
12.05.2006, 11:37 Uhr
~scratch
Gast
|
Ich bin bis jetzt nicht draufgekommen wie ich für das c++ app also im context menu die icons zuweisen kann!?
ich brauche icons bei den context menues für: ID_BROWSEUSER ID_WHOISUSER ID_SENDFILENODE ID_PRIVMSGNODE
Code: |
void UserListContextMenu(HWND htree) { TVHITTESTINFO hit; hit.pt.x=GET_X_LPARAM(GetMessagePos()); hit.pt.y=GET_Y_LPARAM(GetMessagePos()); ScreenToClient(htree,&hit.pt); HTREEITEM h=TreeView_HitTest(htree,&hit); if (!h) h=TreeView_GetSelection(htree); if (h) { char text[256]; TVITEM i; i.mask=TVIF_TEXT|TVIF_HANDLE; i.hItem=h; i.pszText=text; i.cchTextMax=sizeof(text); text[0]=0; TreeView_GetItem(htree,&i); if (i.pszText[0]) { HMENU hMenu=GetSubMenu(g_context_menus,2); POINT p; GetCursorPos(&p); int x=TrackPopupMenu(hMenu,TPM_RETURNCMD|TPM_RIGHTBUTTON|TPM_LEFTBUTTON|TPM_NONOTIFY,p.x,p.y,0,GetParent(htree),NULL); if (x == ID_SENDFILENODE) { char *fnroot=(char*)malloc(65536*4); OPENFILENAME l={sizeof(l),}; fnroot[0]=0; l.hwndOwner = GetParent(htree); l.lpstrFilter = "All files (*.*)\0*.*\0"; l.lpstrFile = fnroot; l.nMaxFile = 65535*4; l.lpstrTitle = "Open file(s) to send"; l.lpstrDefExt = ""; l.hInstance=g_hInst; l.lpfnHook=fileHookProc; l.lpTemplateName=MAKEINTRESOURCE(IDD_FILESUBDLG); l.Flags = OFN_HIDEREADONLY|OFN_EXPLORER|OFN_ALLOWMULTISELECT|OFN_ENABLETEMPLATE|OFN_ENABLEHOOK|OFN_FILEMUSTEXIST; if (GetOpenFileName(&l)) { char *fn=fnroot; char *pathstr=""; if (fn[strlen(fn)+1]) { //multiple files pathstr=fn; fn+=strlen(fn)+1; }; while (*fn) { char fullfn[4096]; fullfn[0]=0; if (*pathstr) { safe_strncpy(fullfn,pathstr,sizeof(fullfn)); if (fullfn[strlen(fullfn)-1]!='\\') strcat(fullfn,"\\"); }; strcat(fullfn,fn); Xfer_UploadFileToUser(GetParent(htree),fullfn,i.pszText,g_filedlg_ulpath); fn+=strlen(fn)+1; }; }; free(fnroot); } else if (x == ID_BROWSEUSER) { char buf[1024]; sprintf(buf,"/%s",i.pszText); SendMessage(g_mainwnd,WM_COMMAND,IDC_SEARCH,0); Search_Search(buf); } else if (x == ID_PRIVMSGNODE) { chat_ShowRoom(i.pszText,1); } else if (x == ID_WHOISUSER) { T_Message msg; //send a message to text that is /whois C_MessageChat req; req.set_chatstring("/whois"); req.set_dest(i.pszText); req.set_src(g_regnick); msg.data=req.Make(); msg.message_type=MESSAGE_CHAT; if (msg.data) { msg.message_length=msg.data->GetLength(); g_mql->send(&msg); }; }; }; }; }
|
ich habe auf die gleiche weise wie bei buttons die icons auch beim context menu angewendet aber es zeigt kein icon an! siehe unten bei ID_BROWSEUSER
Code: |
CreateTooltip(GetDlgItem(hwndDlg,IDC_SEARCH),"Open browser"); SendDlgItemMessage(hwndDlg,IDC_SEARCH,BM_SETIMAGE,IMAGE_ICON, (LPARAM)LoadImage(g_hInst,MAKEINTRESOURCE(IDI_BROWSE),IMAGE_ICON,32,32,0));
CreateTooltip(GetDlgItem(hwndDlg,ID_VIEW_TRANSFERS),"Transfers"); SendDlgItemMessage(hwndDlg,ID_VIEW_TRANSFERS,BM_SETIMAGE,IMAGE_ICON, (LPARAM)LoadImage(g_hInst,MAKEINTRESOURCE(IDI_XFERS),IMAGE_ICON,32,32,0)); SendDlgItemMessage(hMenu,ID_BROWSEUSER,BM_SETIMAGE,IMAGE_ICON, (LPARAM)LoadImage(g_hInst,MAKEINTRESOURCE(IDI_BROWSE),IMAGE_ICON,16,16,0));
|
ich weis wie mam in context menu beim mfc icons einbindet so etwa
Code: |
void CMuteDownloadListCtrl::CreateMenu() { CString strTemp;
m_RightClkMenu.CreatePopupMenu(); strTemp = m_ExtStr.LoadString( IDS_DLOAD_RT_CLK_MENU_CAPTION_ENG + g_unStringLanguageIdOffset ); m_RightClkMenu.AddMenuTitle( strTemp, true );
strTemp = m_ExtStr.LoadString( IDS_DLOAD_RT_CLK_MENU_CANCEL_ENG + g_unStringLanguageIdOffset ); m_RightClkMenu.AppendMenu(MF_STRING,MP_CANCEL, strTemp, MAKEINTRESOURCE(IDI_CANCEL_ICON) );
strTemp = m_ExtStr.LoadString( IDS_DLOAD_RT_CLK_MENU_CLEAR_ENG + g_unStringLanguageIdOffset ); m_RightClkMenu.AppendMenu(MF_STRING,MP_CLEAR, strTemp, MAKEINTRESOURCE(IDI_CLEAR_ICON) );
strTemp = m_ExtStr.LoadString( IDS_DLOAD_RT_CLK_MENU_CLEARCOMPLETE_ENG + g_unStringLanguageIdOffset ); m_RightClkMenu.AppendMenu(MF_STRING,MP_CLEAR_COMPLETE, strTemp, MAKEINTRESOURCE(IDI_CLEAR_COMPLETE_ICON) );
strTemp = m_ExtStr.LoadString( IDS_DLOAD_RT_CLK_MENU_REMOVESTALLED_ENG + g_unStringLanguageIdOffset ); m_RightClkMenu.AppendMenu(MF_STRING,MP_CLEAR_STALLED, strTemp, MAKEINTRESOURCE(IDI_REMOVE_STALLED_ICON) );
strTemp = m_ExtStr.LoadString( IDS_DLOAD_RT_CLK_MENU_SEARCH_QUEUE_ITEM_NEXT_ENG + g_unStringLanguageIdOffset ); m_RightClkMenu.AppendMenu(MF_STRING,MP_SEARCH_QUEUE_ITEM_NEXT, strTemp, MAKEINTRESOURCE(IDI_PRIORITY_ICON) ); }
|
|