Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

modeless forms and popup windows

Posted on 2002-06-17
7
Medium Priority
?
942 Views
Last Modified: 2010-04-04
i have a modeless form that is created from my main form. i've noticed something that i don't unserstand and i thought you guys might be able to help me out. after i create my modeless form from my mainform and then generate a messagedlg popup or some other popup window from my modeless form, my modeless form is sent to back behind any other windows open on my desktop..usually mainform. if i minimize all windows except my modeless form and generate a popup window, everything looks fine. is there a z-order issue here with my app's forms? i need for the modeless form to be just behind the popup windows and not be "sent to back" behind all other windows. basically i want the same "look and feel" that i would expect from a modal form except that i have modeless. thanks to all who respond.
0
Comment
Question by:msessions
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7083894
what means modeless?
0
 

Author Comment

by:msessions
ID: 7083905
sorry. poor choice of words. when i say modeless i mean non-modal.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7083914
can you show, how you create the "modeless" form
and how you call your popup-window?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:msessions
ID: 7083944
from my mainform i create my non-modal form with this code. "Id" is just the form Id that i assign to tag to keep track of what forms are open and what forms need to be created:

procedure TfrmMain.ShowOrCreateForm(Id: integer);
var
frmindex: Integer;
Found: Boolean;
aForm: TfrmTicket;
begin
{Initialize the Variables}
 Found := False;
 aForm := nil;

{Loop over all forms of the application }
 for frmindex := 0 to Pred(screen.FormCount) do
   begin
     { Check if the form already exists by looking at its tag which was assigned an ID on creation}
     if Screen.Forms[frmindex] is TfrmTicket then
       if Screen.Forms[frmindex].Tag = Id then
         begin
           { If so, assign it }
           aForm := TfrmTicket(Screen.Forms[frmindex]);
           Found := True;
         end;
   end;

 {If a form of our formclass was not found, create it}
 if (Not Found) then
   begin
     try
        aForm := TfrmTicket.Create(self);
     except
       MessageDlg('Cannot create form for this user action. Please contact TTS support.', mtError,[mbOK],0);
       exit;
     end;
   end;
{If a form of our formclass was found, show it}
 if (Assigned(aForm)) then
   with aForm do
     begin
       //assign Ticket ID to form tag
       Tag := dmTTS.TicketID;
       Show;
       if WindowState = wsMinimized then
         WindowState := wsNormal;
       BringToFront;
     end;
end;

form save from my non-modal form. the messagedlg 'Save changes?' causes the "problem" that i'm seeing:

function TfrmTicket.DoFormClose:boolean;
begin
  result := false;
  if (spTicket.state in [dsInsert,dsEdit]) then
     if MessageDlg('Save Changes?',mtConfirmation,[mbYes,mbNo],0) = mrYes then
        begin
          if DoSave then
             begin
               OK2Close := True;
               result := true;
             end
          else
             begin
             end;
        end
     else
        begin
          spTicket.CancelUpdates;
          if RecInserted and (dmTTS.TicketID > 0) then
             begin
               dmTTS.spDeleteTicket.Parameters.ParamByName('@ID').Value := dmTTS.TicketID;
               dmTTS.spDeleteTicket.ExecProc;
             end;
          OK2Close := True;
          result := true;
          exit;
        end
  else
    begin
      OK2Close := True;
      result := true;
    end;
end;
0
 

Author Comment

by:msessions
ID: 7083959
i think that if you build a simple sample delphi app and create a non-modal form from your mainform and then pop down a button on your non-modal form that calls a messagedlg then you'll see what i'm talking about. make sure you don't minimize mainform. open up a couple of other apps like Word, outlook, etc. before you do this. this should give you some idea what i'm seeing. thanks.
0
 
LVL 34

Accepted Solution

by:
Slick812 earned 800 total points
ID: 7084501
you might try a standard win system Message box


if MessageBox(frmTicket.Handle,'Save Changes?', 'Save Changes', MB_YESNO or MB_ICONQUESTION) = IDYES then




the frmTicket.Handle indicates where the focus will be returned to after the message box closes
0
 

Author Comment

by:msessions
ID: 7084842
that seemed to work. what about other controls that take focus away from this non-modal form. is their a more general solution? for example, i have a grid that has a lookup column that when the user click to drop down the list item it display another grid(devexpress quantum grid). when the lookup column list item grid is displayed i'm seeing the same thing with the message dialog pop-up windows. thanks.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

705 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