Results 1 to 11 of 11

Thread: What the f**k is with the focus

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    What the f**k is with the focus

    I am using the simpleeeeeeeeest thing....actually, I am trying to set the focus of any object but it is giving me an error message saying "invalid procedure call".
    For example:

    Form1.SetFocus

    or

    ListView1.SetFocus

    It gives me that error message for all of the above calls.
    Baaaaaaaaah

  2. #2
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    Are the items visible?
    <removed by admin>

  3. #3
    Frenzied Member numtel's Avatar
    Join Date
    Apr 2000
    Location
    CA
    Posts
    1,163
    i tried putting form1.setfocus in form_load and it gave me the same error, try putting it in a procedure that it gurranteed to make sure form1 doesn't have the focus or is visible.

  4. #4
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    If you put it in the Form_Activate sub, it shouldn't give you an error. You have to make sure the form is visible before you set focus to it.
    <removed by admin>

  5. #5

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    I am putting this under the event of "ItemClick" of a listview. So, whenever the user clicks on an item in the listview, it gives the focus to a textbox on the form.
    Baaaaaaaaah

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    A Form is NOT going to receive focus if there are visible and enabled controls on it. Thats why you are getting the "Invalid Procedure Call" for the Form.SetFocus

    On the other hand, I don't see why you are getting that for the ListView control.

  7. #7
    Megatron
    Guest
    You cannot set focus to the controls in the Load() event, because they have not been made visible yet. Put the code in the Activate() event, or commandbutton instead.

  8. #8
    Originally posted by Megatron
    You cannot set focus to the controls in the Load() event, because they have not been made visible yet. Put the code in the Activate() event, or commandbutton instead.
    Actually, you can:
    VB Code:
    1. Private Sub Form_Load()
    2.     [b]Me.Show
    3.     DoEvents[/b]
    4.     Command1.SetFocus
    5. End Sub

  9. #9
    Megatron
    Guest
    1) You don't need DoEvents there
    2) You are deliberately showing the form though. Try the following code, and you'll get an error.
    VB Code:
    1. Private Sub Form_Load()
    2.     Command1.SetFocus
    3. End Sub

  10. #10

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Originally posted by abdul
    I am putting this under the event of "ItemClick" of a listview. So, whenever the user clicks on an item in the listview, it gives the focus to a textbox on the form.
    Baaaaaaaaah

  11. #11
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125
    Originally posted by Megatron
    You cannot set focus to the controls in the Load() event, because they have not been made visible yet. Put the code in the Activate() event, or commandbutton instead.
    Did I mention this like 3 posts before you posted that?
    <removed by admin>

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