ATL combobox - - drawing problem 
Author Message
 ATL combobox - - drawing problem

Hi all,
   I have made an ActiveX combobox using the ATL wizard.  
Once I created the project, I used "Insert->New ATL  
Object->Full Control", and based the new control on
ComboBox. I modified the m_ctlComboBox.Create call in the
OnCreate handler to specify the CBS_DROPDOWNLIST style.  
So far, so good.  However, when I place the control on a
form and size it so there is some room for the drop-down
list, the control, rather than confining itself to the
area of its edit-box, erases the form's background over
the whole area where the opened list will appear, making
an unsightly white splotch on the already drab grey form.
I can't seem to eliminate this problem.  Any suggestions?
  Thanks, MP


Wed, 10 Nov 2004 03:23:40 GMT  
 ATL combobox - - drawing problem
Size the control on the form to the desired (small) size. The control
should use larger size when it creates an underlying combobox (find
CreateWindow call in the generated code and adjust it to taste).

Alternatively, a control may get its initial size from the form and
create the combobox with this size, then resize itself to a smaller
size. In this case you resize the control on the form to the (large)
size of the drop-down list. Be aware that this technique does not work
when the host is an ATL dialog or composite control. ATL hosting does
not support self-resizing controls.

The control resizes itself by calling IOleInPlaceSite::OnPosRectChange.
Do not use MoveWindow or similar methods - you should make the container
aware of the size change first, and that's what OnPosRectChange is
about.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> Hi all,
>    I have made an ActiveX combobox using the ATL wizard.
> Once I created the project, I used "Insert->New ATL
> Object->Full Control", and based the new control on
> ComboBox. I modified the m_ctlComboBox.Create call in the
> OnCreate handler to specify the CBS_DROPDOWNLIST style.
> So far, so good.  However, when I place the control on a
> form and size it so there is some room for the drop-down
> list, the control, rather than confining itself to the
> area of its edit-box, erases the form's background over
> the whole area where the opened list will appear, making
> an unsightly white splotch on the already drab grey form.
> I can't seem to eliminate this problem.  Any suggestions?
>   Thanks, MP



Wed, 10 Nov 2004 04:41:23 GMT  
 ATL combobox - - drawing problem

Thanks as always for responding, Igor.

When I size the control on the form to the size of the
editbox, the dropdown doesn't open at runtime.  The
underlying control (the CContainedWindow with
the "ComboBox" style) is created (in the wizard-generated
code) in the constructor, and there is a call to
CContainedWindow::Create in the OnCreate handler of the
outer control. What I have to figure out is what the
combobox does when it shows the dropdown list, and make it
size itself there...

Still puzzled, Malcolm



Sun, 14 Nov 2004 02:32:02 GMT  
 ATL combobox - - drawing problem
The combobox takes note of the size it is created with (passed to
CreateWindow("COMBOBOX") ), and resizes itself so that it is just high
enough to fit edit box. It uses the remebered size to resize its
drop-down list. That's why I said that you need to find the place where
the combobox is created and pass a rectangle large enough to fit
drop-down list.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:

> Thanks as always for responding, Igor.

> When I size the control on the form to the size of the
> editbox, the dropdown doesn't open at runtime.  The
> underlying control (the CContainedWindow with
> the "ComboBox" style) is created (in the wizard-generated
> code) in the constructor, and there is a call to
> CContainedWindow::Create in the OnCreate handler of the
> outer control. What I have to figure out is what the
> combobox does when it shows the dropdown list, and make it
> size itself there...

> Still puzzled, Malcolm



Sun, 14 Nov 2004 03:34:34 GMT  
 ATL combobox - - drawing problem
Hello again Igor,
I have been experimenting with the suggestion you made.  
As I mentioned, the combobox is a CContainedWindow
datamember of the control class. In the control's
constructor initialization list, the CContainedWindow
constructor is called with the "combobox" window class,  
and CContainedWindow::Create called in the control's
WM_CREATE handler.  It is in this call to
CContainedWindow::Create that the rect is passed in.  I
have tried passing in an enlarged rect, but when I size
the control (on a VB form) to fit snugly around the
editbox, the droplist is clipped off, and cannot open.
Ideally I would like to have the combo respond to the
CBN_DROPDOWN message by sizing the listbox to fit the
number of items (unless the list exceeds a specified
limit, after which a scrollbar would be used). I'm
surprised the wizard-code works so poorly! If you create
an ActiveX control based on the combo style you'll see
what I mean...

   thanks, Malcolm

Quote:
>-----Original Message-----
>The combobox takes note of the size it is created with
(passed to
>CreateWindow("COMBOBOX") ), and resizes itself so that it
is just high
>enough to fit edit box. It uses the remebered size to
resize its
>drop-down list. That's why I said that you need to find
the place where
>the combobox is created and pass a rectangle large enough
to fit
>drop-down list.
>--
>With best wishes,
>    Igor Tandetnik

>"For every complex problem, there is a solution that is
simple, neat,
>and wrong." H.L. Mencken



>> Thanks as always for responding, Igor.

>> When I size the control on the form to the size of the
>> editbox, the dropdown doesn't open at runtime.  The
>> underlying control (the CContainedWindow with
>> the "ComboBox" style) is created (in the wizard-
generated
>> code) in the constructor, and there is a call to
>> CContainedWindow::Create in the OnCreate handler of the
>> outer control. What I have to figure out is what the
>> combobox does when it shows the dropdown list, and make
it
>> size itself there...

>> Still puzzled, Malcolm

>.



Sun, 14 Nov 2004 06:13:05 GMT  
 ATL combobox - - drawing problem
Did just that. A Wizard-generated ActiveX control based on combobox.
Slightly modified two methods:

 LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/,
BOOL& /*bHandled*/)
 {
  RECT rc;
  GetWindowRect(&rc);
  rc.right -= rc.left;
  rc.bottom -= rc.top;
  rc.top = rc.left = 0;
  rc.bottom += 100;
  m_ctlComboBox.Create(m_hWnd, rc, 0, WS_CHILD | WS_VISIBLE |
CBS_DROPDOWN);
  m_ctlComboBox.SendMessage(CB_ADDSTRING, 0, LPARAM("Test 1"));
  m_ctlComboBox.SendMessage(CB_ADDSTRING, 0, LPARAM("Test 2"));
  return 0;
 }

 STDMETHOD(SetObjectRects)(LPCRECT prcPos,LPCRECT prcClip)
 {
  IOleInPlaceObjectWindowlessImpl<CTestCtl>::SetObjectRects(prcPos,
prcClip);
  int cx, cy;
  cx = prcPos->right - prcPos->left;
  cy = prcPos->bottom - prcPos->top + 100;
  ::SetWindowPos(m_ctlComboBox.m_hWnd, NULL, 0,
   0, cx, cy, SWP_NOZORDER | SWP_NOACTIVATE);
  return S_OK;
 }

Works for me.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> Hello again Igor,
> I have been experimenting with the suggestion you made.
> As I mentioned, the combobox is a CContainedWindow
> datamember of the control class. In the control's
> constructor initialization list, the CContainedWindow
> constructor is called with the "combobox" window class,
> and CContainedWindow::Create called in the control's
> WM_CREATE handler.  It is in this call to
> CContainedWindow::Create that the rect is passed in.  I
> have tried passing in an enlarged rect, but when I size
> the control (on a VB form) to fit snugly around the
> editbox, the droplist is clipped off, and cannot open.
> Ideally I would like to have the combo respond to the
> CBN_DROPDOWN message by sizing the listbox to fit the
> number of items (unless the list exceeds a specified
> limit, after which a scrollbar would be used). I'm
> surprised the wizard-code works so poorly! If you create
> an ActiveX control based on the combo style you'll see
> what I mean...

>    thanks, Malcolm

> >-----Original Message-----
> >The combobox takes note of the size it is created with
> (passed to
> >CreateWindow("COMBOBOX") ), and resizes itself so that it
> is just high
> >enough to fit edit box. It uses the remebered size to
> resize its
> >drop-down list. That's why I said that you need to find
> the place where
> >the combobox is created and pass a rectangle large enough
> to fit
> >drop-down list.
> >--
> >With best wishes,
> >    Igor Tandetnik

> >"For every complex problem, there is a solution that is
> simple, neat,
> >and wrong." H.L. Mencken



> >> Thanks as always for responding, Igor.

> >> When I size the control on the form to the size of the
> >> editbox, the dropdown doesn't open at runtime.  The
> >> underlying control (the CContainedWindow with
> >> the "ComboBox" style) is created (in the wizard-
> generated
> >> code) in the constructor, and there is a call to
> >> CContainedWindow::Create in the OnCreate handler of the
> >> outer control. What I have to figure out is what the
> >> combobox does when it shows the dropdown list, and make
> it
> >> size itself there...

> >> Still puzzled, Malcolm

> >.



Sun, 14 Nov 2004 06:39:40 GMT  
 ATL combobox - - drawing problem

Igor, you are absolutely right.  What I had failed to do
all along was to add the extra size to the y-dimension in
the call to SetObjectRects. Thank you!

Perhaps I could ask your opininon on another minor
irritation. I have an ActiveX edit control, and I have
overridden the "Text" stock property. I gave the property
the DISPID_TEXT identifier in the .idl file, and the
name "Text". I have written "put_Text" and "get_Text"
methods, and everything works fine.  The only wrinkle is
that the property is always listed, by both the Test
Container and VB, as "text" (lowercase T). I've looked
through all the files, and am mystified as to what I need
to change to clean this up. Obviously I am in conflict
with some default someplace... any thoughts?



Sun, 14 Nov 2004 22:13:32 GMT  
 ATL combobox - - drawing problem
I've never seen this happen. Try completely rebuilding your control. In
VB project, unregister and reregister the TLB - it is said that VB
sometimes caches TLB definitions.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:

> Igor, you are absolutely right.  What I had failed to do
> all along was to add the extra size to the y-dimension in
> the call to SetObjectRects. Thank you!

> Perhaps I could ask your opininon on another minor
> irritation. I have an ActiveX edit control, and I have
> overridden the "Text" stock property. I gave the property
> the DISPID_TEXT identifier in the .idl file, and the
> name "Text". I have written "put_Text" and "get_Text"
> methods, and everything works fine.  The only wrinkle is
> that the property is always listed, by both the Test
> Container and VB, as "text" (lowercase T). I've looked
> through all the files, and am mystified as to what I need
> to change to clean this up. Obviously I am in conflict
> with some default someplace... any thoughts?



Sun, 14 Nov 2004 22:25:55 GMT  
 ATL combobox - - drawing problem
Hi again Igor,
   I'm mystified by this one as well -- not a big problem
though, just annoying. I'll get to the bottom of it.
   Thanks very much, again, for your help with that
combobox problem!
    All the best, Malcolm

Quote:
>-----Original Message-----
>I've never seen this happen. Try completely rebuilding
your control. In
>VB project, unregister and reregister the TLB - it is
said that VB
>sometimes caches TLB definitions.
>--
>With best wishes,
>    Igor Tandetnik

>"For every complex problem, there is a solution that is
simple, neat,
>and wrong." H.L. Mencken



>> Igor, you are absolutely right.  What I had failed to do
>> all along was to add the extra size to the y-dimension
in
>> the call to SetObjectRects. Thank you!

>> Perhaps I could ask your opininon on another minor
>> irritation. I have an ActiveX edit control, and I have
>> overridden the "Text" stock property. I gave the
property
>> the DISPID_TEXT identifier in the .idl file, and the
>> name "Text". I have written "put_Text" and "get_Text"
>> methods, and everything works fine.  The only wrinkle is
>> that the property is always listed, by both the Test
>> Container and VB, as "text" (lowercase T). I've looked
>> through all the files, and am mystified as to what I
need
>> to change to clean this up. Obviously I am in conflict
>> with some default someplace... any thoughts?

>.



Sun, 14 Nov 2004 22:53:27 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Owner Draw ComboBox - CompareItem problem - Sort Problem

2. Owner Draw ComboBox - CompareItem problem

3. Problem using owner-draw combobox

4. Problems with ATL Full control that contains a ComboBox

5. Drawing Problem in ATL

6. Help - Problems with Drawing an MFC ActiveX control inside on ATL compsoite control

7. Problems with Drawing an MFC ActiveX control inside on ATL compsoite control

8. comboBox Owner Draw -> lookup combo

9. Owner drawn .NET ComboBox

10. how can I draw a combobox in my toolbar

11. how can I draw a combobox in my toolbar

12. OWNER DRAW LISTVIEW with ComboBox

 

 
Powered by phpBB® Forum Software