FF Environment Options Form (how it's done)

Started by David Kenny, July 10, 2014, 04:14:11 PM

Previous topic - Next topic

David Kenny

Hello Paul,

I like the way this dialog looks as opposed to using a Tab Control.  I can think of a couple ways of emulating this form.

  • Have all the controls present at design time.  Show/hide them at runtime as needed. (Form management nightmare)
  • Create them myself with CWindow.  (A little backwards when I have a visual designer)
  • Manage a borderless windows over the top of this parent.  (Messy)
I'm sure I could get each one of these techniques to work, but each has it's own pros and cons.
I am not looking for source code, just a point in the right direction if you don't mind.

Thanks,

David

Paul Squires

Hi David,

The FF Environment Options dialog is (as you probably guessed) a main dialog with a collection of embedded child dialogs. The main dialog has a Treeview control on the left hand side and a Label control on the top right that displays the name of the child pages as you select choices from the Treeview. There is also the OK and CANCEL buttons on the main form.

When a Treeview node is selected, a frameless child dialog is displayed on the right hand side of the parent dialog. For example, clicking on the "Compiler" node will show the frmOptionsCompiler child form. The Window Styles for the child forms are simply WS_CHILD, WS_CLIPSIBLINGS and WS_CLIPCHILDREN (note that WS_VISIBLE is *not* checked).

When the main parent Environment Options dialog loads, it also loads the child dialogs as non-modal. I then programatically select the first node in the Treeview.

When a node in the Treeview is clicked on, the TVN_SELCHANGED message is handled. In there I set the Label control that describes the child form being displayed, hide the currently displayed child form, and finally display the new child form with code like the following:

    SetWindowPos hForm, 0, nLeft& + afxScaleX(5), afxScaleY(50), afxScaleX(370), afxScaleY(280), %SW_SHOW


If you have any questions just let me know and I'll describe it in more detail.
:)
Paul Squires
PlanetSquires Software

David Kenny

Thank you Paul,

When I was waiting for your reply yesterday, I got it working with a non-Child window.  But I had to jump through some hoops to get it to work and behave nice.  If the parent form moved, the non-Child form had to be moved manually (with code of course).  And when a treeview item was selected and the corresponding form was displayed, the focus shifted from the treeview to the new form, etc.

I hadn't used Child forms before and it certainly made it easier.   ;D

One thing that had me puzzled for a bit was that I tried the %SW_SHOW flag you used in your SetWindowPos example.  It should have been %SWP_SHOWWINDOW.

Thanks again,

David