mfc >> centering windows in multi-screen

by Ram Baruch » Wed, 03 Dec 2003 00:00:35 GMT

Hi,
I discovered a bug (I think) when two monitors are connected to the same VGA
card under windowsXP:
In this case, whenever a dialog appears, it is ALWAYS centered, no matter
what attributes it has.
It happen not only in my MFC application but also in all other applications
(like Word or VS.NET).
When the same VGA card is used but only one screen is connected- everything
is OK!!!
Do you know of this problem?
Do you know a workaround?
Need help,
Ram.




mfc >> RE: centering windows in multi-screen

by timhuang » Wed, 03 Dec 2003 13:49:38 GMT


Hi Ram,

Thanks for your post. I borrowed a graphic card ATI Radeon 9500 which
supports dual monitor and checked it on my Windows XP Pro system, however,
I am not able to reproduce the problem on my side. That is, a dialog will
display as it is instead of ALWAYS centered in each monitor. I think more
information is needed before moving forward:

1. What's the version of your Windows XP, Pro or Home edition? Did you
install the Windows XP Service Pack1?

2. What's model of your graphic card? Please install the latest driver for
the graphic card. Based on my experience, I suspect the problem may relate
to the graphic driver and recommend you contact the vendor of the graphic
card to see if there is any known issue on their side.

3. Does the problem occur to other windows, say, you can open IE and see
whether or not it is always centered under dual monitors environment?

I look forward to your response.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.




Similar Threads

1. Execute shell or open a dialog in a pecific screen in multi-screen enviroment

Hi,

How can I open a new dialog (modal or modeless), execute a shell command or 
do any other visual MFC operation on a specific screen in a multi screens 
enviroment? Or, how can I get access to the information of how many screens 
are connected and their ID#?

Thanks in advance,
Stilgar. 


2. Centering Screen Text - Borland C++ Builder VCL Components

3. Multi-Threaded Splash Screen not displaying first update.

Stuart,

I have tried your code and figured out exactly what's going wrong. It's
a very subtle threading issue.

You see, in your form startup code, you make a call to
statusInformationScreen.Show();

This method starts a thread which executes the following code:

private static void ShowThread()
{
theStatusInformationForm = new statusInformationForm();
Application.Run(theStatusInformationForm);
}

Until this thread runs to completion, the variable
theStatusInformationForm contains its original value, null.

Now, while this thread is executing in the background, your main
application constructor continues to run. It hits the following lines
of code:

statusInformationScreen.Status = "Startup Point 1";
System.Threading.Thread.Sleep(2000);

When you try to set the status to "Startup Point 1", this is the code
that gets executed:

set
{
if (theStatusInformationForm == null) // Evals to true first time!
{
return;  // This gets executed the first time!!!!!!
}
theStatusInformationForm.StatusInfo = value;
theStatusInformationForm.Refresh();
}

Now, if you remember what I said earlier, theStatusInformationForm is
null until the thread finishes setting it. This sometimes happens only
after the 2 second wait that is done after setting status to "Startup
Point 1".

In summary:

theStatusInformationForm is null because your thread hasn't been
running long enough to instantiate the form. That's why the first
message is never shown -- because it's never been set.

As a hack, I would suggest that you simply add a wait after your call
to statusInformationScreen.Show(). This is, however, just a quick-fix.
You should perhaps consider re-writing the code to avoid this sort of
timing issue. Working with threads is always tricky (that's putting it
mildly). You *must* ensure that any dependencies between threads are
always synchronized, or you will get shot in the foot.
If you're still having trouble, let me know.

Hope that helps.

4. Centering child objects when windows resizes

5. Centering content in splitter window.

Hi,

I have a couple of questions if any one can help me out.

First I'm (trying) to write my first split window application. I have 
two rows  one that contains a view that will never be changed and 
another that I want to use to display FormViews in.

What I would like to do is to be able to center the dialog template in 
the window, so regardless of the formview being displayed it's contents 
are centered in the window.

Secondly is the issue of changing the FormView from View A to View B, I 
assume it can be done, but I don't really know where to start.

Can anyone point me in the right direction with these?

-- 
Thanks,

William.
Remove _ to reply.

6. Build Error with Visual C++ Using Windows XP Media Center Edition

7. Windows Media Center and retrieving non-default saved video files directory question

Is there a way to programmatically determine if MCE isn't saving the
recorded tv video files in the default directory?

It'd be nice to know if the saved files aren't in the

C:\Documents and Settings\All Users\Documents\Recorded TV\

directory.


MsJ

8. Windows Security Center AntiVirus Status - CSharp/C#