Odd modal form behaviour

Posted on 2005-05-02
Last Modified: 2008-02-01
Hi Experts

A curious question that I wonder if somebody has encountered before.

I have a normal app (D7).

Create a new Project with two forms Form1 and Form2

Make Form1 your startup form

On Form1 place a button.

Under the button put this code


Run the project and click the button, Form2 show modally.

Everything looks fine.

Now I have a cheap mouse with a neat menu system.  I click a button on the side and a menu pops up.

Funny thing happens, in my Delphi project, my modal form ducks behind the main form and the main form is inactive.

I have probably a hundred apps on my PC and don't have this problem with any other apps.

The solution is easy - get a new mouse?

But here's the problem, what if my clients have the same problem with another mouse?

Anybody got any idea what's happening?

The app exhibits the same behaviour on NT and Win2000

Question by:Voodooman
    LVL 27

    Expert Comment

    you have already posted the same question below.

    i can't reproduce your problem, maybe its a feature, not a bug.
    sorry, can't help

    meikl ;-)
    LVL 10

    Expert Comment

    Hi, try setting Form2's property FormStyle:=fsStayOnTop;

    maybe it should help, regards,
    LVL 5

    Author Comment


    Hi Meikl

    Yes I did post the problem before but it did not appear in the list for some reason and so I had no responses.

    I posted to support about the 'no show' so maybe they fixed the reason it was not showing.

    This is the reason I posted again as I figured their was some problem with my first question.

    Maybe it's a problem with the mouse driver, but I do not have this problem with any other software only my own software developed with D7.

    Its a Borland bug of some kind (I think so anyway).

    As you can see I can reproduce the probelm on 2 x machines by simply creating a new project with just two forms and standard controls.

    Strange but true

    LVL 27

    Expert Comment

    >Its a Borland bug of some kind (I think so anyway).
    well, could be, d3 had a bug with the mousewheel (with a specific driver (logitech i guess)),
    so maybe this a borland bug too

    will try a second setup on a different machine

    meikl ;-)
    LVL 5

    Author Comment


    Thanks Meikl

    I have had problems in the past similar to this (only with Delphi D7).

    Before I had problems with other application forms getting in between my main form and modal forms.

    In my app I made the main form the splash.

    Then I hid the splash (main form) and showed my 'main working screen'.

    This caused all kinds of problems

    It would happen like this.

    User cliks 'add rec' or something and I

    1) Hide the main screen (remember this is not the main Delphi form)
    2) show the 'addrec form' modally
    4) show a form modally over the 'addrec form', 'SelectClientForm'

    In this scenario if I went to check my E-Mail and after clicked on the toolbar Icon to swap to my app I would retrieve the last modal form 'SelectClientForm' but the 'addrecform' would not be visible behind it as expected, only the Outlook Screen would be visible.

    The project was dropped so I didn't experiment anyfurther.

    However I have just looked at another project completed some months ago and that exhibits the same behaviour that I am experiencing now!!!!!!!!

    I press button 5 to access my mouse menu 'off my modal form' and my modal form drops behind my main delphi form.  

    If I select any item off the mouse menu the form reappears, if I click away from the mousemenu to cancel it the form remains hidden behind my main form.


    LVL 27

    Expert Comment

    sorry, got no time yesterday, will try this evening
    LVL 5

    Author Comment



    LVL 5

    Author Comment


    I found out the answer to this problem myself.

    It concerns how you create the form.

    If you use this the problem does not occur:

    Var F_Login:TF_Login;



    However if you use this the problem does occurr:



    With this latter consturcyion, other forms from other brograms can 'get in between' the showing form and the modal form - strnage but true.

    Apologies for not closing this myself and taking your time.

    LVL 1

    Accepted Solution

    PAQed with points refunded (100)

    EE Admin

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
    Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now