I am having a problem in Delphi with the use of multiple monitors.

My application consists of a main form, with several different kinds of child forms. If I started running my application (not from Delphi – the executable), and I then enable a second monitor, and then move from one type of child form to another, my application would immediately crash. The same thing happens if I have started my application with two monitors enabled, and then disable the secondary monitor.

I don’t get this behavior if I enable or disable the secondary monitor before starting my application – it only happens when I make the change while the application is running.

I found that if I set the DefaultMonitor property on all of my child forms to dmDesktop, this problem went away. I could then close one type of child form, open another, no problem.

BUT – even though the child forms now work, if I try to open a standard Delphi dialog box, like TColorDialog or TFontDialog, I get an “access violation at address…” error. This same thing happens if I call the routine ShowMessage. If I try to open one or two more such dialogs, eventually the program completely crashes.

Oddly enough, this same thing happens to Delphi itself if I disable or enable a secondary monitor – it immediately crashes (I get the charming dialog “Delphi-32 Development Environment has encountered a problem and needs to close. We are sorry for the inconvenience,” etc.)

Admittedly, I am running an older version of Delphi (version 5.0, build 5.62) and Windows XP, version 5.1. This same thing happens when I run the executable on a newer laptop that is running Windows Vista.

Has anyone else ever run into this problem?

I recently downloaded a 30-day demo version of Delphi XE. I tested it on the scenario described, and it seems to have fixed the problem. I guess maybe 11-12 years ago, not as many people were working with dual monitors? :)

Hi Amarkevans,
I know it is a long time ago, but did you find a solution to the dialogs failing with the access violation message?

I am still using Delphi 5 (I know, I know) and had the problem you describe when using dual monitors when the PC woke from sleep (some minutes after sleep). Invoking any child form caused an access violation error as you describe and this was fixed by setting DefaultMonitor to dmDeskTop. Thank you for that advice. I tried yesterday in Delphi 7 and the problem was still there. The problem occurred regardless of which monitor the program was being displayed on at the time the PC went to sleep.
While my child forms no longer cause problems all the dialogs still do i.e. Print Setup, Font, Open, Save.

Hi, jip, still using Delphi 5. I get the problem as described. Has anyone gotten any other tricks or tips to make this work better while still on Delphi5?

commented: Sorry Tobie. I wasn't able to prevent the problems when using system dialogs e.g. Print Setup, Font, Open, Save +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.