[RESOLVED] Keep borders, prevent relocation of forms
I have a lot of forms that get placed in specific locations at run time. I need to disable relocating these forms, but I would like to keep the borders and titlebar.
I have tried jmc's codebank submission called "immobilise" but did not work for me, forms were still draggable (could be my mis_use, but no errors were thrown)
If this isn't doable, is there a way to hide only the titlebar, but maintain the 3D blue borders all around?
The codebank submission should work just fine so you probably did something wrong.
If you want to hide the titlebar but keep the borders, you need to set the ControlBox property to False and the Text property to an empty string. You can still resize the form this way though, so perhaps you want to set the FormBorderStyle to something that does not allow resizing.
If you are using my suggestion to get rid of the titlebar, then you don't need any additional code at all because there is no way to move the form that way. The only possible way I can think of would be to right-click the taskbar item and select Move in the context menu (I'm not even sure if this contextmenu is available if you set ControlBox to false, don't think so!), but from your other threads I think you are hiding the taskbar item, so that is not possible either I can't think of any other way to move the form.
If I only wanted this functionality on a handful of select forms, what's the best way to do that.
cicatrix, I think your solution would do it for all forms within the project.
If I only wanted this functionality on a handful of select forms, what's the best way to do that.
cicatrix, I think your solution would do it for all forms within the project.
No, cicatrix's code goes in the form itself, so it will only do something for every instance of that one form.
The same goes for my suggestion. Setting the ControlBox property to False and the Text property to an empty string can be done in the form itself, and any instance you create of that form will have those properties. It's really no different than any other property...
In summary: cicatrix's code will disable form moving (I think, did not test it but I assume it works), but the form will still display the titlebar.
My suggestion will hide the titlebar, which, in combination with hiding the taskbar item, gives the user no way to even try to move the form in the first place. So, you could still use cicatrix's code in combination with my suggestion, but it will never get used.
Actually did a combo of the solutions as I needed some to maintain the titlebar and some it wasn't necessary. Here's what I ended up with and it is working beautifully! Thank you both!
Re: [RESOLVED] Keep borders, prevent relocation of forms
Looks good. Might I suggest that you use non-rounded edges for the toolstrips in the camera windows? I think that will look better. To do that, you can use: