Custom CComboBox
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Thread: Custom CComboBox

  1. #1
    Join Date
    Feb 2005
    Location
    Indiana
    Posts
    261

    Custom CComboBox

    Well I posted about my problem while back and got no help so I started researching and I'm getting where I need to get.

    The problem I'm having and maybe cause it's getting late but I have the ComboBox with an 'x' on the button and now I have it where it doesn't drop down the listbox when the button is pressed. But it drops it down when you click the CEdit ctrl of the ComboBox. I do have a handle to the Edit ctrl of the combo. And I have it setup where you can type by overriding the WM_LBUTTONDOWN and not calling the base class but when the mouse is over the CEdit control it still loads the I-Cursor until I leave the CEdit.

    I tried overriding the WM_MOUSEMOVE and calling SetCursor and it works but it flashes too much and is irritating. So I'm sure there is an easy answer to this does anyone know it is the question?

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,301

    Re: Custom CComboBox

    Quote Originally Posted by left1none View Post
    Well I posted about my problem while back and got no help so I started researching and I'm getting where I need to get.
    Could you provide a link to this thread where you already "posted about my problem ..."?
    Otherwise your current description is absolutely unclear!
    Victor Nijegorodov

  3. #3
    Join Date
    Feb 2005
    Location
    Indiana
    Posts
    261

    Re: Custom CComboBox

    Quote Originally Posted by VictorN View Post
    Could you provide a link to this thread where you already "posted about my problem ..."?
    Otherwise your current description is absolutely unclear!
    I have solved many of the issues in the original post thought but I'll post the URL so you can see. The problem at hand is the Cursor and keeping it an arrow.

    http://www.codeguru.com/forum/showth...lass+CCombobox

  4. #4
    Join Date
    Feb 2005
    Location
    Indiana
    Posts
    261

    Re: Custom CComboBox

    Is it possible at all? I mean I know it has to be.

  5. #5
    Join Date
    Apr 1999
    Posts
    3,585

    Re: Custom CComboBox

    I'm not sure if this will work, but, have you tried subclassing the embedded CEdit control and handling WM_SETCURSOR?
    Gort...Klaatu, Barada Nikto!

  6. #6
    Join Date
    Feb 2005
    Posts
    2,160

    Re: Custom CComboBox

    Since you want to disable the I-beam cursor, can I assume you don't want the text to be editable and are disabling its editability? Why not use a Drop List style so that the main part of the combo is a static rather than an edit?

  7. #7
    Join Date
    Apr 1999
    Posts
    3,585

    Re: Custom CComboBox

    To follow Hoxsiew's theme, you can make the embedded CEdit read-only if you don't want to allow edits. That would change the cursor.
    Gort...Klaatu, Barada Nikto!

  8. #8
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    3,782

    Re: Custom CComboBox

    Custom (or owner) drawing is all nice and dandy as long as what you're trying to do is 'within reason' and you aren't trying to change too much of the behaviour of the control you're trying to customize.

    The description on the other page isn't entirely clear, but I'm getting the impression you're not really trying to get a custom combobox. But what you really are looking for is a display-text-box-with-a-button (?).
    - you don't want the drop down
    - you don't want the editing part of the combobox
    all you want is a combined readonly edit with button.

    When you want to customize a windows control, you really need to look for a control (or a combination of controls) that already DOES what you want, not one that LOOKS more or less like what you want.

    You can 'easily' mold the looks, but changing behaviour is harder and more specifically a lot harder if you want your program to work with future versions of windows without having to do extensive rewrites.

    If what you want is indeed a displaybox-with-a-button I'd suggest making a custom control, rather than trying to customise an existing "looks somewhat like what I want" standard control.

    In this case, the edit-with-a-button is fairly easy to do by subclassing an editbox and make it have a child button. or even just have an editcontrol and a separate button that have interoperability.

  9. #9
    Join Date
    Feb 2005
    Location
    Indiana
    Posts
    261

    Re: Custom CComboBox

    Let me try and help you help me here.

    Quote Originally Posted by Mike Harnad View Post
    To follow Hoxsiew's theme, you can make the embedded CEdit read-only if you don't want to allow edits. That would change the cursor.
    Well I actually tried this before, making the edit read only and it still changes the cursor to the I-beam it just doesn't let you edit the contents.

    Quote Originally Posted by OReubens View Post
    If what you want is indeed a displaybox-with-a-button I'd suggest making a custom control, rather than trying to customise an existing "looks somewhat like what I want" standard control
    well do need a drop-down. See this will be used to manage several windows (3 different documents actually and many possible open documents of each doc template). So basically the edit control will hold the currently viewed doc and when you click the edit it will drop down a list of all other open documents that you will be able to click on to bring that window to the front or you can close them from there.

    Now I did think maybe the easier and better way was to use a CEdit with a CButton and when you click it it will drop a CMenu. Does this make more sense? Maybe so cause really I have thought about not using the CListBox and using a CMenu on this one actually. I'd love to hear more about this.

    Quote Originally Posted by Mike Harnad View Post
    I'm not sure if this will work, but, have you tried subclassing the embedded CEdit control and handling WM_SETCURSOR?
    Wow thanks Mike, I already have it subclassed but never dawned on me to try that. I will venture a guess this will work though. But still interested in hearing about using a CEdit with a CButton still as well. I have learned alot about the CComboBox though. Great learning experience and thank you all for all your help.

  10. #10
    Join Date
    Feb 2005
    Location
    Indiana
    Posts
    261

    Re: Custom CComboBox

    Quote Originally Posted by Mike Harnad View Post
    I'm not sure if this will work, but, have you tried subclassing the embedded CEdit control and handling WM_SETCURSOR?
    This does in fact work I just tried it. But still curious about using the CEdit instead. The other things I have to handle are...

    1) I have to draw 'x' button (close button) on each item that is in the CListBox (or CMenu if I go that route.

    2) I have to capture the button click when the closed button is clicked (Already works on the CEdit)

    3) it will display the CMDIChildWnd title for the text in the CEdit and in the CListBox (or CMenu) but if the window caption is too large it must only display part of it then using "..." to declare there is more to it

    4)Must notify parent when it has changed (should be easy enough)

    5) all items must be kept circular. So like there will be an array of Windows titles kept. Say the #2 item of the array is in the CEdit box. The #1 item must be at the bottom of the CListbox(CMenu). If a user clicks the #4 item (which would actually be the #2 item in the list in this case) then it will be in the CEdit and the #5 will be the first in the drop down and #3 will be last #2 second to last and so on....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center