Specify a region for a ToolStripItem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?bGpsZXZlbmQy?=

    #1

    Specify a region for a ToolStripItem

    I want to create a Windows.Forms.T oolStripItem that behaves as if it is an
    ellipse (e.g., similar to the round Office Button in Office 2007). Drawing
    the item is no problem, but I also want to prevent the item from reponding to
    the mouse unless the mouse is within the elliptical bounds of the item. For
    a Windows.Forms.C ontrol this can be done by setting the Region property, but
    as far as I can tell there no such property for a ToolStripItem.

    Thanks for any help!
    Lance

  • Linda Liu [MSFT]

    #2
    RE: Specify a region for a ToolStripItem

    Hi Lance,

    Yes, you're right. Only Control class has the Region property.
    ToolStripItem is derived from Component class, so it doesn't have a Region
    property.

    I have spent several hours researching on this problem, but unfortunately I
    haven't found a solution yet.

    I suggest that you use a Button instead of ToolStripItem. You may paint the
    button by handling its Paint event and then set the button's Region
    property.

    FYI, you may visit the following link to get a sample code.

    'Control.Region Property'
    http://msdn2.microsoft.com/en-us/lib...control.region
    .aspx

    Hope this helps.
    If you have any concerns, please feel free to let me know.


    Sincerely,
    Linda Liu
    Microsoft Online Community Support

    =============== =============== =============== =====
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscripti...ult.aspx#notif
    ications.

    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscripti...t/default.aspx.
    =============== =============== =============== =====

    This posting is provided "AS IS" with no warranties, and confers no rights.

    Comment

    • =?Utf-8?B?bGpsZXZlbmQy?=

      #3
      RE: Specify a region for a ToolStripItem

      Hi Linda,

      Thank you so much for your time and your suggestion. Using a Button is a
      good idea, but I would prefer to use a class that inherits from ToolStripItem
      if at all possible in order to maintain internal consistency. Also, it might
      be difficult to have a Button behave exactly like a ToolStripItem (with
      DropDown items, etc.).

      If it is not possible to associate a region with a ToolStripItem, then is
      there some way to prevent the ToolStripItem from thinking that the mouse is
      has entered it? I would guess that there is some method (probably either in
      ToolStrip or ToolStripItem) where the hit test logic is being performed. If
      it is possible to override that method then I could include custom logic for
      handling elliptical ToolStripItems.

      Thanks again,
      Lance

      Comment

      • Linda Liu [MSFT]

        #4
        RE: Specify a region for a ToolStripItem

        Hi Lance,

        In fact, I have spent some time researching on how to prevent the
        ToolStripItem from being focused when the mouse is not located in the
        'region'. But unfortunately, I haven't worked it out yet.

        I will go on research and will get the result back to you ASAP.

        I appreciate your patience.


        Sincerely,
        Linda Liu
        Microsoft Online Community Support

        Comment

        • =?Utf-8?B?bGpsZXZlbmQy?=

          #5
          RE: Specify a region for a ToolStripItem

          Sounds good. Thanks!
          Lance

          Comment

          • Linda Liu [MSFT]

            #6
            RE: Specify a region for a ToolStripItem

            Hi Lance,

            We could subscribe the MouseMove event of a ToolStripItem and write our hit
            test logic in the event handler. However, the problem is that it may not
            easy to implement hit test logic since the 'region' is just a graph we draw.

            What's more, it is may not easy to get the area only within the 'region'
            focused when the mouse is located in the 'region', either.

            I still suggest that you use a Button. As for the drop down items, you may
            use ContextMenuStri p and call the Show method of the ContextMenuStri p in
            the Button's Click event handler.

            The following is a sample.

            Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
            System.EventArg s) Handles Button1.Click
            Me.ContextMenuS trip1.Show(Me.B utton1, 0, Me.Button1.Heig ht)
            End Sub

            Hope this helps.
            If you have any concerns, please feel free to let me know.


            Sincerely,
            Linda Liu
            Microsoft Online Community Support

            Comment

            • =?Utf-8?B?bGpsZXZlbmQy?=

              #7
              RE: Specify a region for a ToolStripItem

              Hi Linda,

              Ok, I suspect that I will be able to implement some kind of workaround.
              Thanks for your help and for the suggestion of using a Button.

              Lance

              Comment

              Working...