CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2004
    Posts
    31

    Question Problem resizing control in dialog!

    Hi Gurus!
    I've a very weird problem! I want to resize a picture control inside a dialog. I designed the dialog including its controls.
    In the program I wrote the following lines:

    // Get window size
    CRect rect;
    m_preview.GetWindowRect(&rect);
    m_preview.MoveWindow(&rect);

    It should show the control exactly the same as I placed it inside the dialog.....but it moves the picture control a few pixels down.
    Any ideas why is this happening?
    Thanks!

  2. #2
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    Re: Problem resizing control in dialog!

    Run thru debugger for actual values of the RECT and also read up documentation on MSDN. You'll figure out whats happening..

  3. #3
    Join Date
    Jun 2004
    Location
    Chicago, United States
    Posts
    88

    Re: Problem resizing control in dialog!

    You should convert the rectangle from the screen to the client coordinates of the dialog before you call MoveWindow function.
    Code:
    CRect rect;
    m_preview.GetWindowRect(&rect);
    this->ScreenToClient(rect);
    m_preview.MoveWindow(&rect);
    // where this is a pointer to your dialog box
    Last edited by amarcode; November 4th, 2004 at 08:01 AM.
    A.M.
    My Latest Articles:
    CCustomBitmapButton - An owner-draw button and a frame for the caption bar, in one class.
    CCustomTabCtrl - A clone of the Excel tab sheet control.

  4. #4
    Join Date
    Oct 2004
    Posts
    31

    Smile Re: Problem resizing control in dialog!

    Thanks a lot for all your help!

  5. #5
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: Problem resizing control in dialog!

    Quote Originally Posted by amarcode
    // where this is a pointer to your dialog box
    [/code]

    this is absolutely unnecessary.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  6. #6
    Join Date
    Jun 2004
    Location
    Chicago, United States
    Posts
    88

    Re: Problem resizing control in dialog!

    Quote Originally Posted by JohnCz

    this is absolutely unnecessary.
    I know it. I only wanted to point that the code shuld be placed in the dialog box class.
    A.M.
    My Latest Articles:
    CCustomBitmapButton - An owner-draw button and a frame for the caption bar, in one class.
    CCustomTabCtrl - A clone of the Excel tab sheet control.

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