473,396 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Make forms show up in middle of screen

489 256MB
Why is it that on laptops with wide screens that my application screens show up on the right side of the screen and the user has to drag the screen into the middle. Is there a way to make the screen always show up in the middle of the screen?
Thanks for any help.
Feb 10 '09 #1
19 18537
ChipR
1,287 Expert 1GB
I've noticed this too when working on my frontend on 2 monitors. Even though my forms are all set to centered, when I compile and distribute it, users have forms open up way off center, maybe relative to where I have them while developing. I think it has helped to make sure I open Acess in a regular size window, then open the forms and make sure they are centered there before I make the accdr (or mde). It seems really inconsistent though, and I haven't collected too much evidence.
Feb 10 '09 #2
ADezii
8,834 Expert 8TB
@CD Tom
You can always make sure that Forms always show up in the 'Middle' of the Screen regardless of Screen Resolution or other factors, but the code is complex and involves judicious use of the API. If you are interested, I'll create a Demo DB that will illustrate this functionality for you.
Feb 10 '09 #3
CD Tom
489 256MB
That would be great, If you can just give me the code I can probable figure it out, unless it's easier doing the demo DB. Thanks
Feb 10 '09 #4
ADezii
8,834 Expert 8TB
@CD Tom
  1. Download the Attachment, it will make things a little easier.
  2. Within your Database, Import the FormInfo Class from the Demo Database. Almost the entire code functionality is encapsulated within this Class.
  3. In the General Declarations of your Form, declare a variable to represent the FormInfo Class, as in:
    Expand|Select|Wrap|Line Numbers
    1. Private mfi As FormInfo
  4. In the Form's Load() Event, create a New Instance of the Class, set its Form Property to the Form where code is currently executing (Me), then Call the Center Method of the Class to Center the Form.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Form_Load()
    2.   Set mfi = New FormInfo
    3.   Set mfi.Form = Me
    4.     mfi.Center
    5. End Sub
  5. Reposition the Form, and Click on the Command Button at any time to Re-Center it on the Screen.
  6. Disregard any related Properties, Methods, and Declarations from the FormInfo Class if they are not needed.
Feb 11 '09 #5
CD Tom
489 256MB
Thanks I'll let you know when I get everything working.
Feb 11 '09 #6
CD Tom
489 256MB
I've just got around to trying this and have a couple of errors. When I try and compile the program I get a error on Private mfi as formInfo the message is "Compile Error: A module is not a valid type" not to sure what to do next.
Feb 16 '09 #7
CD Tom
489 256MB
I was able to fix the first error but now I'm getting an on the the following line: .STATE = Val(Getsetting(appName, strName, adhcState, me.WindowState)) when I try and compile get an error on WindowState Compiler error: Method or data member not found" Got any ideas what's causing this.
Thanks, the program will run and the form does allign but the error comes up when I compile.
I ran the compile on your database and get the same error. Are we missing a ref or something?
Feb 17 '09 #8
ADezii
8,834 Expert 8TB
@CD Tom
I'll look into it as soon as I get a chance.
Feb 17 '09 #9
ADezii
8,834 Expert 8TB
@ADezii
WindowState is a Property of the FormInfo Class as evidenced by a pair of Property Let/Get Procedures contained within this Class. It appears as though a Variable has not been Declared as FormInfo, or that it has not properly been instantiated. Double-Check Steps 3 and 4 in Post #5, and make sure these Lines of Code are present exactly where they should be. Get back to me on this.
Feb 17 '09 #10
CD Tom
489 256MB
I've doubled checked everything and when I compile I still get the "Compile error Method or Data member not found. When I compile your database I get the same error.
Feb 17 '09 #11
ADezii
8,834 Expert 8TB
@CD Tom
I'll call in some of my colleagues in on this one. If the problem can't be resolved, can you E-Mail me a Copy of your Database so that I may have a look at it?
Feb 17 '09 #12
Stewart Ross
2,545 Expert Mod 2GB
Hi ADezii. Using A2003 I receive two error messages when I compile the code in the sample DB in post # 5. The compile errors both relate to the use of WindowState in class FormInfo.

The first error message relates to sub RetrieveCoords - method or data member not found.

.State = Val(GetSetting(AppName, _
strName, adhcState, Me.WindowState))

I wonder if the use of Me is incorrect here as WindowState is not a property of an Access form. There is a WindowState property of the form class available in .Net, however - as this MSDN link shows.

The second is in SaveCoords - expected variable or procedure, not enumerated type.

Call SaveSetting( _
AppName, strName, adhcState, WindowState)

Confusingly, there is a WindowState defined as an enumerated type in the class module (hence the error). Given the potential confusion over the .Net form class WindowState property I wonder if this was deliberate overloading on the part of the class designer?

-Stewart
Feb 17 '09 #13
FishVal
2,653 Expert 2GB
@ADezii
Hello, ADezii.

Unfortunately module of FormInfo class doesn't contain "Get" part of WindowState property. Seems like the file you've attached is not the final working version. ;)

Regards,
Fish.
Feb 17 '09 #14
FishVal
2,653 Expert 2GB
@CD Tom

Actually, both SaveCoords() and RetrieveCoords() methods could be thrown away if you don't intend to store form coordinates in windows registry.
Feb 17 '09 #15
CD Tom
489 256MB
That does take care of the Compile error and I don't intend to store form coordinates in the registry.
Thanks everybody for your help.
Feb 17 '09 #16
ADezii
8,834 Expert 8TB
@ FishVal and Stewart, thanks guys for all your help, it is always appreciated. I've run this code on three different Access Versions, on three different PCs, and have had no problem. I'm more confused than ever. BTW, the base code was taken from the Access 2002 Desktop Developers Handbook, not exactly a 'shabby' source.

Back again and discovered my mistake. The DB that I Attached was only a subset of the actual Database which contained much more functionality in addition to the Center Form code. Obviously, in trying to make things more simple and compact, I've actually complicated everything and left a few things out in the process. Sorry for the run-around guys!
Feb 18 '09 #17
CD Tom
489 256MB
ADezii,
Can you send me the complete database I would like to see exactly what was causing the Compile error. I've removed the two sections and it seems to be working fine. Thanks for your help and also FishVal and Stewart.
Feb 18 '09 #18
ADezii
8,834 Expert 8TB
@CD Tom
I will be more than happy to, but its size is beyond the limitation allowed for an Attachment. Simply send me your E-Mail Address in a Private Message (PM), and I'll send it to you that way. BTW, it is full of very interesting and functional code.
Feb 18 '09 #19
CD Tom
489 256MB
I've never sent a private message, have been looking around and don't see how it's done, sometime I really feel stupid.
Feb 18 '09 #20

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: BuzzLight | last post by:
This is my problem :- - I have set a form frmSplash as the startup form instead of sub Main. - This means I dont create an instance of it myself at startup.. its automatically created. - I have...
1
by: BuzzLight | last post by:
Thanks alot Charles m8, your suggestion was very useful, Iam very new to vb.net ... I used application.run and it works fine but I do not know what "Application.Run" means.. what it does.. But...
0
by: Ronald S. Cook | last post by:
Can't make forms authentication for non-ASPX files work In my web app, I want to secure not only .aspx files, but also .htm files. From what I've read, I have to jump through some hoops to...
1
by: DBC User | last post by:
I am wondering is there any way when I do a show and hide of a form, we can do a smooth transition to the new screen like power point presentation in c#?? Thanks.
1
by: den | last post by:
if I want to open a popup at middle of screen in some example I see that is used also Math.round; is obligatory? there are situation where the result of screen/2 if isnąt an integer can to cause...
3
by: jlb | last post by:
I am converting a VB6 app to .NET Visual Studio 2005. I have about 20 forms. Ths app starts with Main_form, and then passes to a "loop" of about 14 forms that pass from 1 to another, with the...
0
Shashi Sadasivan
by: Shashi Sadasivan | last post by:
Hi All, i Have an application functionaluty which has 4 forms which are needed to interact by the user by dragging data from these forms to one another the main form is located in the MDI Parent...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.