Results 1 to 4 of 4

Thread: form looses all focus

  1. #1
    Guest
    All program is SDI. I leave the main form visible all the time, and make other form SHOW over the top.
    (keypreview= false).
    The problem occurs when I HIDE the 2nd form.
    I have tried various things such as:
    UNLOAD 2nd form
    Enable main form, Hide 2nd form
    SHOW main form, then HIDE 2nd form
    etc, but my fix as above seems to be the only thing which works.
    (Breaking the program when faulty, immediate mode show that main form is enabled =true so that is not the problem).
    My thoughts are Maybe you have to force the focus to a control, somehow the main form 'forgets' where focus should be.
    Is there any way to follow keybrd or mouse click messages to se why the form is ignoring them.?

  2. #2
    Guest

    Smile

    Try to use this API function, I didnt test it with a SDI form.
    But you can always try it.

    Module:
    Code:
    Public Declare Function BringWindowToTop Lib "user32" _
      (ByVal hwnd As Long) As Long
    Button or Load Event:
    Code:
    Dim lValue as Long
    
    lValue = BringWindowToTop(ChildForm.hwnd)

  3. #3
    Lively Member
    Join Date
    Jan 1999
    Location
    Rochester NY, USA
    Posts
    93
    Did you try it the other way around? First hide the form, then enable the other one? When showing and hiding forms, I always show the form that I want to have focus last. just simply... (as an example)

    Me.Hide
    MainForm.Show

    Now that I think about it though.. the problem may be that the form that you hid doesn't really loose focus because it's just hidden. I'm completely pulling this out of the air.. I don't have anything to base this on.. just a thought. I'd guess what you'd have is...

    Me.Hide
    MainForm.Enable

    Try putting a "MainForm.Show" after that...

  4. #4
    Guest
    yes I have tried those show/hide combinations.
    the main form is clearly visible, (no other form are visible).
    I have intense serial comms interrupts and 0.5 second timer running all the time. The main form form load sub does not end sub, but does endless loop with doevents in it.
    (this may have someyhing to do with the problem, since this is not 'normal' coding
    weird one?!?

Posting Permissions

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



Click Here to Expand Forum to Full Width