Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to create, in a .RC file, a control with child-controls

57 views
Skip to first unread message

R.Wieser

unread,
Dec 25, 2011, 1:26:22 PM12/25/11
to
Hello All,

I'm trying to create a dialog with a rebar control in it, which should go
between a listview (top) and a textbox (bottom).

The problem is that I have no idea to, in a .RC file, create a control (the
ReBar) with two other controls as its childs (the listview and the textbox).

By the way: I do not even know if the above actually possible (or the best
way to do it). So, help is appriciated.

Rudy Wieser

P.s.
I assume that the same method could than also be used for a groupbox (so
that if the groupbox is disabled/made invisible all its children will be
too) ?



r_z_...@pen_fact.com

unread,
Dec 30, 2011, 12:54:09 PM12/30/11
to
On Sun, 25 Dec 2011 19:26:22 +0100, "R.Wieser" <add...@not.available>
wrote:

>Hello All,
>
>I'm trying to create a dialog with a rebar control in it, which should go
>between a listview (top) and a textbox (bottom).
>
>The problem is that I have no idea to, in a .RC file, create a control (the
>ReBar) with two other controls as its childs (the listview and the textbox).

Why do you think you need to do this in an rc file, rather than in
code? If you're willing to do it in code, I think you can use the
SetParent function.

More fundamentally, why do you think the listview and text box need to
be children of the rebar? Maybe if you step back a bit, one of us can
help you solve the real problem.


>
>By the way: I do not even know if the above actually possible (or the best
>way to do it). So, help is appriciated.
>
>Rudy Wieser
>
>P.s.
>I assume that the same method could than also be used for a groupbox (so
>that if the groupbox is disabled/made invisible all its children will be
>too) ?
>
>

-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret
PenFact, Inc.
20 Park Plaza, Suite 400
Boston, MA 02116
www.penfact.com
Useful reading (be sure to read its disclaimer first):
http://catb.org/~esr/faqs/smart-questions.html

R.Wieser

unread,
Dec 30, 2011, 9:32:08 PM12/30/11
to
Hello Robert,

> Why do you think you need to do this in an rc file, rather
> than in code?

Wrong question. The question is *why not*.

Yes, I know that I can add controls to a dialog defined in an RC file by
adding code to its WM_INIT event. But at best I would call that (adding
extra controls) a kludge/hack. And if I can add stuff that way to the
dialog why not do *everything* in code ?

The answer is : for easiness sake. What else ?

> More fundamentally, why do you think the listview and text
> box need to be children of the rebar?

I'm sorry ? What is that ReBar control supposed to be for ? Isn't it
ment to be a movable divider, (most always) between two other controls ?
If so, is it too much to expect that it has some mechanism implemented to
send WM_SIZE messages to its children -- indicating the new area
available -- so they can respond to a change of position of the ReBar ?

But than again, I'm not an MS programmer and might expect too much ...

> Maybe if you step back a bit, one of us can
> help you solve the real problem.

I'm sorry, I again do not understand. What do you think that that "real
problem" is I might be having ?

The simpelest description I can come up with is this:

I want to be able to have to some space available which is occupied by two
controls. I want to have something in between those two controls that I
can, at run-time, drag (left/right or up/down) to give one control more
space and the other less.

Example: Open up you favorite HTTP-browser and display the webpage as well
as your favorites. Chances are that the favorites are displayed as a column
at the left of the webpage, and that you will be able to drag the border
between them left and right.

Isn't that what the ReBar control is ment for ?

Regards,
Rudy Wieser


-- Origional message:
<r_z_aret@pen_fact.com> schreef in berichtnieuws
altrf71a1itm7qkjn...@4ax.com...

ScottMcP [MVP]

unread,
Dec 30, 2011, 10:00:10 PM12/30/11
to
>
> Isn't that what the ReBar control is ment for ?
>

No. Splitting the main window into two panes that the user can resize
is done with a so-called "splitter" window. Here's a tutorial...

http://www.catch22.net/tuts/splitter

R.Wieser

unread,
Dec 31, 2011, 3:06:13 PM12/31/11
to
Hello Scott,

My apology. The info on MSes page was not too clear in which control does
what, and I assumed I had the right one. Actually, I tried to get my
question answered before expirimenting with it (a bit of chicken-and-egg
problem). Maybe not the best of choices.

Also, I was -- mistakingly -- sure there was a control to do this
splitter-job, so thank you for that link. It looks like I've been searching
in the wrong direction. :-\

My origional question remains though.

In the link you provided for "method 1" the description is : "This frame
window contains all the windows that need to be divided from each other" (I
assume that this "contains" is ment not only topological but also
relational).

How do I, in a .RC file, after specifying in the dialog a "frame window",
specify other controls which than have that "frame window" as its parent ?

Is it at all possible to do ?

Regards,
Rudy Wieser


-- Origional message
ScottMcP [MVP] <scot...@mvps.org> schreef in berichtnieuws
e81869ee-6f16-43be...@o14g2000vbo.googlegroups.com...

ScottMcP [MVP]

unread,
Dec 31, 2011, 4:26:28 PM12/31/11
to
There is no way to achieve the splitter window effect within a .RC
file. It has to be done with code.

First you need code to draw the splitter bar as the user drags it.
That could probably be done in your dialog. Then when the user ends
the drag you need code to resize the controls to match the new
splitter position.

You might be able to create the two controls in the .RC file (I
haven't tried that). If that doesn't work out create a window to
cover the dialog and handle the splitter bar, and create the controls
in code as children of the splitter window.

Christian ASTOR

unread,
Dec 31, 2011, 11:00:52 PM12/31/11
to
ScottMcP [MVP] a �crit :
> There is no way to achieve the splitter window effect within a .RC
> file. It has to be done with code.

It can be done with a Custom Control where you put a classname for an
own splitter window class
You just have to call RegisterClass() at the beginning.

I do it with a custom splitter class where the only code is in
WM_INITDIALOG where I define which controls are handled by the splitter
(upper, lower for an horizontal splitter for example)

R.Wieser

unread,
Jan 1, 2012, 10:16:36 AM1/1/12
to
Hello Scott,

> There is no way to achieve the splitter window effect
> within a .RC file.

I'm sorry, I've probably been not too clear in describing the desired
outcome ...

The *only* thing I want to be able is to create a parent-child hierachy in
that .RC file. Anything else is than upto the used controls themselves.


In one case I would sub-class the parent-object (the frame-window) to create
a splitter-bar effect for its two children. In another case I would use the
parent-object as a way to make a group of child-controls visible/invisible.
I'm pretty sure there are other possibilities to use this parent-child
association.

You know, its hard to believe that I can, in a .RC file, group radio-buttons
together and describe a full toolbar menu structure, but not create such a
simple parent-child association ....

Regards,
Rudy Wieser


-- Origional message:
ScottMcP [MVP] <scot...@mvps.org> schreef in berichtnieuws
b112078e-43ef-47bd...@m10g2000vbc.googlegroups.com...

R.Wieser

unread,
Jan 1, 2012, 10:23:43 AM1/1/12
to
Hello Christian,

> I do it with a custom splitter class

That will probably be my end-result too.

> where the only code is in WM_INITDIALOG where I define
> which controls are handled by the splitter

My idea was that that relationship would be pre-defined by the .RC file.

But you made me realize that I could just add another WM_..... command to
that custom class by which I can define the two (never less, never more)
sub-windows controlled by it.

As such, thank you for stirring-up my mind. :-)

Regards,
Rudy Wieser


-- Origional message.
Christian ASTOR <cast...@club-internet.fr> schreef in berichtnieuws
jdolrs$o27$1...@speranza.aioe.org...
> ScottMcP [MVP] a écrit :

r_z_...@pen_fact.com

unread,
Jan 3, 2012, 9:33:58 AM1/3/12
to
On Sat, 31 Dec 2011 03:32:08 +0100, "R.Wieser" <add...@not.available>
wrote:

>Hello Robert,
>
>> Why do you think you need to do this in an rc file, rather
>> than in code?
>
>Wrong question. The question is *why not*.
>
>Yes, I know that I can add controls to a dialog defined in an RC file by
>adding code to its WM_INIT event. But at best I would call that (adding
>extra controls) a kludge/hack. And if I can add stuff that way to the
>dialog why not do *everything* in code ?

I do most dialog editing in code. In particular, I size and place
almost all controls so I can adjust dynamically to screen/window size.
And I add/remove some controls dynamically to adjust to user
privileges, context (within my program), and screen/window size. Once
I got in the habit this became easier for me than tweaking .rc files.
Works for me, but might not work for anyone else.


>
>The answer is : for easiness sake. What else ?

Programmer ease is certainly valid, but projects often come with other
restraints. And different programmers have different ideas about what
is easier (see above). I've learned to avoid making assumptions when I
try to help someone.


clip


>
>> Maybe if you step back a bit, one of us can
>> help you solve the real problem.
>
>I'm sorry, I again do not understand. What do you think that that "real
>problem" is I might be having ?
>
>The simpelest description I can come up with is this:
>
>I want to be able to have to some space available which is occupied by two
>controls. I want to have something in between those two controls that I
>can, at run-time, drag (left/right or up/down) to give one control more
>space and the other less.

This is what I had in mind. And I think ScotMcP's response
demonstrates why I asked.

R.Wieser

unread,
Jan 3, 2012, 10:50:06 AM1/3/12
to
Hello Robert,

> I've learned to avoid making assumptions when I
> try to help someone.

My apologies if this sounds blunt, but you *did* make an assumption: that
the question I asked was not the question I wanted to have answered ... :-\

But that question *and only that one* was the one I, at that time, wanted to
have answered. The rest was ... stuffing (not that I'm not gratefull for
the replies/pointers from Scott & Christian mind you), only in there so that
you guys could make a mental image of why I needed it.

I also gave not one, but *two* reasons/examples why I wanted to be able to
write that parent-child structure into an .RC file.

The only mistake (I think) I made was naming the wrong control for the job
...


And yes, I could still use a positive answer. It would still be usable for
both of the provided examples (and probably for more). As I mentioned to
Scott, its hard to believe that building such a simple structure isn't
possible.

Regards,
Rudy Wieser


-- Origional message:
<r_z_aret@pen_fact.com> schreef in berichtnieuws
tg36g7p2hsu1o5m2f...@4ax.com...

r_z_...@pen_fact.com

unread,
Jan 6, 2012, 12:45:31 PM1/6/12
to
On Tue, 3 Jan 2012 16:50:06 +0100, "R.Wieser" <add...@not.available>
wrote:

>Hello Robert,
>
>> I've learned to avoid making assumptions when I
>> try to help someone.
>
>My apologies if this sounds blunt, but you *did* make an assumption: that
>the question I asked was not the question I wanted to have answered ... :-\
>

No, I did not make that assumption. But you did ask that question
because you were having trouble implementing a design you had chosen.
And I know that sometimes asking why a person chose the design (the
bigger picture) can lead to a different design that works well.

Somewhat oversimplified example. Someone asks how to get a list box
(very old control) to show multiple columns. The responder says that
would be difficult and asks why the OP wanted to use a list box with
multiple columns. And as a result, the OP finds out a list control
would work. The specific question was not answered, but the question
behind it was.

R.Wieser

unread,
Jan 7, 2012, 6:40:49 AM1/7/12
to
Hello Robert,

> Somewhat oversimplified example.
...
> The specific question was not answered, but the
> question behind it was.

Yes, its oversimplified, and given with a 20-20 vision. Alas, this time
your "I am sure thats not what he wants to know" assumption failed you. :-)

O.k. , I may be a bit odd. I really do like to have my questions answered,
or at least acknowledged (better yet: being asked if I'm sure that what I'm
asking for is what I need to know).

... but than again, I thought I had hammered that down by providing *two*
examples needing the same solution, not one ...

Regards,
Rudy Wieser

<r_z_aret@pen_fact.com> schreef in berichtnieuws
rsbeg7d804shupgrs...@4ax.com...
0 new messages