Open form not showing unless minimize first?

Discussion in 'Questions (Windows Mobile)' started by tsteward, Feb 22, 2009.

  1. tsteward

    tsteward Active Member Licensed User

    When I run my latest program all is well.
    But then...
    I click on a link to load the module for drawing.
    I see the waitCursor, then it stops and I'm still looking at the main form.
    I then minimise the program, then using the task manager bring it back.
    I now see the form from the drawing module.

    after using the drawing module it closes leaving nothing on the screen, but in task manager the program is still running so clicking on it brings up the program back at the original main form.

    Code Snippet
    Main program main form
    mdlDraw.Show("New", wikiDir & DrawingTitleTB.Text & DrawingNumber+1)
    Drawing Module
    Public Sub Show(status, file)

    do some stuff to setup

    End Sub
    Happy to paste code but this is a very large project.
    Any idea what may be wrong, please? :sign0085:
  2. agraham

    agraham Expert Licensed User

    The bare-bones of what you posted work OK so the problem isn't visible in those code fragments. Can you pare down a copy of your program to just, say, the main module with just a button on a main form that calls mdldraw.drawShow and a single module, mdldraw with just the Public Sub Show and see if the problem still persists. If so then post it!
  3. klaus

    klaus Expert Licensed User

    Hi tsteward,

    Couldn't you reply the problem in the DrawBasics program, it is not that big ?

    Best regards.
  4. Scubaticus

    Scubaticus Active Member Licensed User

    I have to same problem.

    I run my app showing form1. On that form I press a button showing me form2 and on that form I press a button showing me form3.

    When on form 3 (or 2, it doesn't matter) and press my End Key, causing the App to be send to the background and reactivating the app through a taskmanager, form 3 is showed again as expected. When I fire a form3.close, form2 is not showed. I have to go to the taksmanager and activate the app, showing me form 2. After closing form 2, the screen shows me the phone menu and I have to activate the app through the taskmanager to get form 1.

    I did not test what will happen if I would do a again and even if this is working, it would mean I have to keep track of which screen should be activated through a reshow which would mean writing a lot of extra code just to catch the unexpected behaviour and keep track of which form to reactivate.

    It doen't matter if I close the screen by a form.close or the OK button of the form.

    Is this a bug or is there something to prevent this unexpected behaviour?
  5. agraham

    agraham Expert Licensed User

    I think I half understand what you mean now, I didn't get it at first :( Though I don't understand your sequence. How do you "load a module" without the form showing? Why is the the drawing form not being shown after the Wait cursor stops?
    What do you mean by "minimise"? I am afraid that I need more clarification as to what is actually happening to comment further.

    What does your End key actually do to "send your app to the background". If it is to display the Today screen then I may be able to explain that as I get a similar effect if I display the Today screen using the Today option on the Start Menu.

    All open forms, and the Today screen is one, seem to be stacked in a Z-order depending upon their last viewed order. If I display a Main form that then display a second form then use my Task Manager (Handyswitcher) to display another app then use it again to redisplay the second form the forms are stacked Main Form - app - Second Form, and can be seen to be so stacked in the switcher dropdown list. So if I close the second form I see the other app, not the Main form.

    It also appears that the Today screen is included in this stack. It does not appear in the switcher dropdown list but appears to behave just like other forms. So if you display the Today screen then bring back one of your forms the other forms are stacked below the Today screen and closing the form you just brought to the top will show the Today screen again.
    Last edited: Feb 22, 2009
  6. Scubaticus

    Scubaticus Active Member Licensed User

    Thanks agraham for your quick reply.

    My 'end key' is my call hang-up key and shows indeed the Today Screen.
    In my task bar (taskswitcher) I only see one instance of my App.

    So if I have a couple of screens open, after closing each of them, I need the taskswitcher to activate the app again and again and again....

    The question is now if this is a B4PPC issue or not and of course if there's a way to prevent this nasty behavior?
  7. agraham

    agraham Expert Licensed User

    No, if you are seeing the behaviour I described that i's the way Windows Mobile works and applies to all apps. Some native code guru might know a way to push the Today screen to the bottom of the stack (like the .NET Form.SendToBack method) but I'm afraid that I don't.
  8. Scubaticus

    Scubaticus Active Member Licensed User

    Thanks for your answer. I installed Handyswitcher and now see the screens which are in the stack.

    I'll try to keep track of the screens and after a close do a reshow of the one expected. Hopefully this will work.

    Edit: A reshow of the calling screen does work and I don't have to use the taskswitcher after closing an open one.


    * Screen1.Show
    ** Screen2.Show
    ***Screen3.Show (Press the today Screen)

    From Taskbar:

    Old situation:
    * restore Screen3
    * Screen3.Close (Expecting Screen2 to become active but ...)
    * Today Screen is showed

    New situation:
    * restore Screen3
    * Screen3.Close
    * Screen2.Show (Screen2 becomes active again)
    * Screen2.Close
    * Screen1.Show (Screen1 becomes active again)
    *Today screen is not showed
    Last edited: Feb 22, 2009
  9. tsteward

    tsteward Active Member Licensed User

  10. Scubaticus

    Scubaticus Active Member Licensed User

    What I did was:

    Public Sub screenAdd (fromScreen)
    End Sub

    Public Sub screenRestore
       lastEntry = screenStack.Count-
    If lastEntry >= 0 Then
          showScreen  = screenStack.Item(lastEntry)

          lastEntry = lastEntry -
    Control(showScreen, form).Show
    End If
    End Sub
    The above subs are in module toos and uses the an Arraylist called screenStack.

    Now just before a I do a call to ScreenAdd with the name of the screen it's coming form (i.e. tools.screenAdd("Catch.frmCatches")

    And just short before a form.close I do a tools.screenRestore:

    This way for the calling screen an extra .show will be executed, showing me the screen (which wasn't showing without the extra .show).

    The only caveat is that when you jump into a screen from within the taskbar which is not the last screen open, you will reshow the wrong screens. I did not test throughfully this code, but within my app (using a lot of shared screens) it works fine after a Todayscreen was requested.

    If you don't share screens and a specific form.close brings you to an already known open form, you could just do a again for that form.
  11. tsteward

    tsteward Active Member Licensed User

    Thanks but that did NOT sove the problem for me unfortunately.:sign0161:
  12. tsteward

    tsteward Active Member Licensed User

    All fixed! :sign0060:
    I had not finnished processing the sub so form was not being shown.

    My dumb ass.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice