15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Dynamic dialog boxes

Cheng Tan -- Cheng_Tan@wink.com
Wednesday, April 17, 1996

Hi,

MSVC 4.1, Win95

I have a need for a dynamic dialog box where controls are made visible or 
invisible based on the selection in a drop list.
I've found Atif Aziz's article in MSDN and the he mentions these methods:

 1) overlay all the controls. Maintenance will be messy.

 2) make use of Borland's resource editor, spread the controls out and write a 
MoveCategory function

 3) nest dialog boxes. Interesting but...
 "The IsDialogMessage function that orchestrates tabbing and mnemonics within a 
dialog box is limited to 
 the first level of sibling child windows only. Writing a function that mimics 
the functionality of IsDialogMessage 
 to account for all levels of nesting is not easy."

 4) rendering controls from one dialog box resource to another

Method 4 seems OK but I was wondering if there is a better way of going about 
this.

Thanks in advance,
Cheng



Mike Blaszczak -- mikeblas@interserv.com
Saturday, April 20, 1996

[Mini-digest: 4 responses]

On 17 Apr 96, Cheng Tan  wrote:
>MSVC 4.1, Win95

Thanks.

>I have a need for a dynamic dialog box where controls are made visible or 
>invisible based on the selection in a drop list.
>I've found Atif Aziz's article in MSDN and the he mentions these methods:

[...]

> 2) make use of Borland's resource editor, spread the controls out
> and write a MoveCategory function

If you carefully read the article, you'll note that it is pretty old. It 
refers to VC++ 1.0, and says that VC++ 1.0 doesn't support drawing a dialog 
box clips its own controls.  VC++ 4.x certainly does support this, and VC++ 
2.x might--I don't have a copy of it at home.

So, this approach is probably the easiest... and you don't need the Borland 
resource editor to pull it off.  What don't you like, by the way, about all 
of the four suggestions that you recalled from the article?

.B ekiM
TCHAR szDisc[] = _T("These words are my own; I do not speak for Microsoft.");

-----From: Brad Wilson 

>> I have a need for a dynamic dialog box where controls are made visible or 
>> invisible based on the selection in a drop list.

Hiding things from the user makes it difficult to remember how they
got to "see" the controls, because they won't know where they were
when the controls were "shown".

[Moderator's note: I don't think we know enough specifics to be able
to make a statement like this.  For all we know, this is a very
natural interface for what Cheng is working on.]

Isn't there some graceful alternative?  If not ...

>>  3) nest dialog boxes. Interesting but...

Your best bet is here, I think, with a 32-bit application.  Giving
the nested dialog the extended style WS_EX_CONTROLPARENT should
allow you to get the tabbing "in" and "out" of the nested dialog.
Property sheets and pages use this style.

Brad

--
Brad Wilson, Crucial Software     crucial@ix.netcom.com    +1 (810) 620-9803
Custom software engineering services for Microsoft Windows NT and Windows 95

  "You wear guilt . Like shackles on your feet . Like a halo in reverse
   I can feel . The discomfort in your seat . And in your head it's worse"

-----From: John Addis 

Having not read the article I'm not sure what is meant by a 
"MoveCategory" function, but I would try the following:

1) Create all the controls in the dialog editor. 
2) Place a control (either the initially visible control or a dummy 
placeholder) in the appropriate spot.
3) Override OnInitDialog. After calling the inherited method use 
MoveWindow to move each control to the spot of the placeholder control.
4) When the 'mode' of the dialog changes use ShowWindow to hide/show the 
appropriate controls.


-- 
John Addis        Master of Time and Space
jaddis@erols.com  C++, MFC, Win32, Win95, TCP/IP
"Invalid or missing REALITY.COM Universe halted."

-----From: "David W. Gillett" 

>  1) overlay all the controls. Maintenance will be messy.

  Agreed.  (shudder!)

>  2) make use of Borland's resource editor, spread the controls out
> and write a MoveCategory function

  Interesting idea.

>  3) nest dialog boxes. Interesting but...
> "The IsDialogMessage function that orchestrates tabbing and
> mnemonics within a dialog box is limited to the first level of
> sibling child windows only. Writing a function that mimics the
> functionality of IsDialogMessage to account for all levels of
> nesting is not easy."

  I believe that this is fixed in Win95 by the DS_CONTROL and 
WS_EX_CONTROLPARENT styles.  The quotes was accurate for previous 
versions of Windows.
  [Pages within a property sheet are handled using the DS_CONTROL 
style, and it works quite nicely.]

  Go for it!

>  4) rendering controls from one dialog box resource to another

  I'm not sure how this would work.

Dave
 




| Вернуться в корень Архива |