James N. Potts <jpmail(a)limolink.com> writes:
>Andy Piper <andy(a)xemacs.org> writes:
>
>> At 09:22 PM 5/29/00 -0500, William M. Perry wrote:
>> >so, since the widgets are glyphs, and glyphs go in toolbars, would I be
>> >able to put a text-entry or combo-box into the toolbar now?
>>
>> Theory says yes. Reality says no because for windows at least its down
to
>> the supported button types. It might work under X though.
This is the
>> problem with working with native widgets - lowest common denominator and
>> all that.
>>
>Oh, windows doesn't let you stick arbitrary widgets into the toolbar? Hrm.
Actually, I believe it does. At least, I've stuck arbitrary controls into
a
native Win32 toolbar in Delphi programs, but I haven't dug into
the Delphi
source to see how it achieves it. Delphi wraps the Win32 Common Controls,
so you can just plop controls onto the toolbar at designtime.
From the look of it, it just creates the arbitrary control using the
toolbar
as the control's parent window. Out of curiosity, I'll dig
into it.
Windows sortof supports this. The tricky part is getting the toolbar
buttons to line up with the arbitrary widget:
You add a separator to the toolbar of the width that you want your widget to
be, and in the location that you it to be. You then create whatever widget
you like, setting its parent window to be the toolbar, and its bounds to be
the bounds of the separator.
Given toolbar handle "bar" the following creates a text box inside a
toolbar:
(translated from pascal in my head, so it probably doesn't compile)
TBBUTTON tb;
RECT r;
int i;
tb.iBitmap = 100; // The width goes in the bitmap field.
// Of course! It's so obvious!
tb.idCommand = 123;
tb.fsState = 0;
tb.fsStyle = TBSTYLE_SEP;
tb.dwData = 0;
tb.iString = 0;
SendMessage(bar, TB_ADDBUTTONS, 1, &tb);
i = SendMessage(bar, TB_COMMANDTOINDEX, 123, 0);
SendMessage(bar, TB_GETITEMRECT, i, &r);
h = CreateWindow('EDIT','Foobar', WS_CHILD | WS_VISIBLE | WS_BORDER,
r.left, r.top, r.right - r.left, r.bottom - r.top,
bar, 0, instance, NULL);
The only hard part after this is to catch any button order updates, and
change the bounds of the widget so that it stays "on top of" the separator.
A smart programmer (unlike me) would store the handle in the dwData field
(or in a structure pointed to by the dwData field) for easy reference.
-Jim