Click here to Skip to main content
15,887,683 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: OnDropFiles() problem Pin
ghunzel0627-Mar-07 18:56
ghunzel0627-Mar-07 18:56 
GeneralRe: OnDropFiles() problem Pin
Parthi_Appu27-Mar-07 19:19
Parthi_Appu27-Mar-07 19:19 
AnswerRe: OnDropFiles() problem Pin
Stephen Hewitt27-Mar-07 17:23
Stephen Hewitt27-Mar-07 17:23 
GeneralRe: OnDropFiles() problem Pin
ghunzel0627-Mar-07 17:50
ghunzel0627-Mar-07 17:50 
GeneralRe: OnDropFiles() problem Pin
Parthi_Appu27-Mar-07 17:56
Parthi_Appu27-Mar-07 17:56 
GeneralRe: OnDropFiles() problem Pin
ghunzel0627-Mar-07 18:20
ghunzel0627-Mar-07 18:20 
GeneralRe: OnDropFiles() problem Pin
David Crow28-Mar-07 3:00
David Crow28-Mar-07 3:00 
GeneralRe: OnDropFiles() problem Pin
Stephen Hewitt27-Mar-07 17:58
Stephen Hewitt27-Mar-07 17:58 
Modify code like this:
void CLaunchDlg::OnDropFiles(HDROP dropInfo)
{
	// Get the number of pathnames that have been dropped
	WORD wNumFilesDropped = DragQueryFile(dropInfo, -1, NULL, 0);
 
	CString firstFile= _T("");
 
	// get all file names. but we'll only need the first one.
	for (WORD x = 0 ; x < wNumFilesDropped; x++)
	{
		// Get the number of bytes required by the file's full pathname
		WORD wPathnameSize = DragQueryFile(dropInfo, x, NULL, 0);
 
		// Allocate memory to contain full pathname & zero byte
		WCHAR* npszFile = new(nothrow) WCHAR[wPathnameSize + 1]; // SFH: I use 'new' and not 'LocalAlloc'.
 
		// If not enough memory, skip this one
		if (npszFile == NULL)
		{
			continue;
		}
 
		// Copy the pathname into the buffer
		DragQueryFile(dropInfo, x, npszFile, wPathnameSize + 1);
 
		// we only care about the first
		LPCTSTR pFileName = PathFindFileName(npszFile); // SFH: Extract just the filename.
		firstFile = pFileName;
 
		// clean up
		delete [] npszFile; // SFH: I use 'delete' and not 'LocalFree'.

		break; // SFH: Since we only care about the first why keep looping?
	}

	SetWindowText(firstFile);
}



Steve

GeneralRe: OnDropFiles() problem Pin
ghunzel0627-Mar-07 18:45
ghunzel0627-Mar-07 18:45 
GeneralRe: OnDropFiles() problem Pin
Stephen Hewitt27-Mar-07 18:53
Stephen Hewitt27-Mar-07 18:53 
GeneralRe: OnDropFiles() problem Pin
ghunzel0627-Mar-07 19:06
ghunzel0627-Mar-07 19:06 
QuestionSetTimer before CreateWindow() Pin
LiYS27-Mar-07 16:48
LiYS27-Mar-07 16:48 
AnswerRe: SetTimer before CreateWindow() Pin
Stephen Hewitt27-Mar-07 17:09
Stephen Hewitt27-Mar-07 17:09 
GeneralRe: SetTimer before CreateWindow() [modified] Pin
LiYS27-Mar-07 17:22
LiYS27-Mar-07 17:22 
GeneralRe: SetTimer before CreateWindow() Pin
Stephen Hewitt27-Mar-07 17:26
Stephen Hewitt27-Mar-07 17:26 
GeneralRe: SetTimer before CreateWindow() Pin
LiYS27-Mar-07 17:43
LiYS27-Mar-07 17:43 
GeneralRe: SetTimer before CreateWindow() [modified] Pin
LiYS27-Mar-07 19:45
LiYS27-Mar-07 19:45 
GeneralRe: SetTimer before CreateWindow() Pin
Stephen Hewitt27-Mar-07 19:53
Stephen Hewitt27-Mar-07 19:53 
Questionfloating-point to hex conversion Pin
morocco21227-Mar-07 12:03
morocco21227-Mar-07 12:03 
AnswerRe: floating-point to hex conversion Pin
cp987627-Mar-07 14:19
cp987627-Mar-07 14:19 
GeneralRe: floating-point to hex conversion Pin
morocco21228-Mar-07 2:58
morocco21228-Mar-07 2:58 
AnswerRe: floating-point to hex conversion Pin
David Crow27-Mar-07 17:08
David Crow27-Mar-07 17:08 
GeneralRe: floating-point to hex conversion Pin
morocco21228-Mar-07 3:01
morocco21228-Mar-07 3:01 
GeneralRe: floating-point to hex conversion Pin
David Crow28-Mar-07 3:05
David Crow28-Mar-07 3:05 
GeneralRe: floating-point to hex conversion Pin
morocco21228-Mar-07 3:40
morocco21228-Mar-07 3:40 

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.