CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 42
  1. #16
    Join Date
    Oct 2009
    Location
    Holland
    Posts
    201

    Re: Set Focus On Mouse Hover (MFC)

    sorry was not clear enough have to update visual studio first. afxcontrolbar.h is not there.
    I downloaded your example, compiled it and it gave on error on afx...h not avail.

    regards,

    ger

  2. #17
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Set Focus On Mouse Hover (MFC)

    What version of Visual Studio are you using? If it's the Express version, MFC isn't supported.

  3. #18
    Join Date
    Oct 2009
    Location
    Holland
    Posts
    201

    Re: Set Focus On Mouse Hover (MFC)

    Arjay

    I'm using Microsoft Visual Studio 2008 Pro Edition
    Version 9.0.30729.1 SP

    Loaded your hover project, THANKS!, worked super!
    Made a new project called TEST, same style as your hover, worked super also.

    Went back to my project, replace the bitmap button with a normal control button
    (bitmap set to false) and quess what it worked.
    Turned bitmap on again and owner draw to false
    the project is still working (but at this time the bitmap is not visible, only the caption text)
    Now the killer,
    if i turn on bitmap and owner draw, both true. bitmap is visible.
    but now the hotitemchange routine is not called.

    so the change from standard button to bitmap button is the problem, i think ....

    regards,

    ger

  4. #19
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Set Focus On Mouse Hover (MFC)

    Run the Spy++ tool and look at the styles for the button and compare them with the styles for the owner drawn button. There might be a style missing that you can add back (to get the hover message to fire).

    Also, if you installed the MFC source code when you installed Visual C++, you can step into the MFC source code during button creation to try to figure out the issue.

  5. #20
    Join Date
    Oct 2009
    Location
    Holland
    Posts
    201

    Re: Set Focus On Mouse Hover (MFC)

    I will put on my sherlock holmes goggles!
    in the meantime I made a quick HOVER project for you, the fault is
    in this project also, see att.

    regards,

    ger

    Please let me know if the attached file(s) is/are working!
    Attached Files Attached Files

  6. #21
    Join Date
    Oct 2009
    Location
    Holland
    Posts
    201

    Re: Set Focus On Mouse Hover (MFC)

    Spy++ Output:

    Normal Button Styles:
    WS_CHILDWINDOW
    WS_VISIBLE
    WS_TABSTOP
    BS_PUSHBUTTON
    BS_TEXT

    extended styles:
    WS_EX_LEFT
    WS_EX_LTRREADING
    WS_EX_RIGHTSCROLLBAR
    WS_EX_NOPARENTNOTIFY

    the bitmap button:
    WS_CHILDWINDOW
    WS_VISIBLE
    WS_TABSTOP
    BS_OWNERDRAW
    BS_BITMAP

    extended styles:
    WS_EX_LEFT
    WS_EX_LTRREADING
    WS_EX_RIGHTSCROLLBAR
    WS_EX_NOPARENTNOTIFY



    regards,

    ger

  7. #22
    Join Date
    Oct 2009
    Location
    Holland
    Posts
    201

    Re: Set Focus On Mouse Hover (MFC)

    Arjay,

    did you managed to download my sample?

    regards,

    ger

  8. #23
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Set Focus On Mouse Hover (MFC)

    Yes. It doesn't look like hover works with owner draw.

  9. #24
    Join Date
    Feb 2005
    Posts
    2,160

    Re: Set Focus On Mouse Hover (MFC)

    You have to handle hover yourself with _TrackMouseEvent() and handle the WM_MOUSELEAVE message.

  10. #25
    Join Date
    Feb 2010
    Posts
    30

    Re: Set Focus On Mouse Hover (MFC)

    just an idea not sure that it will work but if you where to encapsulate the button in another class such as a view class and use the OnMouseMove or Hover message handler

  11. #26
    Join Date
    Oct 2009
    Location
    Holland
    Posts
    201

    Re: Set Focus On Mouse Hover (MFC)

    Hi,

    I was already afraid you guys would came up with that idea….

    So can’t use HOTITEMCHANGE, will revert to mouse tracking

    Did some field work;

    Have to use: mouse-leave, mouse-move and mouse-hover
    ON_WM_MOUSEMOVE()
    ON_WM_MOUSELEAVE()
    ON_WM_MOUSEHOVER()

    Mouse-move will house the tracking event, correct?
    Mouse-hover will change the bitmap to focus
    And
    Mouse-leave will change it to normal again.

    So I need to create a new class, let’s call it HOT.
    Which type/base should I use, when I start the add class wizard?
    And
    How do I clue the class to the button using this new HOT class,
    (I think something like select control and right click, do the add option…)
    Can I use the same class (Hot) on more than one button or do
    I have to make a HOT1 and HOT2 and so on.

    Regards,

    Ger

  12. #27
    Join Date
    Feb 2010
    Posts
    30

    Re: Set Focus On Mouse Hover (MFC)

    I would use CView since it is simple and handles mouse messages and I would use it for one button if you want the action to happen just for that button and to glue it to the CView you make CView the base class

    class mybutton : public CView
    { ...
    ...

  13. #28
    Join Date
    Feb 2005
    Posts
    2,160

    Re: Set Focus On Mouse Hover (MFC)

    That's an awful lot of overhead for a button.

    In my opinion, you should just derive from CButton and make it owner draw and handle ALL the drawing yourself. Since CButton derives from CWnd, it has all the mouse handling capabilities without all the overhead of a CView.

    Somewhere I have a whole CButton owner-draw class that I used in some project or other for toolbar buttons. It handles hover and all the other button stuff. I'll see if I can dig it up.

    I haven't been following this thread too closely. What version of VS are you using?

  14. #29
    Join Date
    Feb 2010
    Posts
    30

    Re: Set Focus On Mouse Hover (MFC)

    yeah i know its alot of overhead but it was just an idea that i had along time ago to encapsilate the onmousemove action in an owner drawn button to change the bitmap,in which i had dropped the action for now and will work on it when I am doing clean up code on appearance so if you have something better I would like to know myself so please post to this thread what you were posting thanks hoxsiew

  15. #30
    Join Date
    Feb 2010
    Posts
    30

    Re: Set Focus On Mouse Hover (MFC)

    ver 6 introductory edition can't afford full version yet $900

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured