Click here to Skip to main content
15,904,638 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: 3D coloured button Pin
Hamid_RT6-Oct-06 19:09
Hamid_RT6-Oct-06 19:09 
QuestionHow do I use string as a param for CreateWindowEx function Pin
scody6-Oct-06 18:14
scody6-Oct-06 18:14 
AnswerRe: How do I use string as a param for CreateWindowEx function Pin
Michael Dunn6-Oct-06 18:56
sitebuilderMichael Dunn6-Oct-06 18:56 
AnswerRe: How do I use string as a param for CreateWindowEx function Pin
Hamid_RT6-Oct-06 19:00
Hamid_RT6-Oct-06 19:00 
AnswerRe: How do I use string as a param for CreateWindowEx function Pin
scody7-Oct-06 1:18
scody7-Oct-06 1:18 
QuestionTemporary pointer Pin
Oliver1236-Oct-06 16:18
Oliver1236-Oct-06 16:18 
AnswerRe: Temporary pointer Pin
Michael Dunn6-Oct-06 18:59
sitebuilderMichael Dunn6-Oct-06 18:59 
QuestionCan't get a file path from a windows dialog and pass it too a directX api call Pin
BarryOg6-Oct-06 14:11
BarryOg6-Oct-06 14:11 
I'm trying to open a dialog box to the user and than take the filename they select and pass it too a DirectX api call which gets details about that file. I've been messing around with this for a few nights and I've got absolutely nowhere. I've read a lot about character encoding and although there are still a few blanks in my understanding I have a fairly good grasp of it. I'd imagine what I'm trying to do is simple enough and I'm running into pitfalls which are common place but no matter what I attempt to do I can't seem to get around these errors. Anyway here's my code, please take a look and if you could shed some light you'd really be doing me a huge favour.

I was given this in an earlier forum post, I really don't understand what it does, but it fixed an eariler problem I had so its in there for now.

#ifdef _UNICODE<br />
typedef wstring tstring;<br />
#else<br />
typedef string tstring;<br />
#endif


This is my function to display a file select dialog box and returns a tstring of the full path.

tstring openFile()<br />
{<br />
	OPENFILENAME ofn;       // common dialog box structure<br />
	TCHAR szFile[_MAX_PATH];       // buffer for file name<br />
	HANDLE test;<br />
<br />
	// Initialize OPENFILENAME<br />
	ZeroMemory(&ofn, sizeof(ofn));<br />
	ofn.lStructSize = sizeof(ofn);<br />
	ofn.hwndOwner = mainLoop.hWnd;<br />
	ofn.lpstrFile = szFile;<br />
	//<br />
	// Set lpstrFile[0] to '\0' so that GetOpenFileName does not <br />
	// use the contents of szFile to initialize itself.<br />
	//<br />
	ofn.lpstrFile[0] = '\0';<br />
	ofn.nMaxFile = sizeof(szFile);<br />
	ofn.lpstrFilter = _T("All\0*.*\0Text\0*.TXT\0");<br />
	ofn.nFilterIndex = 1;<br />
	ofn.lpstrFileTitle = NULL;<br />
	ofn.nMaxFileTitle = 0;<br />
	ofn.lpstrInitialDir = NULL;<br />
	ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;<br />
<br />
	// Display the Open dialog box. <br />
<br />
	if (GetOpenFileName(&ofn)==TRUE) <br />
		test = CreateFile(ofn.lpstrFile, GENERIC_READ,<br />
			0, (LPSECURITY_ATTRIBUTES) NULL,<br />
			OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,<br />
			(HANDLE) NULL);<br />
	<br />
<br />
<br />
	tstring temp (ofn.lpstrFile);<br />
<br />
	return temp;<br />
<br />
}


When I call this the contents of Info remain null, so I'm guessing what's happening here is the encoding of fileName is incorrect for this function.

fileName = openFile();<br />
	<br />
D3DXGetImageInfoFromFile(fileName.c_str(), &Info);


If I call it with the value hardcoded like so:

D3DXGetImageInfoFromFile(_T("F:\\Pictures\\ShannonTrip2006-PrintRun\\ShannonTrip2006 326.jpg"))

it works, it also works if I do the following:

fileName = _T("F:\\Pictures\\ShannonTrip2006-PrintRun\\ShannonTrip2006 326.jpg");<br />
	<br />
D3DXGetImageInfoFromFile(fileName.c_str(), &Info);


The memory of fileName in this call looks exactly the same as the memory used when I'm getting the value from openFile() yet one works and the other doesn't. Not sure where I can look after this, any help is greatly appreciated.
AnswerRe: Can't get a file path from a windows dialog and pass it too a directX api call Pin
Hamid_RT6-Oct-06 19:20
Hamid_RT6-Oct-06 19:20 
GeneralRe: Can't get a file path from a windows dialog and pass it too a directX api call Pin
BarryOg7-Oct-06 1:38
BarryOg7-Oct-06 1:38 
GeneralRe: Can't get a file path from a windows dialog and pass it too a directX api call Pin
Hamid_RT7-Oct-06 2:48
Hamid_RT7-Oct-06 2:48 
GeneralRe: Can't get a file path from a windows dialog and pass it too a directX api call Pin
BarryOg7-Oct-06 4:09
BarryOg7-Oct-06 4:09 
QuestionwaveOutGetID [modified] Pin
kk30036-Oct-06 11:51
kk30036-Oct-06 11:51 
QuestionCreateProcess() anomaly Pin
neilsolent6-Oct-06 9:21
neilsolent6-Oct-06 9:21 
QuestionAuthFilt always display the logon page Pin
Will88888886-Oct-06 8:49
Will88888886-Oct-06 8:49 
QuestionImage sequence display in Dialog [modified] Pin
Bighand20006-Oct-06 7:22
Bighand20006-Oct-06 7:22 
AnswerRe: Image sequence display in Dialog Pin
led mike6-Oct-06 8:44
led mike6-Oct-06 8:44 
GeneralRe: Image sequence display in Dialog Pin
Bighand20006-Oct-06 9:19
Bighand20006-Oct-06 9:19 
AnswerRe: Image sequence display in Dialog Pin
Hamid_RT6-Oct-06 8:48
Hamid_RT6-Oct-06 8:48 
GeneralRe: Image sequence display in Dialog [modified] Pin
Bighand20006-Oct-06 9:22
Bighand20006-Oct-06 9:22 
GeneralRe: Image sequence display in Dialog Pin
Hamid_RT6-Oct-06 19:00
Hamid_RT6-Oct-06 19:00 
GeneralRe: Image sequence display in Dialog Pin
Bighand20007-Oct-06 4:29
Bighand20007-Oct-06 4:29 
GeneralRe: Image sequence display in Dialog Pin
Hamid_RT7-Oct-06 6:54
Hamid_RT7-Oct-06 6:54 
GeneralRe: Image sequence display in Dialog Pin
Bighand20007-Oct-06 16:52
Bighand20007-Oct-06 16:52 
GeneralRe: Image sequence display in Dialog Pin
Hamid_RT7-Oct-06 19:52
Hamid_RT7-Oct-06 19:52 

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.