Results 1 to 3 of 3

Thread: Can't Step to Form_Activate

  1. #1

    Thread Starter
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383

    Can't Step to Form_Activate

    When I debug the app with F5, Form_Load and Form_Activate get called just fine.
    However, when I step through the code with F8, Form_Activate doesn't get called.

    I load my form with Form2.Show

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Can't Step to Form_Activate

    don't put any break points in your Form_Load, only in Form_Active.

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Can't Step to Form_Activate

    Quote Originally Posted by agmorgan
    When I debug the app with F5, Form_Load and Form_Activate get called just fine.
    However, when I step through the code with F8, Form_Activate doesn't get called.

    I load my form with Form2.Show
    Yes, you are right.

    For everyone else, try this experiment.

    Open up a new standard exe project and add a second form to the default Form1.

    One Form2, add the following code:
    VB Code:
    1. Private Sub Form_Activate()
    2. MsgBox "Activate"
    3. End Sub
    4.  
    5. Private Sub Form_Initialize()
    6. MsgBox "Initialize"
    7. End Sub
    8.  
    9. Private Sub Form_Load()
    10. MsgBox "Load"
    11. End Sub
    On Form1 put a command button with Form2.Show in its click event; run it; click on Command1. You will see all three message boxes in the following order: Initalize - Load - Activate

    Now, on Form2, but a break on Initialize, and "walk" through the process. After the messageboxs for Initialize and Load appear, you will be taken to the "End Sub" of Command1_Click on Form1, and you won't see the messagebox for Activate on Form2.

    The Activate event ONLY fires when the Form is the Active Window. It will not be the Active Window when you step through the code because the focus will return to the calling form. When you do not step through it, and allow the form to load normally, form2 will become the active window thus firing the Activate event.

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