I designed a form on 1600*1200 resolution for my own use which works fine. Obviously on another resolution I'm missing parts of the screen.
Is there a way I can implement scroll bars when resolution is other that 1600*1200?
The classic way of doing this (book examples abound) is to use a picture box - but that has several drawbacks, not least that you have a bunch of code to write..
Easiest way is to cheat!
Add an MDI form to your application. Set it's title to be the same as your form. Set the Border style on your form to None, and set it's MDIChild property to true.
And that's it. You don't really have to make ANY further changes to your code EXCEPT if you are trying to show your form modally since, unfortunately MDI forms cannot be shown modally.
While this is a good cheat, there is one (large) problem - you can't put controls onto an MDI form, or at least, you can't put controls without an align property.
This limits you to PictureBoxes, CoolBars, ToolBars etc. All of which influence the size and position of the scroll bars.
If I am wrong here Mike could you let me know?
Phailak, does your screen really only work on 1600x1200??? I know its more work, but I generally have code in the Form_Resize event handler which keeps everything in line.
Is it possible to have some more information about what your form does?
Well, the reason I worked with 1600*1200 was to have everything on one screen. Its an RPG app and I don't want to mess with switching from one from to the other. I have a bunch of buttons, listbox, combo boxes etc...
Some friends want it so I'm trying to fit it otherwise...
I played with resolution on resizing controls and stuff, it works for positionning but Fonts are messed up as well as some controls interlocking or something.
HScroll1.Max = (Picture1.Width - Width) / 300
VScroll1.Max = (Picture1.Height - Height) / 300
End Sub
Private Sub HScroll1_Change()
Picture1.Left = -HScroll1.Value * 300
End Sub
Private Sub HScroll1_Scroll()
Picture1.Left = -HScroll1.Value * 300
End Sub
Private Sub VScroll1_Change()
Picture1.Top = -VScroll1.Value * 300
End Sub
Private Sub VScroll1_Scroll()
Picture1.Top = -VScroll1.Value * 300
End Sub
'-----------
This is just a code snippet - take it and improve on it. You might need to change some of the numbers to make sure the bars appear at the right time and in the right place.
I have a magical technique which I use to generate those numbers, but I will share it with you.
I run the code, and when things appear in the wrong place, I add values to things to shift them up/down left/right.
I haven't put them in as constants because I wanted them to stand out. Once you've got the values correct (ie. the scrollbars are in the right place, etc) you can package them in constants.
Actually, this begs the question - how to you get the dimensions of the usuable bit of a form?
You're quite right about the limitations of what you can put onto an MDI parent form - but we're not doing this.
The issue here is that Phailak already has a form, with all the controls etc that he wants on it. So all we need to do is make it an MDI child. Nothing else has to change at all (well, apart from changing the border setting as noted). i.e. all we are doing is hosting the original form.
One additional advantage of this 'cheat' is that if the original form has a menu bar then the MDI parent inherits this, and so the menu doesn't scroll...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.