主要记录下一些有啊没啊的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,"");
AppendMenu(hPopupMenu,MF_STRING,CW_DOCUMENT,"22222222(&D)");
InsertMenu(hMenu,,MF_BYPOSITION|MF_STRING|MF_POPUP,(unsigned short)hPopupMenu,"");
TrackPopupMenu(hMenu,TPM_TOPALIGN,t.x,t.y,,::GetFocus(),);

右键弹出

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, ); if (count){
for (int i=;i<count;i++){
DragQueryFile(hDrop,i,m_pzDropFile,MAX_PATH);
for (int j=;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 指向一个以''\0''结尾的字符串
int nMnuId = LOWORD(lpici->lpVerb);//user clicked menu's id //用户当前点击的菜单项ID
if( != nFlag){
return E_INVALIDARG;
}
//response the menu item command
switch(nMnuId){
case :
{
///*形成后的命令行格式为 *.exe E/D file1name空格 filename2空格 filename3...*/
m_files[]='E';//
m_files[]=0x20;//空格
ShellExecute(NULL,"open","temp.exe",m_files,NULL, SW_SHOW );
return S_OK;
}
break; case :
{
m_files[]='D';//标识符 E
m_files[]=0x20;
ShellExecute(NULL,"open","temp.exe",m_files,NULL, SW_SHOW );
return S_OK;
}
break;
}
return E_INVALIDARG;
}

右键点击

04-28 16:38