ReadOnly in SaveFileDialog?

Troy

Well-known member
Joined
Feb 7, 2005
Messages
153
Programming Experience
10+
Hey guys Anyone know how to make the input in the SaveFileDialog Read Only. I tried the .Readonly option but it apparently doesn't exist in .net.

I'm wanting to allow the user to select a directory to save a file but not be able to rename it.;)
 
There maybe something in the FileOK event that you could look at. Validate the file name there. Or failing that there also be something in the CommonDialog.HookProc or CommonDialog.DefWndProc. Check out the FileOk event first though because as I said i may be possible to validate text in the filename box from there.

EDIT : Yes, looking at the hookProc method more closely it would be possible to create a readonly CommonDialog however it would mean gettting a bit lower level and intercepting windows messages to get the job done.
 
There maybe something in the FileOK event that you could look at. Validate the file name there. Or failing that there also be something in the CommonDialog.HookProc or CommonDialog.DefWndProc. Check out the FileOk event first though because as I said i may be possible to validate text in the filename box from there.

EDIT : Yes, looking at the hookProc method more closely it would be possible to create a readonly CommonDialog however it would mean gettting a bit lower level and intercepting windows messages to get the job done.


ok I'm Following what your saying a bit but still not sure what to hook?

rofl why couldn't they just make the field Enabled /disabled lol.
 
Ok, so by overriding the HookProc method in your app will mean that you will get all the messages that the OS sends to that window before the SaveFileDialog does. So it might be possible using the Message.Create method to send a message to the SFD to disable the textbox in question. This will of course mean first you will have to use a few other WIN32 methods such as FindWindowEx for example to get the hWnd of the textbox you need. You can get the required functions from a program called API viewer. You do realise this is all very theoretical, i am sure it is possible but i'm wondering if it is worth the effort. You could just go ahead and create your own SaveFileDialog, by inheriting from CommonDialog or even starting from scratch.
 
roflmao, yeah I was thinking bah I'll just make my own hehe.
 
Back
Top