CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    May 2006
    Location
    India
    Posts
    22

    Question How to solve the problem with move window?

    What are the problems we can face with Movewindow?
    I used the getclient rect, got the rectangle and then
    I am using the move window function.

    Then here i got the problems.
    The window is not moveing to the particular position.
    How to solve that problems.
    Any one please let me know.

  2. #2
    Join Date
    May 2005
    Posts
    4,954

    Re: How to solve the problem with move window?

    What do you mean the "window is not moving to the particular position"? .

    Did you check what coordinates you are passing to MoveWindow() ?

    Cheers
    If a post helped you dont forget to "Rate This Post"

    My Article: Capturing Windows Regardless of Their Z-Order

    Cheers

  3. #3
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: How to solve the problem with move window?

    Code:
    	void OnLButtonUp(UINT /**/, CPoint pt)
    	{
    		CRect rc;
    		ClientToScreen((LPPOINT)&pt);
    		GetWindowRect(rc);
    		MoveWindow(pt.x, pt.y, rc.Width(), rc.Height());
    	}
    Attached Files Attached Files
    Best regards,
    Igor

  4. #4
    Join Date
    May 2006
    Location
    India
    Posts
    22

    Re: How to solve the problem with move window?

    Oh! really thank ful to you. Thanks for replying.
    I have a small problem. I have a frame in a dialog.
    I want to move other window to that frame window's coordinates. the frame window coordinates is fixed. I have to get the coordinates and have to move that other window.
    here the problem is i am using MDI application. my child dialog is bigger. and the dialog displaying is smaller. so it is with scrollbar. the frame i mensioned in above is bigger than the mdi child's size. with scrolling we can see that window.
    I have to move my window to that frame window. how to make it possiable. if you did not understand please let me know i will send you a sample program. thanks a lot.

  5. #5
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: How to solve the problem with move window?

    Quote Originally Posted by MSDN
    MoveWindow Function
    The MoveWindow function changes the position and dimensions of the specified window. For a top-level window, the position and dimensions are relative to the upper-left corner of the screen. For a child window, they are relative to the upper-left corner of the parent window's client area.
    So the only thing you must handle is to define proper coordinates and map them into coordinates of parent of window to be moved.
    Best regards,
    Igor

  6. #6
    Join Date
    May 2006
    Location
    India
    Posts
    22

    Re: How to solve the problem with move window?

    Thank you all friends.

    I just changed my code as GetWindowRect instead of GetClientRect.
    Then suddenly my problem solved. Thanks a lot to codeguru.

    The code i used is as follows:
    ------------------------------------
    Code:
    CRect rectROLL_FRA;
    	GetDlgItem(FRA_ROLL_CASH_DRAFT)->GetWindowRect(rectROLL_FRA);
    	ScreenToClient( rectROLL_FRA );
    	bSuccess = m_rollup.Create(WS_CHILD | WS_DLGFRAME | WS_VISIBLE, rectROLL_FRA, this, 0);
    	ASSERT(bSuccess);

  7. #7
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: How to solve the problem with move window?

    Quote Originally Posted by raj1to0
    Thank you all friends.

    I just changed my code as GetWindowRect instead of GetClientRect.
    Then suddenly my problem solved. Thanks a lot to codeguru.

    The code i used is as follows:
    ------------------------------------
    Code:
    CRect rectROLL_FRA;
    	GetDlgItem(FRA_ROLL_CASH_DRAFT)->GetWindowRect(rectROLL_FRA);
    	ScreenToClient( rectROLL_FRA );
    	bSuccess = m_rollup.Create(WS_CHILD | WS_DLGFRAME | WS_VISIBLE, rectROLL_FRA, this, 0);
    	ASSERT(bSuccess);
    Do you find it sudden?

    You should read the MSDN articles on GetClientRect and GetWindowRect. The latter returns the rect in screen coordinates, so the following ScreenToClient is seemed like been having a sense. In contrast to GetClientRect case...

    PS. The golden programmer's rule: never neglect reading helps. Especially being facing troubles.
    Best regards,
    Igor

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