|
-
Jun 14th, 2022, 07:37 PM
#1
Thread Starter
Hyperactive Member
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
-
Jun 15th, 2022, 05:33 AM
#2
Thread Starter
Hyperactive Member
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
-
Jun 15th, 2022, 12:57 PM
#3
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|