Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Automating Form Closure

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Automating Form Closure

    We have an application that starts by opening a form that contains a number of buttons. An icon for this form appears in the task bar. When a button on this form is clicked an application starts that opens a new form. An icon for this form is added to the task bar and the original form still appears but is grayed out. . When the second form is closed both the second form and the original (grayed out) form disappear and the icon for the second form is removed from the task bar. However, the icon for the original form still appears on the task bar to represent a minimized copy of the original form. If the foregoing process is repeated we end up with two icons on the task bar each of which represents a copy of the original form. This gets to be confusing and can lead to processing diffuculties.

    Is there a way to automatically close the original form when the second form is closed?

    Thank you.

    Red Abicht

    Phone: 253-591-5358 ext 6179
    Fax: 253-591-5301
    Email: [email protected]

  • #2
    RE: Automating Form Closure

    On the OnExit event for the second form try something like this

    if is_object("FirstFormName")
    FirstFormName.close()
    end if

    Jerry

    Comment


    • #3
      RE: Automating Form Closure

      Jerry:

      This doesn't work.

      When the first form is opened the window (at the top) shows the file name (.dbf) and form name.

      When a button is clicked and a second form opens the first form contents are grayed out and the file name (.dbf) and form name disappear. This window now appears to represent Alpha Five and not the first form The file name and form name associated with the second application appear in the second window.

      The name of the first form is "MainScreenTacMuni". To test the accessibility of this form I entered the following code in the OnInit event for the second form:

      IF .not. is_object(":MainScreenTacMuni") THEN
      trace.writeln("This is test 2")
      END IF

      Is this good code to test access to the form?

      This message appears in the Trace Window after the second form opens.

      And, the icon for the first form still appears on the task bar.

      Red Abicht

      Comment


      • #4
        RE: Automating Form Closure

        Attached is a zip file with a database and two tables. Unzip this into a folder and open the database. Open form1 and then Form2. When you close form2, form1 closes. I think that is what you requested.

        Jerry

        Comment


        • #5
          RE: Automating Form Closure

          Jerry:

          Thank you for the zop file. I tried out you test application and it worked fine.

          However, your design is different from the the one I'm working with. Both of your forms are in the same database.

          My application opens a form which has a button on it. When this button is clicked a second application (different database) runs. The new application opens a second form. I am unable to "see" the first form when the second application is running.

          Is there some way to focus on an object in the first database from the second database?

          Thank you,

          Red Abicht

          Comment


          • #6
            RE: Automating Form Closure

            Maybe you can use sys_focus_put() and sys_send_keys() to shift focus to the orphaned form window and close it.

            -- tom

            Comment


            • #7
              RE: Automating Form Closure

              Tom:

              Two copies of Alpha Five are running when the second form is opened. On the task bar the first icon represents the initial program that opens "Form1"; the second icon represents the program that opened "Form2". When I use the statement sys_focus_put("Alpha Five") which copy is the focus set on?

              Thank you.

              Red Abicht

              Comment


              • #8
                RE: Automating Form Closure

                Red,

                I have no experience doing what you describe. However, it ought to be possible to change the name in the caption of the orphaned window, as the new app is being opened. Wouldn't that distinguish the two?

                -- tom

                Comment


                • #9
                  RE: Automating Form Closure

                  Tom:

                  I was running both form windows in normal mode. In this situation the Alpha Five window is visible in back of the form window and the caption of the Alpha Five window is just "Alpha Five" and this ("Alpha Five") is what appears in the Task Manager Application listing. So, I had the same entry for both my applications. When I maximized the first form the window caption was expanded to include reference to the form view (i.e., it became "Alpha Five - [Test1.dbf :Form View(Form1)]").

                  I put this information between the parentheses in a sys_focus_put() statement that I entered into the OnExit event for the second form. When I closed the second form (clicked on the 'X' in the upper right corner of the window) I got the Action Program Error "Error: not found".

                  My Version 4 Xbasic Reference Manual (page 336) for the sys_focus_put() instruction says: Sends focus to a specific program that is identified in the Windows Title. Can you help me in constructing a valid entry for the Windows Title?

                  Thank you,

                  Red Abicht

                  Comment


                  • #10
                    RE: Automating Form Closure

                    Red

                    While I am not sure why you have two instances of A5 open, you can change the A5 window title to anything you want. After starting a databse, run

                    a5.window_title = "YourTitle"

                    Then to send focus back to that instance of A5, use

                    sys_focus_put("YourTitle")

                    Jerry

                    Comment


                    • #11
                      RE: Automating Form Closure

                      Jerry:

                      The first instance of Alpha Five opens Form1 which contains a button. When this button is clicked the first instance of Alpha Five is minimized and a new instance of Alpha Five runs and opens Form2. Both instances are running and focus is on the second instance (I think).

                      I changed the name of the first instance to "Test1". In the OnInit event of Form2 (second instance) I entered
                      sys_focus_put("Test1")
                      if is_object(":Form1")
                      trace.writeln("Form1 is accessible.")
                      end if
                      if is_object(":Form2")
                      trace.writeln("Form2 is accessible.")
                      end if

                      I start the first instance of Alpha Five, click the button to run the second instance, and then check the trace window. Only "Form2 is accessible." appears.

                      What is the best way to verify that focus has been sent to the first instance (Test1) of Alpha Five?

                      How can I communicate with the first instance of Alpha Five (e.g., close it down)?

                      Thank you.

                      Red Abicht

                      Comment


                      • #12
                        RE: Automating Form Closure

                        Red,

                        I fear you're exploring uncharted territory. You're using Alpha Five in ways most of us would not. Having never attempted such a thing I was assuming that once you succeeded in shifting Windows' focus to the desired "window" you could close it by passing Alt-F4 to it using sys_send_keys(). -- tom

                        Comment


                        • #13
                          RE: Automating Form Closure

                          Tom:

                          You are absolutely correct. In the OnInit event of the second A5 instance I sent focus on the first A5 instance and then used sys_send_keys("{ALT-F4}") to close the first instance of A5.

                          Where are the keyboard entries documented? I didn't know that ALT-F4 would shut down Alpha Five.

                          The design I'm working with uses a form that contains numerous buttons each of which starts a different application. You seem to indicate that this is an unusual design approach. How would this idea normally be handled?

                          Thank you.

                          Red Abicht

                          Comment


                          • #14
                            RE: Automating Form Closure

                            Alt-F4 is not an Alpha Five command. It's a Windows keyboard shortcut. It will close the active item, or quit the active program. It's a distant cousin of the three finger salute (Ctrl-Alt-Del) -- tom

                            Comment


                            • #15
                              RE: Automating Form Closure

                              Tom:

                              Once focus is sent to a different program is any control other than sys_send_keys() available to handle the application that is in focus?

                              Thank you.

                              Red Abicht

                              Comment

                              Working...
                              X