CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Jul 2013
    Posts
    5

    Positioning of window on Desktop

    Hi All

    I have a CFormView derived window which I would like to position at run time.
    In particular when the user clicks a button I would like to shfit the CFormView window and open up a new Dialog window so that the two do not overlap.
    I have created the CFormView window and the dialog window- can someone please tell me how to shfit the CFormView window?

    I shift the Dialog window as follows in OnInitDialog:
    SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER);

    Thank you in advance.
    AAEL

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Positioning of window on Desktop

    Well, CFormView derived window is (like any other view) a child of a frame window (either mainframe or childframe)
    You could also let more than one view share a frame window, as in the case of a splitter window. Perhaps, splitter is what you need?
    Or what? Is your app an SDI or MDI?
    Victor Nijegorodov

  3. #3
    Join Date
    Jul 2013
    Posts
    5

    Re: Positioning of window on Desktop

    The application is an SDI.

    All I would like to do is to have the two windows (the SDI CFormView window and the CDialog window) appear so that they do not overlap.

    Thank you

    Quote Originally Posted by VictorN View Post
    Well, CFormView derived window is (like any other view) a child of a frame window (either mainframe or childframe)
    You could also let more than one view share a frame window, as in the case of a splitter window. Perhaps, splitter is what you need?
    Or what? Is your app an SDI or MDI?

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Positioning of window on Desktop

    Then get the position of the view, then set the dialog position to be outside the view rect!
    Victor Nijegorodov

  5. #5
    Join Date
    Jul 2013
    Posts
    5

    Re: Positioning of window on Desktop

    How would I get the position of the view? What is the VC++ command to get the position of the view?

    Thank you

  6. #6
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Positioning of window on Desktop


  7. #7
    Join Date
    Jul 2013
    Posts
    5

    Re: Positioning of window on Desktop

    The first parameter of GetWindowRect is HWND hWnd. How do I get the hWnd for my CFormView?

    Thank you

  8. #8
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Positioning of window on Desktop

    Quote Originally Posted by aael View Post
    The first parameter of GetWindowRect is HWND hWnd. How do I get the hWnd for my CFormView?

    Thank you
    Try this one.
    http://msdn.microsoft.com/en-us/libr.../f3ef9c0s.aspx

    It's better to learn to use MSDN for basic stuff like this rather than using the forum in place of documentation.

  9. #9
    Join Date
    Jul 2013
    Posts
    5

    Re: Positioning of window on Desktop

    Thank you.

    I managed to get the dimensions of the window.
    Please can you tell me how to shift the CFormView window?

  10. #10
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Positioning of window on Desktop

    Quote Originally Posted by aael View Post
    Thank you.

    I managed to get the dimensions of the window.
    Please can you tell me how to shift the CFormView window?
    Don't move the view, move the frame.

  11. #11
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: Positioning of window on Desktop

    Quote Originally Posted by GCDEF View Post
    Don't move the view, move the frame.
    Don't move the frame either - just position your new dialog do it doesn't overlap your view.
    I would be upset if I clicked the button on a form and that form got moved
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

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