473,734 Members | 2,806 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why Can't I Preset Location of Modal Form?

In my WinForms application, I have a main form, which may or may not be
visible depending on the user's wishes. This main form initiates a separate
thread that starts a data transfer process.

In this thread I want to show a special dialog box. Because the question
must be answered, I'm using ShowDialog to display it. Just before doing so,
I have some simple code to:
- Center it in the main form, if that form is visible
- Center it in the screen otherwise

Yet to my amazement, this centering code (ie. Left & Top) has absolutely no
effect. Why not?

I even hardcoded in a new location but it had no effect either. Here's the
code in question:

frmInstallPromp t frmInstall = new frmInstallPromp t();
frmInstall.Disp layMobileDevice Info();
//frmInstall.Cent erForm(parentFo rm, parentForm.Wind owState);
frmInstall.Loca tion = new System.Drawing. Point(1000, 1000);
DialogResult retval = frmInstall.Show Dialog();

--
Robert W.
Vancouver, BC
www.mwtech.com

Nov 17 '05 #1
2 6159
Have you tried:

frmInstall.Star tPosition = FormStartPositi on.CenterParent ;
frmInstall.Show Dialog();

Regards - Octavio

"Robert W." <Ro*****@discus sions.microsoft .com> escribió en el mensaje
news:71******** *************** ***********@mic rosoft.com...
In my WinForms application, I have a main form, which may or may not be
visible depending on the user's wishes. This main form initiates a
separate
thread that starts a data transfer process.

In this thread I want to show a special dialog box. Because the question
must be answered, I'm using ShowDialog to display it. Just before doing
so,
I have some simple code to:
- Center it in the main form, if that form is visible
- Center it in the screen otherwise

Yet to my amazement, this centering code (ie. Left & Top) has absolutely
no
effect. Why not?

I even hardcoded in a new location but it had no effect either. Here's
the
code in question:

frmInstallPromp t frmInstall = new frmInstallPromp t();
frmInstall.Disp layMobileDevice Info();
//frmInstall.Cent erForm(parentFo rm, parentForm.Wind owState);
frmInstall.Loca tion = new System.Drawing. Point(1000, 1000);
DialogResult retval = frmInstall.Show Dialog();

--
Robert W.
Vancouver, BC
www.mwtech.com

Nov 17 '05 #2
Octavio,

Can I say Muchas Gracias?!

Coming from the VB6 world, I wasn't aware of the "FormStartPosit ion" property.

In point of fact, the "CenterPare nt" enum doesn't work because the parent
form is a notification window, not the main form I was referring to. But I
discovered another enum called "Manual". When set to this, it then does take
its location information from the Left & Top properties.

Thank you so much for clueing me in!

--
Robert W.
Vancouver, BC
www.mwtech.com

"Octavio Hernandez" wrote:
Have you tried:

frmInstall.Star tPosition = FormStartPositi on.CenterParent ;
frmInstall.Show Dialog();

Regards - Octavio

"Robert W." <Ro*****@discus sions.microsoft .com> escribió en el mensaje
news:71******** *************** ***********@mic rosoft.com...
In my WinForms application, I have a main form, which may or may not be
visible depending on the user's wishes. This main form initiates a
separate
thread that starts a data transfer process.

In this thread I want to show a special dialog box. Because the question
must be answered, I'm using ShowDialog to display it. Just before doing
so,
I have some simple code to:
- Center it in the main form, if that form is visible
- Center it in the screen otherwise

Yet to my amazement, this centering code (ie. Left & Top) has absolutely
no
effect. Why not?

I even hardcoded in a new location but it had no effect either. Here's
the
code in question:

frmInstallPromp t frmInstall = new frmInstallPromp t();
frmInstall.Disp layMobileDevice Info();
//frmInstall.Cent erForm(parentFo rm, parentForm.Wind owState);
frmInstall.Loca tion = new System.Drawing. Point(1000, 1000);
DialogResult retval = frmInstall.Show Dialog();

--
Robert W.
Vancouver, BC
www.mwtech.com


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
8908
by: Kyralessa | last post by:
In Access 2000, I have a base form with a ListBox of conference registrants. In the form's declarations section I include Dim f as Form To add a registrant I'm doing this: Set f = New Form_frmSingleRegistrant f.Caption = "New Registrant" f.cmdSave.Caption = "&Save New Registrant"
5
3320
by: will eichert | last post by:
Greetings. I have a problem with a combo box incorrectly displaying blank items when returning to a form from a modal form. It's fine when the main form first comes up, but gets messed up when the main form is reactivated following opening and closing a modal form. Strangely, this was not a problem until I started using my Access 2000 db in Access 2003 (as an Access 2000 db). Details follow... I have an unbound combo box on my main form...
2
5056
by: D Cameron | last post by:
I'd like to be able to make a full screen form in one of my apps inescapable: disable the Start button, Alt-Tab etc. until my application closes the form. I seem to remember VB3.0 distinguishing between system modal and application modal forms. A System Modal form seems like it would fill my need. Are system modal forms still possible? the Form.ShowDialog() method seems to offer more of an application modal behavior. I believe I...
4
3112
by: Brian Henry | last post by:
Hi, is there a way to get a form to post back to a modal dialog box when it was posted from a modal dialog to start with? here is the problem... I have a form with combo boxes and when you select one then click on an add button it adds the item to a list box, but when you click on add (this is in a modal dialog box) it opens the postback in a new window outside of the modal dialog box, how do you force it to postback to the modal dialog?...
3
1421
by: Sarika | last post by:
I have some questions regarding Modal forms and would appreciate if someone could clarify my understanding. (a) I observed that the modal form's Form_Closing event is generated if I set the modal form's Visible property to False or call its Hide method. Is this true? or is it a result of something that I am doing incorrectly? (b) The ShowDialog method halts all other execution in a single threaded program till the modal form is closed,...
23
2737
by: Chukkalove | last post by:
Im sorry, I dont know the correct description for a hierarchy of parent and child forms. I have a main form that opens a child form modally. This child form in turn opens it's own child form modally. I also have a separate thread running that monitors a card reader. If the user removes the card then the thread calls back the main form to tell it that the card was pulled. The main form should then close down any children leaving the main...
2
2645
by: Mike | last post by:
Hi, I'm having a problem with modal forms on windows. I've written a very short test program, with a main window and a form called from the main window. The form is set to modal with form.setModal(1) before calling form.show(). All works as expected on Linux. The form is modal, not allowing the main window to received the focus. If I call the form from within itself, the topmost form is modal, and not of the previous forms will...
1
1662
by: samentu | last post by:
Hi there. I'm having a little problem here with some forms. Let me describe the problem: my application has a MDI parent form (the form that starts with the application); then when I click a button a modal form appears; this modal form has a button in it that when clicked should close itself, create a new child form for the parent and create another modal form. The thing is that when I click the button on the modal form it does close itself but...
4
2902
by: Johnny Jörgensen | last post by:
In my current project I've got some DataGridViews containing multiple hidden columns. For some reason 8 of the 10 grids I've got on my form has suddenly started showing 1 of the hidden columns (not all of them). If I look at the grids in the designer, the columns ARE invisible, but still they're shown at runtime. I cannot figure out why. I've searched the entire project to see if I could find any code setting the columns visible, but...
0
8946
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8776
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9236
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.