Vc++6.0如何同时打开两个.dsw文件

Vc++6.0如何同时打开两个.dsw文件,第1张

打开我的电脑或者任意一个文件夹窗口都可以

选择工具->文件夹选项->文件类型,选择列表中DSW,点击"高级”按钮,仿春打开的老芹对话框中,在“ *** 作”栏选择“open”备含耐,点击”编辑“按钮,打开的对话框中将DDE消息内的[open("%1")]删掉,然后确定,就可以打开多个工程文件了

例如,要打蚂郑升开C盘根目录下的a.txt文件,丛锋就使用:闷老

ShellExecute(NULL, "open", "explorer.exe", "/select,C:\\a.txt", NULL, SW_SHOWNORMAL)

/********源文件*************/

// FileFolderDialog.cpp : implementation file

//

#include "stdafx.h"

#include "FileFolderDialog.h"

#include <DLGS.H>

#include <WINUSER.H>

#include "CDERR.H"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__

#endif

//郑竖///谨如////////////////////////////////////////////////////////////////////////

// CFileFolderDialog

IMPLEMENT_DYNAMIC(CFileFolderDialog, CFileDialog)

// CFileFolderDialog::CFileFolderDialog(BOOL bOpenFileDialog, LPCTSTR lpszDefExt, LPCTSTR lpszFileName,

// DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd) :

// CFileDialog(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, pParentWnd)

// {

//祥丛启 }

CFileFolderDialog::CFileFolderDialog(BOOL bOpenFileDialog,DWORD dwFlags,

LPCTSTR lpszFilter,CWnd* pParentWnd)

: CFileDialog(bOpenFileDialog,NULL,NULL,

dwFlags,lpszFilter,pParentWnd)

{

Files = NULL

Folder = NULL

bParsed = FALSE

// m_ofn.nMaxFile = 2562

// lpFile = new char[2562]

// m_ofn.lpstrFile = lpFile

// m_ofn.lpstrFile[0] = NULL

}

CFileFolderDialog::~CFileFolderDialog()

{

// delete lpFile

if (Files)

{

delete[] Files

delete[] Folder

}

}

BEGIN_MESSAGE_MAP(CFileFolderDialog, CFileDialog)

//{{AFX_MSG_MAP(CFileFolderDialog)

// NOTE - the ClassWizard will add and remove mapping macros here.

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

void CFileFolderDialog::OnInitDone()

{

HideControl(chx1)

const UINT iExtraSize = 150

// Number of controls in the File Dialog

const UINT nControls = 7

// Get a pointer to the original dialog box.

CWnd *wndDlg = GetParent()

RECT Rect

wndDlg->GetWindowRect(&Rect)

// Change the size

wndDlg->SetWindowPos(NULL, 0, 0,

Rect.right - Rect.left,

Rect.bottom - Rect.top + iExtraSize,

SWP_NOMOVE)

wndDlg->CenterWindow()

// Control ID's - defined in <dlgs.h>

UINT Controls[nControls] = {stc3, stc2, // The two label controls

edt1, cmb1, // The eidt control and the drop-down box

IDOK, IDCANCEL,

lst1} // Explorer vinduet

// Go through each of the controls in the dialog box, and move them to a new position

for (int i=0 i<nControls i++)

{

CWnd *wndCtrl = wndDlg->GetDlgItem(Controls[i])

wndCtrl->GetWindowRect(&Rect)

wndDlg->ScreenToClient(&Rect) // Remember it is child controls

// Move all the controls according to the new size of the dialog.

if (Controls[i] != lst1)

wndCtrl->SetWindowPos(NULL,

Rect.left, Rect.top + iExtraSize,

0, 0, SWP_NOSIZE)

else // This is the explorer like window. It should be sized - not moved.

wndCtrl->SetWindowPos(NULL, 0, 0,

Rect.right - Rect.left,

Rect.bottom - Rect.top + iExtraSize,

SWP_NOMOVE)

}

}

int CFileFolderDialog::DoModal()

{

if (Files)

{

delete[] Files

Files = NULL

delete[] Folder

Folder = NULL

}

int ret = CFileDialog::DoModal()

if (ret == IDCANCEL)

{

DWORD err = CommDlgExtendedError()

if (err == FNERR_BUFFERTOOSMALL/*0x3003*/ && Files)

ret = IDOK

}

return ret

}

CString CFileFolderDialog::GetNextPathName(POSITION& pos) const

{

if (!Files)

return CFileDialog::GetNextPathName(pos)

ASSERT(pos)

TCHAR *ptr = (TCHAR *)pos

CString ret = Folder

ret += _T("\\")

ret += ptr

ptr += _tcslen(ptr) + 1

if (*ptr)

pos = (POSITION)ptr

else

pos = NULL

return ret

}

POSITION CFileFolderDialog::GetStartPosition()

{

if (!Files)

return CFileDialog::GetStartPosition()

if (!bParsed)

{

CString temp = Files

temp.Replace(_T("\" \""), _T("\""))

temp.Delete(0, 1)// remove leading quote mark

temp.Delete(temp.GetLength() - 1, 1) // remove trailing space

_tcscpy(Files, temp)

TCHAR *ptr = Files

while (*ptr)

{

if ('\"' == *ptr)

*ptr = '\0'

++ptr

}

bParsed = TRUE

}

return (POSITION)Files

}

void CFileFolderDialog::OnFileNameChange()

{

TCHAR dummy_buffer

// Get the required size for the 'files' buffer

UINT nfiles = CommDlg_OpenSave_GetSpec(GetParent()->m_hWnd, &dummy_buffer, 1)

// Get the required size for the 'folder' buffer

UINT nfolder = CommDlg_OpenSave_GetFolderPath(GetParent()->m_hWnd, &dummy_buffer, 1)

// Check if lpstrFile and nMaxFile are large enough

if (nfiles + nfolder > m_ofn.nMaxFile)

{

bParsed = FALSE

if (Files)

delete[] Files

Files = new TCHAR[nfiles + 1]

CommDlg_OpenSave_GetSpec(GetParent()->m_hWnd, Files, nfiles)

if (Folder)

delete[] Folder

Folder = new TCHAR[nfolder + 1]

CommDlg_OpenSave_GetFolderPath(GetParent()->m_hWnd, Folder, nfolder)

}

else if (Files)

{

delete[] Files

Files = NULL

delete[] Folder

Folder = NULL

}

CFileDialog::OnFileNameChange()

}

#define BIF_NEWDIALOGSTYLE 0x0040

#define BIF_USENEWUI (BIF_NEWDIALOGSTYLE | BIF_EDITBOX)

void CFileFolderDialog::SelectFolder(HWND hWnd,CString& strSelectPath)

{

BROWSEINFO bi

char FileName[MAX_PATH]

ZeroMemory(&bi,sizeof(BROWSEINFO))

bi.hwndOwner = hWnd

bi.pszDisplayName = FileName

bi.lpsztitle="Select Folder"

bi.ulFlags= BIF_USENEWUI

LPITEMIDLIST idl=SHBrowseForFolder(&bi)

if(idl==NULL)

return

SHGetPathFromIDList(idl,FileName)

strSelectPath.Format("%s",FileName)

}

/*********头文件**************/

#if !defined(AFX_FILEFOLDERDIALOG_H__E3E793FF_2164_4A16_A003_E9A2BA1EF7A6__INCLUDED_)

#define AFX_FILEFOLDERDIALOG_H__E3E793FF_2164_4A16_A003_E9A2BA1EF7A6__INCLUDED_

#if _MSC_VER >1000

#pragma once

#endif // _MSC_VER >1000

// FileFolderDialog.h : header file

//

/////////////////////////////////////////////////////////////////////////////

// CFileFolderDialog dialog

class CFileFolderDialog : public CFileDialog

{

DECLARE_DYNAMIC(CFileFolderDialog)

public:

// CFileFolderDialog(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs

// LPCTSTR lpszDefExt = NULL,

// LPCTSTR lpszFileName = NULL,

// DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,

// LPCTSTR lpszFilter = NULL,

// CWnd* pParentWnd = NULL)

CFileFolderDialog(BOOL bOpenFileDialog, DWORD dwFlags = OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT | OFN_ENABLESIZING |OFN_EXPLORER,

LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL)

~CFileFolderDialog()

void SelectFolder(HWND hWnd,CString& strSelectPath)

virtual int DoModal()

CString GetNextPathName(POSITION &pos) const

POSITION GetStartPosition()

private:

// char* lpFile

BOOL bParsed

TCHAR *Folder

TCHAR *Files

virtual void OnFileNameChange()

virtual void OnInitDone( )

protected:

//{{AFX_MSG(CFileFolderDialog)

// NOTE - the ClassWizard will add and remove member functions here.

//}}AFX_MSG

DECLARE_MESSAGE_MAP()

}

//{{AFX_INSERT_LOCATION}}

// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_FILEFOLDERDIALOG_H__E3E793FF_2164_4A16_A003_E9A2BA1EF7A6__INCLUDED_)


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/tougao/8188856.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-14
下一篇 2023-04-14

发表评论

登录后才能评论

评论列表(0条)

保存