Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Control to Fill Dialog?

Control to Fill Dialog?

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++questionvisual-studiocom
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LiamD
    wrote on last edited by
    #1

    Hi, I am moving from C# to VC++ to test to see if it will meet my timing requirements. I am not familiar with VC++. I want to add an ActiveX control that fills a dialog box. So the size of the control will always match the size of the dialog when it is resized. This is easily done in C# .NET using the Anchor property. How can I do this in VC++? Can it be done by setting properties or do I have to create extra code to achive this? By the way I am using Visual Studio 2003 to create my code for an MFC application. Thanks, Liam

    K 1 Reply Last reply
    0
    • L LiamD

      Hi, I am moving from C# to VC++ to test to see if it will meet my timing requirements. I am not familiar with VC++. I want to add an ActiveX control that fills a dialog box. So the size of the control will always match the size of the dialog when it is resized. This is easily done in C# .NET using the Anchor property. How can I do this in VC++? Can it be done by setting properties or do I have to create extra code to achive this? By the way I am using Visual Studio 2003 to create my code for an MFC application. Thanks, Liam

      K Offline
      K Offline
      khan
      wrote on last edited by
      #2

      I think you will need to handle the WM_SIZE message: void CTheDialog::OnSize(...) { CRect rect; GetClientRect(&rect); m_Control.MoveWindow(&rect); } Now the control will completely occupy the client area of the dialog. this is this.

      L 1 Reply Last reply
      0
      • K khan

        I think you will need to handle the WM_SIZE message: void CTheDialog::OnSize(...) { CRect rect; GetClientRect(&rect); m_Control.MoveWindow(&rect); } Now the control will completely occupy the client area of the dialog. this is this.

        L Offline
        L Offline
        LiamD
        wrote on last edited by
        #3

        Khan++, thanks for the reply this worked for a while now it is failing an assertion: C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\src\mfc\winocc.cpp void CWnd::MoveWindow(int x, int y, int nWidth, int nHeight, BOOL bRepaint) { ASSERT(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL)); ... Can you explain why this is? Also I would like to be able to have a fixed offset from a border. Can this be done easily. Thanks

        K 1 Reply Last reply
        0
        • L LiamD

          Khan++, thanks for the reply this worked for a while now it is failing an assertion: C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\src\mfc\winocc.cpp void CWnd::MoveWindow(int x, int y, int nWidth, int nHeight, BOOL bRepaint) { ASSERT(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL)); ... Can you explain why this is? Also I would like to be able to have a fixed offset from a border. Can this be done easily. Thanks

          K Offline
          K Offline
          khan
          wrote on last edited by
          #4

          You will need to set a boolean variable at class level: BOOL m_bInitialized; And initialize it to FALSE in the constructor. m_bInitialized = FALSE; And set it to TRUE in the OnInitDialog() function. m_bInitialized = TRUE; Also send a resize message explicitly after setting it TRUE: SendMessage(WM_SIZE,0,0); Now modify OnSize() like this: OnSize() { CDialog::OnSize().....//whatever. if (m_bInitialized == TRUE) { Resize the client control here. } } To set an offset you could: CRect rect; ... rect.DeflateRect(10,10,10,10);//This will reduce all the sides of the rect by 10 pixels. this is this.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups