主要记录下一些有啊没啊的MFC东西。
1、单文档 去掉 无标题:在玩的时候用于FindWindow(class,title)
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if( !CFrameWnd::PreCreateWindow(cs) ) return FALSE; cs.style &= ~FWS_ADDTOTITLE ;//////////////////加上这一句. return TRUE; }
2、鼠标右键操作 ,二级菜单
POINT t; GetCursorPos(&t); HMENU hMenu,hPopupMenu; hMenu=CreatePopupMenu(); hPopupMenu=CreatePopupMenu(); AppendMenu(hMenu,MF_STRING,CW_ABOUT,"11111111"); AppendMenu(hPopupMenu,MF_STRING,CW_DOCUMENT,"22222222(&D)"); InsertMenu(hMenu,1,MF_BYPOSITION|MF_STRING|MF_POPUP,(unsigned short)hPopupMenu,"3333333"); TrackPopupMenu(hMenu,TPM_TOPALIGN,t.x,t.y,0,::GetFocus(),0);
3、文件文件夹右击菜单 注册表中位置 HKCR_AllFilesystemObjects_ShellEx_ContextMenuHandlers
在ATL工程中编辑的位置为FileView 选项卡- SimATL.rgs(*.rgs)
NoRemove AllFilesystemObjects { NoRemove ShellEx { NoRemove ContextMenuHandlers { ForceRemove SimpleShlExt = s '{×××××××××××××××(ATL-uid)}' } } } }
4、对多个文件的右击操作()
HRESULT CSimAti::Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT lpdobj, HKEY hkeyProgID) { //----------省略 。。。。。。 //拖拽操作,右击操作 //---------------------------------------------- //extern TCHAR m_files[MAX],m_pzDropFile[20] //extern int length; int count = ::DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0); if (count){ for (int i=0;i<count;i++){ DragQueryFile(hDrop,i,m_pzDropFile,MAX_PATH); for (int j=0;j<strlen(m_pzDropFile);j++) { m_files[length+j]=m_pzDropFile[j]; } length+=strlen(m_pzDropFile); m_files[length++]=0x20;//0x20 ASCII为空格,以空格来间隔各个文件 } m_files[length]=NULL; } //---------------------------------------------- GlobalUnlock(hDrop); //Release the medium storage ::ReleaseStgMedium(&mdmSTG); //return SUCCEED flag return S_OK; }
5、对文件-右键菜单的点击行为
HRESULT CSimAti::InvokeCommand(LPCMINVOKECOMMANDINFO lpici) { USES_CONVERSION; int nFlag = HIWORD(lpici->lpVerb);//如果 nFlag 不为0则说明 pici->lpVerb 指向一个以'' ''结尾的字符串 int nMnuId = LOWORD(lpici->lpVerb);//user clicked menu's id //用户当前点击的菜单项ID if(0 != nFlag){ return E_INVALIDARG; } //response the menu item command switch(nMnuId){ case 0: { ///*形成后的命令行格式为 *.exe E/D file1name空格 filename2空格 filename3...*/ m_files[0]='E';// m_files[1]=0x20;//空格 ShellExecute(NULL,"open","temp.exe",m_files,NULL, SW_SHOW ); return S_OK; } break; case 1: { m_files[0]='D';//标识符 E m_files[1]=0x20; ShellExecute(NULL,"open","temp.exe",m_files,NULL, SW_SHOW ); return S_OK; } break; } return E_INVALIDARG; }