Click here to Skip to main content
15,886,067 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: disable button Pin
janpoo15-Mar-07 20:15
janpoo15-Mar-07 20:15 
AnswerRe: disable button Pin
prasad_som15-Mar-07 20:18
prasad_som15-Mar-07 20:18 
GeneralRe: disable button Pin
janpoo15-Mar-07 20:29
janpoo15-Mar-07 20:29 
GeneralRe: disable button Pin
Hamid_RT15-Mar-07 20:29
Hamid_RT15-Mar-07 20:29 
GeneralRe: disable button Pin
janpoo15-Mar-07 20:56
janpoo15-Mar-07 20:56 
GeneralRe: disable button Pin
Hamid_RT16-Mar-07 0:42
Hamid_RT16-Mar-07 0:42 
AnswerRe: disable button Pin
ThatsAlok16-Mar-07 0:01
ThatsAlok16-Mar-07 0:01 
QuestionProblem starting application by drag-drop file [modified] Pin
Jim_Csoft15-Mar-07 18:07
Jim_Csoft15-Mar-07 18:07 
Hi
In my application I want to start the application by dragging an associated data file and dropping onto the application or by file association. I retrieve the file name from the m_lpCmdLine variable which contains the file name with the complete path. I set a CString variable "strCWD" to equal the m_lpCmdLine but the File.Open command bombs to my error capture routine for "Nonexistant file". However, when I manually set strCWD to the same path and file contained in m_lpCmdLine, it opens correctly with the drag/drop routine. Does anyone know what is up with this?

Getting desperate...

code snippit (Sidebar: Can someone instruct me as to how to keep the code snippit format, i.e., tabs and spacings? Mine seem to be totally removed no matter how I format it.

// The main window has been initialized, so show and update it.
int nCmdShow = m_nCmdShow;
((CMainFrame*)m_pMainWnd)->InitialShowWindow(nCmdShow);

// Parse command line for standard shell commands, DDE, file open
// CCommandLineInfo cmdInfo;
// ParseCommandLine(cmdInfo);

// Dispatch commands specified on the command line
// if (!ProcessShellCommand(cmdInfo))
// return FALSE;

CFile File;
if (m_lpCmdLine[0] != '\0')
{
// drag & drop file to open
OnFileNew();
}
else
{
// create a new (empty) document
OnFileNew();
}
return TRUE;
}

void CFESIZER32App::OnFileNew()
{
UINT nStrLen = 0;
UINT nStrCount = 0;
char lpszCmdStr[_MAX_PATH];
CString strFilename;
CFile File;
CError Error;

if (m_lpCmdLine[0] != '\0')
{
strcpy(lpszCmdStr, m_pszHelpFilePath);
nStrLen = strlen(lpszCmdStr);
while (lpszCmdStr[nStrLen] != '\\')
{
lpszCmdStr[nStrLen] = 0;
--nStrLen;
}
g_strProgramPath = lpszCmdStr;
SetCurrentDirectory(lpszCmdStr);
strFilename = m_lpCmdLine;
// strFilename = "C:\\Documents and Settings\\My Documents\\My Application Data\\My File.fil";
}
else
{
strcpy(lpszCmdStr, m_pszHelpFilePath);
nStrLen = strlen(lpszCmdStr);
while (lpszCmdStr[nStrLen] != '\\')
{
lpszCmdStr[nStrLen] = 0;
--nStrLen;
}
g_strProgramPath = lpszCmdStr;
strFilename = g_strProgramPath + "Project" + ".fil";
}
// file exists -> open it
MessageBox(0, strFilename, "Debug Message #1", MB_OK);
if (File.Open(strFilename, CFile::modeRead))
{
File.Close();
theApp.OpenDocumentFile(strFilename);
}
// file does not exist -> create it
else if (File.Open(strFilename, CFile::modeCreate | CFile::modeWrite))
{
File.Write(&Project, sizeof(class CProjectData));
File.Close();
strFilename = g_strProgramPath + "\\Project" + ".idx";
if (File.Open(strFilename, CFile::modeCreate | CFile::modeWrite))
{
File.Close();
strFilename = g_strProgramPath + "\\Project" + ".fdb";
if (File.Open(strFilename, CFile::modeCreate | CFile::modeWrite))
{
File.Close();
}
theApp.OpenDocumentFile(strFilename);
}
}
}

QuestionRe: Problem starting application by drag-drop file Pin
prasad_som15-Mar-07 18:55
prasad_som15-Mar-07 18:55 
AnswerRe: Problem starting application by drag-drop file Pin
Jim_Csoft16-Mar-07 4:05
Jim_Csoft16-Mar-07 4:05 
Questionlist control Pin
Chen-XuNuo15-Mar-07 17:06
Chen-XuNuo15-Mar-07 17:06 
AnswerRe: list control Pin
Owner drawn15-Mar-07 17:42
Owner drawn15-Mar-07 17:42 
GeneralRe: list control Pin
Rajesh R Subramanian5-Aug-08 23:22
professionalRajesh R Subramanian5-Aug-08 23:22 
AnswerRe: list control Pin
harsh_296115-Mar-07 18:29
harsh_296115-Mar-07 18:29 
AnswerRe: list control Pin
Hamid_RT15-Mar-07 20:04
Hamid_RT15-Mar-07 20:04 
AnswerRe: list control Pin
ThatsAlok15-Mar-07 23:33
ThatsAlok15-Mar-07 23:33 
QuestionCRectTracker Pin
Gabor Kalman15-Mar-07 15:55
Gabor Kalman15-Mar-07 15:55 
Answerrepost Pin
toxcct15-Mar-07 23:25
toxcct15-Mar-07 23:25 
GeneralRe: repost Pin
ThatsAlok16-Mar-07 0:02
ThatsAlok16-Mar-07 0:02 
QuestionCRectTracer Pin
Gabor Kalman15-Mar-07 14:24
Gabor Kalman15-Mar-07 14:24 
QuestionPalindrome Number Pin
Lorisabel15-Mar-07 13:02
Lorisabel15-Mar-07 13:02 
AnswerRe: Palindrome Number Pin
David Crow15-Mar-07 16:41
David Crow15-Mar-07 16:41 
GeneralRe: Palindrome Number Pin
Lorisabel16-Mar-07 5:17
Lorisabel16-Mar-07 5:17 
Questionfile size display Pin
badenmaher6915-Mar-07 12:40
badenmaher6915-Mar-07 12:40 
AnswerRe: file size display Pin
toxcct15-Mar-07 12:56
toxcct15-Mar-07 12:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.