Results 1 to 19 of 19

Thread: BrandNewbie Questions (Resolved)

  1. #1

    Thread Starter
    Lively Member CagedConfession's Avatar
    Join Date
    Oct 2002
    Posts
    98

    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

  2. #2
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046
    #1
    Private Sub Command1_Click()
    Form2.Show
    End Sub

    #2

  3. #3
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046
    not sure how "bandnewbie" you are, but let me know if you dont understand my previous post ...

  4. #4
    Hyperactive Member Eyes.Only's Avatar
    Join Date
    Oct 2001
    Location
    Minnesota
    Posts
    347
    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.

  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    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:
    1. Private Sub Command1_Click()
    2.     Form2.Show
    3. End Sub
    If you want to force the user to do something with form2, then do this
    VB Code:
    1. Private Sub Command1_Click()
    2.     Form2.Show vbModal
    3. End Sub

  6. #6
    New Member
    Join Date
    Oct 2002
    Location
    Houston, Tx
    Posts
    1
    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

  7. #7
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046
    Originally posted by MartinLiss
    Let me add something to Mr. Water's (Muddy) code.
    *ahem* Mr. Morganfield if you must be formal ... :-)

  8. #8

    Thread Starter
    Lively Member CagedConfession's Avatar
    Join Date
    Oct 2002
    Posts
    98
    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

  9. #9

    Thread Starter
    Lively Member CagedConfession's Avatar
    Join Date
    Oct 2002
    Posts
    98
    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

  10. #10
    New Member
    Join Date
    Sep 2002
    Location
    Tampa
    Posts
    10
    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.

  11. #11
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    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:
    1. Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    2.  
    3. Private Sub Command1_Click()
    4. Load Form1
    5. Me.ScaleMode = Form1.ScaleMode
    6. Form1.Left = Command1.Left
    7. Form1.Top = Command1.Top + Command1.Height
    8. Form1.Show
    9. SetParent Form1.hWnd, Me.hWnd
    10. End Sub
    HTH

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  12. #12
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    You can alwyas position a form based on where the cursor currently is:

    VB Code:
    1. Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    2. Private Type POINTAPI
    3.     x As Long
    4.     y As Long
    5. End Type
    6. Dim rc As Long
    7. Dim lpPoint As POINTAPI
    8.  
    9. Private Sub Form_Load()
    10. 'Position the form wherever the cursor is
    11.     On Error Resume Next
    12.     rc = GetCursorPos(lpPoint)
    13.     Me.Left = (lpPoint.x * 15) - Me.Width + 550
    14.     If Me.Left + Me.Width > Screen.Width Then Me.Left = Screen.Width - Me.Width
    15.     If Me.Left < 0 Then Me.Left = 400
    16.     Me.Top = (lpPoint.y * 15) - Me.Height + 400
    17.     If Me.Top + Me.Height > Screen.Height Then Me.Top = Screen.Height - Me.Height - 400
    18.     If Me.Top < 0 Then Me.Top = 400
    19. 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.

  13. #13

    Thread Starter
    Lively Member CagedConfession's Avatar
    Join Date
    Oct 2002
    Posts
    98
    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

  14. #14
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    Have you declared the setparent API?
    VB Code:
    1. 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

  15. #15

    Thread Starter
    Lively Member CagedConfession's Avatar
    Join Date
    Oct 2002
    Posts
    98
    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

  16. #16
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    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

  17. #17
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    Just Cut 'N' Paste the code above, U will get an idea

    "Brothers, you asked for it."
    ...Francisco Domingo Carlos Andres Sebastian D'Anconia

  18. #18

    Thread Starter
    Lively Member CagedConfession's Avatar
    Join Date
    Oct 2002
    Posts
    98
    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

  19. #19
    Frenzied Member KayJay's Avatar
    Join Date
    Jul 2001
    Location
    Chennai
    Posts
    1,849
    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
  •  



Click Here to Expand Forum to Full Width