I have try this..When I run, the common dialog appear on the center. But When I try end the project, the program hang.. What the cause of this problem?
Last edited by matrik02; Feb 7th, 2008 at 05:00 AM.
You didn't "Put 'ReleaseHook' in the Form_Unload event.", as Chris001 specified.
You aren't unloading the form properly (perhaps by using the evil "End" command), so the Form_Unload event is not running.
The code that Chris001 provided has issues (I've had a quick look, and it seems fine).
Based on how often we see it, I would expect number 2 to be the issue. To check if it is, put a MsgBox at the start of the Form_Unload event - if it doesn't show, you aren't closing your form properly.
That is basically the same thing as the "End" command, and should not really be used (in any situation) unless you have no other alternative - like if your code is stuck in an infinite loop.
In cases where you are using sub-classing (as you are here), it results in an obvious crash.. but in many cases it will do permanent damage that you don't notice until it is too late (like corrupting databases that you are connected to).