Menu

feature equivalent to WTL CDialogResize

2008-07-10
2013-05-28
  • Todor Totev

    Todor Totev - 2008-07-10

    Hello there,
    I have just discovered Win32++ and am playing with the examples right now. My question is, has it a facility like CDialogResize class from WTL? I.e. something that automatically repositions/resizes controls when the user resizes the containing window. That's a non-trivial code which is very easy for a UI newbie (like me) to get wrong.

    What I want to do: I have a dialog that has list view with file names and additional details (similar to the right pane of Windows Explorer). When file names are long, I usually resize their column to see them. Now if the dialog is not resizable, this pushes all other info outside the dialog and I have to scroll like mad.

    By the way, I am very happy that Win32++ uses the Vista style open dialog. I think it and the Task dialog are the best UI features introduced in Vista.

     
    • David

      David - 2008-07-11

      Hi Todor,

      Thanks for you message.  Win32++ doesn't automatically reposition the child windows of a dialog when it's resized, but that is fairly easy to implement.

      Each control on a dialog is actually a child window of the dialog (the dialog is the parent window). The window handle to the dialog control can be retrieved with GetDlgItem. Once you have the control's window handle (HWND) you can move it or resize it in response to a WM_SIZE or WM_SIZING message (depending on the behaviour you're after). For a dialog you handle these messages in DialogProc.

      The child window is moved/resized with either MoveWindow or SetWindowPos.

      If you have any further questions implementing this, please get back to me.

      Best regards,
      David

       
    • Todor Totev

      Todor Totev - 2008-07-14

      Hello David,
      my previous experience with UI part of Windows API is with Delphi / .Net and these libraries do this automatically. I had a look at WTL implementation and it looked quite scary to me. I am not sure what to do with recursive / contained controls, like check boxes inside a group box inside a page of a tab control. Maybe I am trying to bite more than I can swallow.
      Kind regards,
      Todor

       
    • David

      David - 2008-07-15

      Hi Todor,

      To simplify things, I suggest you focus on what your dialog actually has, rather than what it might have.  Based on your first message, I understand that your main concern is with the list view control. You could handle the the WM_SIZE or WM_SIZING message in the dialog's DialogProc, and adjust the size of the the list view accordingly. Then, if it improves the dialog's appearance, you could use the same trick for other controls in your dialog.

      Best Regards,
      David

       
    • Todor Totev

      Todor Totev - 2009-02-27

      Hello David,
      finally I did a resizing window. I started with a mock-up in .net to get the design right (the form designer in visual studio is quite nice plus I can populate some fake data to see how the form looks with the data). Then I re-created the UI in c++. And then I started writing code to handle resizing and it was horrible. So I restarted everything with a simple dialog - one list view which is docked (in .net terms) to the upper edge of the dialog and an OK button which is "anchored" to the lower edge. I successfully wrote the code to reposition these two controls ... in 40 minutes. Granted, it was my first try but frankly it was so awful I do not want to do it again.

      The only idea I have to persuade you that win32++ needs to automate resizing code is to ask you to rewrite the Form example as a resizable window. After you see that there are lines and lines and lines of code that looks very similar yet subtly different you can understand how bad it is to be written by hand, and how prone to errors it is.

      Kind regards,
      Todor

       
    • David

      David - 2009-02-28

      Hi Todor,

      I have no objection to adding to adding a resizeable dialog to Win32++.  It also seems I may have underestimated the difficulty of the task.

      To avoid further fustration, I suggest you send me a direct e-mail of the code you've developed so far, along with a brief list of the shortcommings you feel the code has.  It might also help if you send a small executable demononstrating how you want a resizeable dialog to behave - just so we're on the same page.

      A resizeable dialog is actually on my ToDo list for Win32++, but working on this feature together will yield a faster result rather than waiting for it to bubble to the top of my ToDo list.

      When sending your project, place your entire project in a zip file, leaving out anything I won't need to re-compile it (i.e. leave out the Debug and Release directories as well as any *.ncb files if working with a Microsoft compiler).

      You will find my direct e-mail address listed in the copyright section at the top of the header files in the Win32++ directory. (I avoid mentioning my e-mail address directly on the internet to avoid spam.)

      Best regards,
      David

       

Log in to post a comment.