Alpha Video Training
Results 1 to 9 of 9

Thread: Calling a Modeless XDialog within a Modal XDialog

  1. #1
    Member
    Real Name
    Keith Weatherhead
    Join Date
    Nov 2004
    Location
    Braceville, IL
    Posts
    427

    Default Calling a Modeless XDialog within a Modal XDialog

    Greetings,

    I'm sure this can be done, I think the example with the "{Close_On_Leave}" is trying to demonstrate this although I have not gotten all the pieces clear as to how this really works.

    In the example below I have the base script, with three fields. The 2nd script is a "modeless" XDialog script. When the user is in Field 2, I want the "modeless" dialog to appear and when they are no longer in Field 2, I want it to close on its own. If the user wishes to close it while they are in Field 2, the Close button should take care of that.

    How do I go about doing this?

    Base Script
    Code:
    DIM SHARED Fld1 as C
    DIM SHARED Fld2 as C
    DIM SHARED Fld3 as C
    DIM SHARED varC_result as C
    heading_string = "Call Modeless XDialog while in Field2"
    footer_string = "Close if not in Field 2"
    ok_button_label = "&OK"
    cancel_button_label = "&Cancel"
    varC_result = ui_dlg_box("XDialog Example",<<%dlg%
    {region}
    {text=55,1:heading_string};
    {endregion};
    {region}
    Data Field 1:| [.40Fld1];
    Data Field 2:| [.40Fld2];
    Data Field 3:| [.40Fld3];
    {endregion};
    {region}
    {text=55,1:footer_string};
    {endregion};
    {line=1,0};
    {region}
    <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
    {endregion};
    %dlg%)
    Modeless Script
    Code:
    DIM StatText as C
    StatText = "This is the static text to be replaced"
    ui_modeless_dlg_box("Modeless Dlg",<<%dlg%
    {region}
    {Region}
    ;
    {Endregion};
    {Region}
    | {text=80,10:StatText};
    {Endregion}; 
    {Region}
    ;
    {Endregion};
    {line=1,0};
    <15Close>;
    {endregion};
    %dlg%,<<%code%
    if a_dlg_button = "Close"  then
        ui_modeless_dlg_close("Modeless Dlg")
    end if
    %code%)
    Regards,
    Keith
    Keith Weatherhead
    Discus Data, Ltd
    kweatherhead@gmail.com

  2. #2
    "Certified" Alphaholic
    Real Name
    Finian Lennon
    Join Date
    Apr 2000
    Location
    Atlanta, GA
    Posts
    1,804

    Default Re: Calling a Modeless XDialog within a Modal XDialog

    Here the modeless xdialog will pop up if you attempt to make an entry in fld2.

    Code:
    DIM SHARED Fld1 as C
    DIM SHARED Fld2 as C
    DIM SHARED Fld3 as C
    DIM SHARED varC_result as C
    heading_string = "Call Modeless XDialog while in Field2"
    footer_string = "Close if not in Field 2"
    ok_button_label = "&OK"
    cancel_button_label = "&Cancel"
    dlg_code=<<%dlg%
    {region}
    {text=55,1:heading_string};
    {endregion};
    {region}
    Data Field 1:| [.40Fld1];
    Data Field 2:| [.40Fld2!fld2_*];
    Data Field 3:| [.40Fld3];
    {endregion};
    {region}
    {text=55,1:footer_string};
    {endregion};
    {line=1,0};
    {region}
    <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
    {endregion};
    %dlg%
    
    event_code=<<%code%
    select
    	case left(a_dlg_button,4) = "fld2"
    	if a_dlg_button = "fld2_change" then
    	   a_dlg_button = ""
    		RunModelessXD()
    		elseif a_dlg_button = "fld2_setfocus" then
    			a_dlg_button = ""
    			   if ui_modeless_dlg_exist("Modeless Dlg")
    				ui_modeless_dlg_close("Modeless Dlg")
    			   end if
    				else
    					a_dlg_button = ""
    	end if
    end select
    %code%
    
    varC_result = ui_dlg_box("XDialog Example",dlg_code,event_code)
    
    Function RunModelessXD as V()
    DIM StatText as C
    StatText = "This is the static text to be replaced"
    dlg_code=<<%dlg%
    {region}
    {Region}
    ;
    {Endregion};
    {Region}
    | {text=80,10:StatText};
    {Endregion}; 
    {Region}
    ;
    {Endregion};
    {line=1,0};
    <15Close>;
    {endregion};
    %dlg%
    
    event_code=<<%code%
    if a_dlg_button = "Close"  then
        ui_modeless_dlg_close("Modeless Dlg")
    end if
    %code%
    
    ui_modeless_dlg_box("Modeless Dlg",dlg_code,event_code)
    End Function
    This may give you some ideas.
    Finian

  3. #3
    Member Mario Prieto's Avatar
    Real Name
    Mario Prieto
    Join Date
    Apr 2000
    Location
    Las Cruces, NM
    Posts
    364

    Default Re: Calling a Modeless XDialog within a Modal XDialog

    Here is some code. I didn't do the closing of the modeless dlg.
    I am assuming that the name of the modeless dlg script is "test2"

    Code:
    DIM SHARED Fld1 as C
    DIM SHARED Fld2 as C
    DIM SHARED Fld3 as C
    DIM SHARED varC_result as C
    heading_string = "Call Modeless XDialog while in Field2"
    footer_string = "Close if not in Field 2"
    ok_button_label = "&OK"
    cancel_button_label = "&Cancel"
    varC_result = ui_dlg_box("XDialog Example",<<%dlg%
    {region}
    {text=55,1:heading_string};
    {endregion};
    {region}
    Data Field 1:| [.40Fld1];
    Data Field 2:| [.40Fld2!field2_*];
    Data Field 3:| [.40Fld3];
    {endregion};
    {region}
    {text=55,1:footer_string};
    {endregion};
    {line=1,0};
    {region}
    <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
    {endregion};
    %dlg%,<<%code%
    select
        case a_dlg_button="field2_setfocus"
         a_dlg_button=""
          script_play_local("test2")
         
          
        case a_dlg_button="CANCEL"
          a_dlg_button="Close"  
        
        case else
          a_dlg_button=""  
          
        
          
    end select
    %code%)
    The Mexican

  4. #4
    "Certified" Alphaholic
    Real Name
    Finian Lennon
    Join Date
    Apr 2000
    Location
    Atlanta, GA
    Posts
    1,804

    Default Re: Calling a Modeless XDialog within a Modal XDialog

    Oops, the line
    elseif a_dlg_button = "fld2_setfocus" then
    should be
    elseif a_dlg_button = "fld2_killfocus" then

    to close the xdialog on leaving the fld2 field.
    Finian

  5. #5
    Member
    Real Name
    Keith Weatherhead
    Join Date
    Nov 2004
    Location
    Braceville, IL
    Posts
    427

    Default Re: Calling a Modeless XDialog within a Modal XDialog

    Quote Originally Posted by Mario Prieto
    Here is some code. I didn't do the closing of the modeless dlg.
    I am assuming that the name of the modeless dlg script is "test2"

    Mario, I appreciate the assistance. When I tried your example code, I could not get the second window (modeless) to open at any field. Not sure if there is something set wrong on my system... does it work on yours?

    Regards,
    Keith
    Keith Weatherhead
    Discus Data, Ltd
    kweatherhead@gmail.com

  6. #6
    Member
    Real Name
    Keith Weatherhead
    Join Date
    Nov 2004
    Location
    Braceville, IL
    Posts
    427

    Default Re: Calling a Modeless XDialog within a Modal XDialog

    Quote Originally Posted by Finian Lennon
    Here the modeless xdialog will pop up if you attempt to make an entry in fld2.

    This may give you some ideas.

    Thanx, Finian, its very close to what I need to start with. I made the "set" to "kill" _focus change you outlined in the other post.

    There are two issues with this code and most likely it has to do with my initial explanation....

    1st, I want the window to open as soon as the user "arrives" at the 2nd field. This window is suppose to have some specific instructions about the 2nd field so I would like it visable before anything is typed into the field.

    2nd, the modeless window keeps popping up over the main window with every character you try to type into the 2nd field, rather than opening once, it attempts to open on every keypress. Is this a big change?

    I like the indented code in the XDialog !! I've never really seen any examples of indented XDialog and it certainly makes it a bit easier to decypher what the components are that way.

    Regards,
    Keith
    Keith Weatherhead
    Discus Data, Ltd
    kweatherhead@gmail.com

  7. #7
    Member masteralone's Avatar
    Real Name
    Oran Hamilton
    Join Date
    Jun 2006
    Location
    U.S. West Coast
    Posts
    70

    Default Re: Calling a Modeless XDialog within a Modal XDialog

    Just sticking my head in here so I will get notified of further replies so I can follow this thread.
    My two cents worth :)

    Oran

  8. #8
    Member
    Real Name
    Keith Weatherhead
    Join Date
    Nov 2004
    Location
    Braceville, IL
    Posts
    427

    Default Re: Calling a Modeless XDialog within a Modal XDialog

    Quote Originally Posted by masteralone
    Just sticking my head in here so I will get notified of further replies so I can follow this thread.
    Welcome aboard !!
    I'm playing with it and *if* I get it before one of our asteemed masters, "shows us the way", I'll post it, so far I'm taking more lumps than getting it to do what I want.

    Keith
    Keith Weatherhead
    Discus Data, Ltd
    kweatherhead@gmail.com

  9. #9
    Member
    Real Name
    Keith Weatherhead
    Join Date
    Nov 2004
    Location
    Braceville, IL
    Posts
    427

    Default I finally got to a working example ! ! !

    Quote Originally Posted by KeithW
    Welcome aboard !!
    I'm playing with it and *if* I get it before one of our asteemed masters, "shows us the way", I'll post it, so far I'm taking more lumps than getting it to do what I want.

    Keith
    Thanx to those that offered ideas to me on this issue, I am still way behind the eight-ball when it comes to XDialog, but it is beginning to make some sense and I have begun to make some forward progress again...

    As I promised... here is a working version, based off of finian's changes to my original example code posted. I'm sure it can be further revised to provide the same functionality, yet done in fewer commands.

    I was just interested in getting it to function period, now the revisions can come... but the functionality that I originally was looking for is there. The "modeless" dialog opens when going into field_2 and when going into either of the other fields will close that "modeless" dialog.

    In my application I am adding a button to open the dialog regardless of which field your in now that I found the ui_dlg_ctl_goto() function as that was the "other" functionality I was looking for, but had not yet discovered in my searching.

    Hope this saves some else the intial hassle of trying to do something like this.

    Code:
    DIM SHARED Fld1 as C
    DIM SHARED Fld2 as C
    DIM SHARED Fld3 as C
    DIM SHARED varC_result as C
    DIM SHARED ModeLessExist as L
    ModeLessExist = .f.
    heading_string = "Call Modeless XDialog while in Field2"
    footer_string = "Close if not in Field 2"
    ok_button_label = "&OK"
    cancel_button_label = "&Cancel"
    dlg_code=<<%dlg%
    {region}
    {text=55,1:heading_string};
    {endregion};
    {region}
    Data Field 1:| [.40Fld1!Fld1_*];
    Data Field 2:| [.40Fld2!fld2_*];
    Data Field 3:| [.40Fld3!Fld3_*];
    {endregion};
    {region}
    {text=55,1:footer_string};
    {endregion};
    {line=1,0};
    {region}
    <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
    {endregion};
    %dlg%						'end of Format string
    event_code=<<%code%
    select
    	case left(a_dlg_button,4) = "fld2"
    		if a_dlg_button = "fld2_SetFocus"  .AND.  ModeLessExist = .f.  then
    		   a_dlg_button = ""
    			RunModelessXD()
    			if ui_modeless_dlg_exist("Modeless Dlg")
    				ModeLessExist = .t.
    			else
    				ModeLessExist = .f.
    			end if
    			
    		else
    			a_dlg_button = ""
    	end if
    
    	case left(a_dlg_button,4) = "fld1"
    		if a_dlg_button = "fld1_SetFocus" then
    			a_dlg_button = ""
    			if ui_modeless_dlg_exist("Modeless Dlg")
    				ui_modeless_dlg_close("Modeless Dlg")
    				ModeLessExist = .f.
    			else
    				ModeLessExist = .f.
    			end if
    		else
    			a_dlg_button = ""
    	end if
    
    	case left(a_dlg_button,4) = "fld3"
    		if a_dlg_button = "fld3_SetFocus" then
    			a_dlg_button = ""
    			if ui_modeless_dlg_exist("Modeless Dlg")
    				ui_modeless_dlg_close("Modeless Dlg")
    				ModeLessExist = .f.
    			else
    				ModeLessExist = .f.
    			end if
    		else
    			a_dlg_button = ""
    	end if
    
    end select
    %code%						'end of Event string
    '--------------------------------------------------------------
    varC_result = ui_dlg_box("XDialog Example",dlg_code,event_code)
    END
    '----------------------------
    Function RunModelessXD as V()                                  'function wrapping modeless dialog
    DIM StatText as C
    StatText = "This is the static text to be replaced"
    dlg_code=<<%dlg%
    {region}
    {Region}
    ;
    {Endregion};
    {Region}
    | {text=80,10:StatText};
    {Endregion}; 
    {Region}
    ;
    {Endregion};
    {line=1,0};
    <15Close>;
    {endregion};
    %dlg%						'end of Format string
    event_code=<<%code%
    if a_dlg_button = "Close"  then
        ui_modeless_dlg_close("Modeless Dlg")
    end if
    %code%						'end of Event string
    ui_modeless_dlg_box("Modeless Dlg",dlg_code,event_code)
    End Function
    Regards,
    Keith
    Last edited by KeithW; 07-16-2006 at 11:20 PM. Reason: Change title...
    Keith Weatherhead
    Discus Data, Ltd
    kweatherhead@gmail.com

Similar Threads

  1. Problem with modeless xdialog
    By Craig Hutchison in forum Alpha Five Version 7
    Replies: 3
    Last Post: 06-21-2006, 11:12 AM
  2. Calling a Report from XDialog
    By Mario Prieto in forum Alpha Five Version 7
    Replies: 1
    Last Post: 05-03-2006, 12:15 PM
  3. Modal/Modeless
    By Inge Hansen in forum Alpha Five Version 5
    Replies: 2
    Last Post: 01-15-2004, 07:03 AM
  4. Modal, modeless
    By dik_coleman in forum Alpha Five Version 5
    Replies: 8
    Last Post: 12-15-2003, 09:45 PM
  5. Modal vs Modeless...again!
    By Thomas Henkel in forum Alpha Five Version 5
    Replies: 2
    Last Post: 08-21-2002, 08:42 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •