borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Movie Thumbnail Sample)Next Topic (Making A Demo Version) New Topic New Poll Post Reply
AndreaVB Forum : VB General : HELP! (Again) This time on screen resolution... lol
Poster Message
inertiascience
Level: Guest


icon HELP! (Again) This time on screen resolution... lol

Hiee!!
Im back again, with an urgant question for my presentation tomarrow. The projector can only go to a certain resolution  (1024x768) and I programmed the program Im using for my presentation in 1600x1200 resolution. Is there any way to automatically resize the program for the resolution?   I really need this urgantly.   The only Way I know of is to resize all of the controls in 1024x788 to fit the resolution. I hope there's an eiasier way...  

27-02-2003 at 10:56 PM
| Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: HELP! (Again) This time on screen resolution... lol

It used to be have all programs fit on a 800x600 resolution (that is, designed for). Now it's 1024x768 - XP's default, and the standard resolution for many PC's.

[meaning: you shouldn't have designed it for 1600x1200, some monitors don't support that resolution [smaller LCDs]].

But for your problem, the easiest thing would be to redesign the form, just make all the controls smaller by the same amounts.

EX:

Select all labels, go to the properties, subtract x from the width, x from the height->it will resize all of the labels at the same time. Do the same for all controls. Then manually move all of them, save (if it looks right) and compile/run.

Otherwise you'd have to keep track in code of the form's size, the current screen resolution, and resize the controls via code, and move the controls via code. I've done it before, but it's a lot easier to do it in design.

For help in the future, set your computer's resolution at 1 step higher than 1024x768. That way your design window in VB (with the immediate pane, properties and controls pane visible) is about the size of a 1024x768 screen. as long as everything is visible there, it should be at that resolution.




____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)

27-02-2003 at 11:35 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
inertiascience
Level: Guest

icon Re: HELP! (Again) This time on screen resolution... lol

The thing is is that all my labels and graphics are not the same size and making them the same size would distort them.   

28-02-2003 at 01:33 AM
| Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: HELP! (Again) This time on screen resolution... lol

No two are the same size? that's weird. but then you just have to resize them all manually.

____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)

28-02-2003 at 04:28 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
yronium
Level: Moderator


Registered: 14-04-2002
Posts: 907
icon Re: HELP! (Again) This time on screen resolution... lol

(OK, I'm writing without VB and the code I've written already to consult)


Dim ctl as Control

For Each ctl in Me.Controls

   ctl.Height = ctl.Height * 100 / 78.125   ' (1024:100 = 800:x)
   ctl.Width = ctl.Width * 100 / 78.125    ' (768:100 = 600:x)

Next ctl

Me.Height = Me.Height * 100 / 78.125
Me.Width = Me.Width * 100 / 78.125


Each form has got a Controls collection, so you can use it to manage several controls at a time. Then you have to set separately each form's dimensions.

Hope it helps



____________________________
Real Programmer can count up to 1024 on his fingers

28-02-2003 at 08:02 AM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: HELP! (Again) This time on screen resolution... lol

That code is useful, but the hardest part is actually moving the controls on the form so it looks the same way. By the time you get that coded (since each control has to be done separately [bit easier if in an control array]), you could've already resized it in design mode.


____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)

28-02-2003 at 08:07 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
yronium
Level: Moderator


Registered: 14-04-2002
Posts: 907
icon Re: HELP! (Again) This time on screen resolution... lol

I think you can manage controls' position too by the same method, since the Top and Left properties specify a relative position on the form.
I didn't try it, yet, I'm not home.

The real problem could be moving the form itself, but... maybe not... I'm not sure...

It should be tested...

____________________________
Real Programmer can count up to 1024 on his fingers

28-02-2003 at 08:42 AM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: HELP! (Again) This time on screen resolution... lol

You can, but the referencing can be tricky.

.Left/Top properties would have to be subtracted by the same percentage as the width/height, this leads to a potential funny spacing (ex: division won't end up with a even number all the time, some may have 100 result, others 101 or even 99 [rounding issues]) which can lead to problems if you're wanting columns/rows of different controls or labels for text boxes, or even a control inside a shape/picturebox.

Also have to take into account the fonts, if the current are meant to take up the entire area, a smaller area may mean the font size won't work, so you may have to change the font size.

Basically I look at it like this:
50 controls resized manually: 10 min
50 controls code changes, verifying text, changing resulution for all possible used (to make sure will work properly), tweaking division algorithm so all rounds are the same: a more than 10min (generally).

____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)

28-02-2003 at 08:59 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
yronium
Level: Moderator


Registered: 14-04-2002
Posts: 907
icon Re: HELP! (Again) This time on screen resolution... lol

Yes, of course you're right, ehehe...
Though I think it'd be useful learning to write code to do everything good, including the Int function to the divisions, and the fonts sizes, the columns etc. But maybe I'm too theoretical...

But weren't any API that did everything, comparing by screen resolution? I remember I've heard about something like it...



____________________________
Real Programmer can count up to 1024 on his fingers

28-02-2003 at 09:20 AM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: HELP! (Again) This time on screen resolution... lol

The "Screen" option ("Screen." in vb) displays different screen attributes (like current size).

Comtrols are much easier to resize when the form is created with the minimum size required for everything to work (800x600 or 1024x768 resolutions), and then resizing/moving everything in the form_resize. Basically it's the same as when a form is resized by the user.

IE:
In the form_Load you'd have a line (or two) to resize the form based on the screen resolution. In the form_resize the code that places the controls based on the current form size [changing the form size if it's not at least as big as the minimum required].



____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)

01-03-2003 at 12:11 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
starspike
Level: Guest

icon Re: HELP! (Again) This time on screen resolution... lol

I have the same kind of problem.... I'm writing a program for my internship and it's supposed to work on a network. But the different computers don't all have the same resolution. (1024*768 en 600*800)
I've read this topic and the sticky on the FAQ part... But I really don't understand anything about it...
Can anyone explain me how I can make this work. The help says something abouit the Screen Object, but it doesn"t seem to work...

Help me out...      

19-05-2003 at 01:23 PM
| Quote Reply
~Bean~
Level: VB Guru


Registered: 07-04-2003
Posts: 488
icon Re: HELP! (Again) This time on screen resolution... lol

go to microsoft.com and check this article out...reiterates a lot of what JL said and offers an example...

Microsoft Knowledge Base Article - Q182070
HOWTO: Create a Resolution-Independent Form

____________________________
Eggheads unite! You have nothing to lose but your yolks.

19-05-2003 at 04:52 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
starspike
Level: Guest

icon Re: HELP! (Again) This time on screen resolution... lol

quote:
~Bean~ wrote:
go to microsoft.com and check this article out...reiterates a lot of what JL said and offers an example...

Microsoft Knowledge Base Article - Q182070
HOWTO: Create a Resolution-Independent Form


and so i did... But it doesn't really work. Since my DataGrid just dissapears and some other things also act very strangely when I enter the code from the article.....
21-05-2003 at 11:08 AM
| Quote Reply
AndreaVB Forum : VB General : HELP! (Again) This time on screen resolution... lol
Previous Topic (Movie Thumbnail Sample)Next Topic (Making A Demo Version) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder