CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    May 2008
    Posts
    74

    detect when form activate reach the limit of the form

    hi,
    there is any way to detect
    when a form activate reach the limit of the mdiform?
    the limit that i want detect is: top,bottom,left,right when the form pass
    from the limit border of the mdiform a msg will appear like a auto scrool appear
    i need detect this for all forms that i have in the project
    thanks for your help

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: detect when form activate reach the limit of the form

    Try it again. I don't understand what you have, or what you need. You mention MDI forms.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    May 2008
    Posts
    74

    Re: detect when form activate reach the limit of the form

    hi,
    i put a image that show what i have.
    i have some forms inside a mdiform and i want know when a form reach the border limit
    of the mdiform for when the form reach that border the form will leave the mdiform.
    them when the form is outside of the mdiform i want put the form inside the mdiform again.
    i just need know how detect wich form is selected inside a mdiform and the position of that form.
    thanks a lot for your help
    Attached Images Attached Images

  4. #4
    Join Date
    Dec 2001
    Posts
    6,332

    Re: detect when form activate reach the limit of the form

    If you want to allow the form to show outside the MDI, then perhaps you don't need an MDI. However, can you clarify what you said about putting the form back inside the MDI again? Why remove it, only to put it right back again? Are you trying to prevent the user from moving the form beyond the boundary of the MDI? Please provide additional details on what it is you want to ultimately accomplish.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  5. #5
    Join Date
    May 2008
    Posts
    74

    Re: detect when form activate reach the limit of the form

    hi,
    no the objetive of remove/put in the mdiform is only for be more produtive desktop just that,
    imagine that you have 2 or 3 lcd and you want a form in each lcd but in the mdiform you want
    certain forms it is very cool for organization etc but the question is not that i only need detect when the form is near from border limit of the mdiform just that

  6. #6
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: detect when form activate reach the limit of the form

    Sounds like all you need to do is check the size of the mdi, the size of the form in question and the locations of the two forms. I would think you might want this code in the drag event of the form.

  7. #7
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: detect when form activate reach the limit of the form

    What drag event would that be? Neither DragDrop nor DragOver would fire if the form is moved.

    You can use this to detect the presence of scrollbars on the MDI form:
    Code:
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" ( _
           ByVal hWnd As Long, _
           ByVal nIndex As Long _
      ) As Long
      
    Private Const GWL_Style = (-16)
    
    Private Const WS_HScroll As Long = &H100000
    Private Const WS_VScroll As Long = &H200000
    
    Private Function GetScrollBarStyle(hWnd As Long) As Integer
      GetScrollBarStyle = (GetWindowLong(hWnd, GWL_Style) / WS_HScroll) And 3
    End Function
    GetScrollBarStyle will return 1 for horizontal, 2 for vertical, 3 for both and 0 for no scrollbars.

    The question is: when would you do this?
    Maybe use a timer and check each 500msec. If scrollbars are shown then you step through all the windows and reposition those which are out of MDI form's area.

  8. #8
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: detect when form activate reach the limit of the form

    My mistake. I was not aware that there was no event fired when a form was dragged in the mdi window though I would imagion there must be an API call to capture such an event.

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

Featured