Results 1 to 3 of 3

Thread: SetParent and control Tab focus

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Location
    Argentina
    Posts
    441

    SetParent and control Tab focus

    Hi, I see the need to load the content of a picturebox (or a framebox) inside a new form and show this form in a modal way, the only way I know of is through SetParent api, everything is fine, but I have the problem that it stops To work the change of focus through the Tab key, do you have any suggestions for this problem, or how I could move a picturebox into a blank form and without this inconvenience.

    you can test this behavior, add to a form1 a picturebox with two textbox , and add a Form2, run the code
    Code:
    Option Explicit
    Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    
    Private Sub Form_Load()
        Me.Show
        SetParent Picture1.hWnd, Form2.hWnd
        
        Form2.Show vbModal
    End Sub
    leandroascierto.com Visual Basic 6 projects

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2008
    Location
    Argentina
    Posts
    441

    Re: SetParent and control Tab focus

    well it seems that putting this in the form2 already works, there will be cases in which I will have to do some more things but I think this will save me for the moment.

    Code:
    Option Explicit
    Private Declare Function EnableWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal fEnable As Long) As Long
    Private Declare Function PutFocus Lib "user32.dll" Alias "SetFocus" (ByVal hwnd As Long) As Long
    
    Private Sub Form_Activate()
        EnableWindow Form1.hwnd, 1
        PutFocus Form1.Text1.hwnd
    End Sub
    leandroascierto.com Visual Basic 6 projects

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: SetParent and control Tab focus

    Hi, I see the need to load the content of a picturebox (or a framebox) inside a new form and show this form in a modal way,
    Does not using the vbModal on the form .Show method not work?


    oi... IT looks like you're "moving" the picture box to the second form... .why? Just add a property to the second form that would allow you to either 1) pass a reference to the sourceing picture box, you can then use that to setup a picture box on the second form, or 2) Pass an image object to the second form, which can then be used to display, or 3) PAss the path to the image to the second form, and let it load the image.

    Then use form.show(vbModal) to display the form and make it modal.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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