No, just no .. insane ( windows ) ...

Coders forum. Discuss techniques, swap code snippets, ask for help etc. relating to all forms of software development.
Post Reply
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27258
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

No, just no .. insane ( windows ) ...

Post by gilesgoat »

So "occasionally I do various small tools for various uses" ...

.. that I will not explain here .. anyway .. you have a "File Dialog" in windows, that thing that when you do "Load File" or "Save File" allows you to select a file ( and more shit ) ...

Already that "it's a bit of a thing" to open/use it .. you know, those "user friendly" things like :

Code: Select all

	HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED |
		COINIT_DISABLE_OLE1DDE);
	if (SUCCEEDED(hr))
	{
		IFileSaveDialog *pFileSave;
		// Create the FileOpenDialog object.
		hr = CoCreateInstance(CLSID_FileSaveDialog, NULL, CLSCTX_ALL,
			IID_IFileSaveDialog, reinterpret_cast<void**>(&pFileSave));
.. followed by some load of other crap ...

Then you say "would it be nice if there would be a way to add a tick box/something" ..

And then after quite some search and a bit of trial and error you find that "yes you can obtain a IFDialogCustomize interface" ... and add a "Check button" with a thing like

Code: Select all

pfdc->AddCheckButton(4000, L"9 Bits DAC", FALSE);
And later on get its state with a thing like

Code: Select all

hr = pfdc->GetCheckButtonState(4000,&use9BitsChecked);	
So far "weird but not too weird" .. still "seems reasonably logical" ...

BUT THEN ... then you think "oh I'd need something I can enter a number before I save" .. and there's the AddEditBox() function ..

Hum, so far seems simple ..

Then you find there's "GetEditBoxText()" .. piece of cake, sounds all good ...

And you add those two lines in your code and .. .. .. and NOTHING WORKS .. no matter what you "the text is ALWAYS NULL" ..

WTF ?

So you go to read MSDN .. and you get a thing like "that adds an edit control" "that gives you the text from the edit control" ..

WHAT THE HECK AM I doing wrong ?

So ok "no panic" SURE there's an MSDN sample about that ? .. erm .. NO .. or if there's I have not been able to find it ...

Then you search the internet there and there .. and still nothing ..

Then more search makes you find "just a line somewhere" someone mentioning a thing like "No it does not work because that function must be called BEFORE the File Requester closes".

And it's like "HOW ON EARTH are you supposed to do that ?" .. there's no way ?

Thankfully after much deeper search "some good soul" knew the answer and put it out .. and that's where it gets "mental" ..

.. so you need to RE-CREATE a "custom version" of a "Dialog Event Handler" to handle "IFileDialogControlEvents" and then with functions "I never seen" you have to "add and when finished remove" this "event handler" to the "FileDialog" control that has to suppoer ALL methods of that thing even if only to reply with "perform default action in this case" and you have to re-define the "OnFileOk()" method such as in THAT moment you can obtain a IFCustomizePointer to use that GetEditBoxText() to read the string that is returned in some mem that you have to copy somewhere and finally release with CoTaskMemFree() and then release the PTR as well and finally you have your value instea of NULL ...

Just .. watch .. this .. crap .. you need .. https://stackoverflow.com/questions/353 ... savedialog

"All I wanted was to read text from a input field" .. ..

Mental ... ...
Giles the billy goat
"Baa"
Post Reply