Apr 3rd, 2006, 01:01 PM
#1
Thread Starter
Member
Setting a Button location !!!!
How do I set/change the location of a Button located within its Parent Window via the API ?
I can easily set the position of a Parent Window via the SetWindowPos or MoveWindow API s but I can't make it work for a child window (ie Button)
I have used many other supporting functions in the process like GetWindowRect, ClientToScreen... but with no luck
Anyone has an answer out there ?
Thanks.
Apr 3rd, 2006, 01:02 PM
#2
Re: Setting a Button location !!!!
Apr 3rd, 2006, 01:05 PM
#3
Thread Starter
Member
Re: Setting a Button location !!!!
Sorry moved where ?
Thanks.
Apr 3rd, 2006, 01:13 PM
#4
Re: Setting a Button location !!!!
Originally Posted by
BLUE_SEA
Sorry moved where ?
Thanks.
Here...the ClassicVB section.
Apr 3rd, 2006, 02:03 PM
#5
Re: Setting a Button location !!!!
I had no trouble using moving a button in calculator. What are you trying to move and what code have you tried so far?
VB Code:
Private Declare Function MoveWindow Lib "user32" ( _
ByVal hwnd As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal nWidth As Long, _
ByVal nHeight As Long, _
ByVal bRepaint As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _
ByVal hWnd1 As Long, _
ByVal hWnd2 As Long, _
ByVal lpsz1 As String, _
ByVal lpsz2 As String) As Long
Private Sub Command1_Click()
Dim lHwnd As Long
Dim lHwndChild As Long
lHwnd = FindWindow(vbNullString, "Calculator")
lHwndChild = FindWindowEx(lHwnd, 0&, "Button", "Backspace")
MoveWindow lHwndChild, 0, 0, 100, 100, True
End Sub
Apr 3rd, 2006, 04:19 PM
#6
Thread Starter
Member
Re: Setting a Button location !!!!
Thanks bushmobile,
I want to move the OK button when I resize the Standard VB InputBox so if for example I change the width of the InputBox Window the Ok Button should then move so that it stays always at the same distance from the InpuBox right border .
Any Idea ?
Thanks.
Apr 3rd, 2006, 04:53 PM
#7
Re: Setting a Button location !!!!
If this is your app, then the easiest thing to do is create your own InputBox. I've attached an example:
Attached Files
Apr 4th, 2006, 02:34 AM
#8
Thread Starter
Member
Re: Setting a Button location !!!!
Originally Posted by
bushmobile
If this is your app, then the easiest thing to do is create your own InputBox. I've attached an example:
Thanks again but this Custom InputBox doesn't have the option to change its own size . I specifically want to be able to resize it and for the OK and Cancel buttons to remain in the same location in relation to the inputbox right border.
Any thoughts ?
Thank you.
Last edited by BLUE_SEA; Apr 4th, 2006 at 03:35 AM .
Apr 4th, 2006, 04:58 AM
#9
Re: Setting a Button location !!!!
that custom input box was just an example. It's a form that you have full control over (rather the the normal inputbox that you don't). Just resize/reposition your controls in the Form_Resize event.
Last edited by bushmobile; Apr 4th, 2006 at 05:33 AM .
Apr 4th, 2006, 08:11 AM
#10
Thread Starter
Member
Re: Setting a Button location !!!!
Thanks,
I really need to get this working with the standard VB InputBox not with a userform as I am doing this for educational purposes.
Any chance anyone ??
BLUE_SEA
Apr 4th, 2006, 08:33 AM
#11
Re: Setting a Button location !!!!
Here's some threads about customising the standard MessageBox (same principle will apply for the InputBox):
http://www.vbforums.com/showpost.php...58&postcount=4
http://www.vbforums.com/showthread.php?t=329373
As you can see, it ain't easy.
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