|
-
Oct 26th, 2002, 11:13 PM
#1
Thread Starter
Lively Member
BrandNewbie Questions (Resolved)
Hi, I'm sure my questions are so elementary that they may sound stupid, but here goes.
I have a command button on form 1 that when clicked I would like it to pull up form 2, How do I get it to do this, how do I align it right under the button itself???
Question 2
I want my program to pop up in an abnormal shape, for example if i wanted my program to start up and it be in the shape of a cross picture I found, how would i do this???
Thx to anyone who can help me on this.........
Last edited by CagedConfession; Oct 29th, 2002 at 05:51 PM.
 [vbcode]Private Sub Form_Load()
I would rather be hated for who I am than loved for who I'm not.[/vbcode]
End Sub
-
Oct 26th, 2002, 11:15 PM
#2
PowerPoster
#1
Private Sub Command1_Click()
Form2.Show
End Sub
#2
-
Oct 26th, 2002, 11:18 PM
#3
PowerPoster
not sure how "bandnewbie" you are, but let me know if you dont understand my previous post ...
-
Oct 26th, 2002, 11:25 PM
#4
Hyperactive Member
as regards your second question:
http://www.vbforums.com/showthread.p...hreadid=109909
Has a tool for it or a link to the API way.
-
Oct 26th, 2002, 11:31 PM
#5
Let me add something to Mr. Water's (Muddy) code.
The following code will allow the user to interact with either form1 or form2, or ignore form2 completely.
VB Code:
Private Sub Command1_Click()
Form2.Show
End Sub
If you want to force the user to do something with form2, then do this
VB Code:
Private Sub Command1_Click()
Form2.Show vbModal
End Sub
-
Oct 26th, 2002, 11:51 PM
#6
New Member
For VB .NET the code that works for Modal is:
Private Sub Command1_Click()
Form2.ShowDialog
End Sub
Instead of:
Private Sub Command1_Click()
Form2.Show vbModal
End Sub
-
Oct 27th, 2002, 12:28 AM
#7
PowerPoster
Originally posted by MartinLiss
Let me add something to Mr. Water's (Muddy) code.
*ahem* Mr. Morganfield if you must be formal ... :-)
-
Oct 27th, 2002, 04:17 AM
#8
Thread Starter
Lively Member
Cool, i did get the form to pop up. Now how do I get it to align its self automatically under the button itself. For instance when the program itself is moved around on the screen i want the box to stay under the button when pressed. Thanks for your help......This is probally just the beggining of my questions. But i'll try not to bother u guys to much......
 [vbcode]Private Sub Form_Load()
I would rather be hated for who I am than loved for who I'm not.[/vbcode]
End Sub
-
Oct 27th, 2002, 05:06 AM
#9
Thread Starter
Lively Member
Cool, i did get the form to pop up. Now how do I get it to align its self automatically under the button itself. For instance when the program itself is moved around on the screen i want the box to stay under the button when pressed. Thanks for your help......This is probally just the beggining of my questions. But i'll try not to bother u guys to much......
 [vbcode]Private Sub Form_Load()
I would rather be hated for who I am than loved for who I'm not.[/vbcode]
End Sub
-
Oct 27th, 2002, 07:16 AM
#10
New Member
i'm pretty new myself, caged, but i think you can make your new form appear exactly where you want it using the "left" "right" properties. and size it with the height/width properties.
also - there is a screen layout display that you can use that may work.
To be on the wire is life - everything else is just waiting.
-
Oct 27th, 2002, 08:12 AM
#11
Frenzied Member
Originally posted by CagedConfession
Cool, i did get the form to pop up. Now how do I get it to align its self automatically under the button itself. For instance when the program itself is moved around on the screen i want the box to stay under the button when pressed. Thanks for your help......This is probally just the beggining of my questions. But i'll try not to bother u guys to much......
As subraven mentioned, the Left and Top properties have to be use to align the form. To ensure that the second form does not leave the screen area of the first form, the SETPARENT api call is used. You can know more about api calls at http://www.allapi.net
VB Code:
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Sub Command1_Click()
Load Form1
Me.ScaleMode = Form1.ScaleMode
Form1.Left = Command1.Left
Form1.Top = Command1.Top + Command1.Height
Form1.Show
SetParent Form1.hWnd, Me.hWnd
End Sub
HTH
"Brothers, you asked for it."
...Francisco Domingo Carlos Andres Sebastian D'Anconia
-
Oct 28th, 2002, 06:01 AM
#12
Frenzied Member
You can alwyas position a form based on where the cursor currently is:
VB Code:
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Dim rc As Long
Dim lpPoint As POINTAPI
Private Sub Form_Load()
'Position the form wherever the cursor is
On Error Resume Next
rc = GetCursorPos(lpPoint)
Me.Left = (lpPoint.x * 15) - Me.Width + 550
If Me.Left + Me.Width > Screen.Width Then Me.Left = Screen.Width - Me.Width
If Me.Left < 0 Then Me.Left = 400
Me.Top = (lpPoint.y * 15) - Me.Height + 400
If Me.Top + Me.Height > Screen.Height Then Me.Top = Screen.Height - Me.Height - 400
If Me.Top < 0 Then Me.Top = 400
End Sub
Positioning it is easy (just set Me.Left and / or Me.Top. Its checking to make sure that the form is still on the screen that is a little harder.
-
Oct 28th, 2002, 11:06 PM
#13
Thread Starter
Lively Member
Private Sub Command3_Click()
Load Form1
Me.ScaleMode = Form2.ScaleMode
Form1.Left = Command1.Left
Form1.Top = Command1.Top + Command1.Height
Form1.Show
SetParent Form1.hwnd, Me.hwnd
End Sub
I get the error subfunction not defined. Compile error.
It highlights the SetParent
 [vbcode]Private Sub Form_Load()
I would rather be hated for who I am than loved for who I'm not.[/vbcode]
End Sub
-
Oct 29th, 2002, 01:03 AM
#14
Frenzied Member
Have you declared the setparent API?
VB Code:
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
HTH
"Brothers, you asked for it."
...Francisco Domingo Carlos Andres Sebastian D'Anconia
-
Oct 29th, 2002, 03:05 AM
#15
Thread Starter
Lively Member
Where would i put this at on my main form, form1?
 [vbcode]Private Sub Form_Load()
I would rather be hated for who I am than loved for who I'm not.[/vbcode]
End Sub
-
Oct 29th, 2002, 05:27 AM
#16
Frenzied Member
In the General Declarations Section of the Form. If U have Option Explicit, then just below Option Explicit
"Brothers, you asked for it."
...Francisco Domingo Carlos Andres Sebastian D'Anconia
-
Oct 29th, 2002, 05:29 AM
#17
Frenzied Member
Just Cut 'N' Paste the code above, U will get an idea
"Brothers, you asked for it."
...Francisco Domingo Carlos Andres Sebastian D'Anconia
-
Oct 29th, 2002, 05:50 PM
#18
Thread Starter
Lively Member
Got it, Thankx everybody for your help. You sure can make a rookie programers life easier. I still got a long way to go though before I get everything panned out.
 [vbcode]Private Sub Form_Load()
I would rather be hated for who I am than loved for who I'm not.[/vbcode]
End Sub
-
Oct 30th, 2002, 01:08 AM
#19
Frenzied Member
UR Welcome
"Brothers, you asked for it."
...Francisco Domingo Carlos Andres Sebastian D'Anconia
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
|