473,396 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Specify a region for a ToolStripItem

I want to create a Windows.Forms.ToolStripItem 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.Control 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

Feb 6 '07 #1
6 1389
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.

Feb 7 '07 #2
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

Feb 7 '07 #3
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

Feb 9 '07 #4
Sounds good. Thanks!
Lance

Feb 9 '07 #5
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 ContextMenuStrip and call the Show method of the ContextMenuStrip in
the Button's Click event handler.

The following is a sample.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Me.ContextMenuStrip1.Show(Me.Button1, 0, Me.Button1.Height)
End Sub

Hope this helps.
If you have any concerns, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support

Feb 12 '07 #6
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

Feb 13 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Altramagnus | last post by:
I have a complicated Region object, which I need to draw the outline, but not fill How can I convert the Region object to GraphicsPath object? or How can I draw the outline of the Region object?
1
by: Jason Richmeier | last post by:
Hopefully there is an easy answer to this question since it has been bothering me all afternoon. What are the keys that are associated with ToolStripItem objects? Are they keys that allow...
6
by: =?Utf-8?B?bGpsZXZlbmQy?= | last post by:
I want to specify a custom color for disabled text that is used by a class that inherits from ToolStripProfessionalRenderer. The code would look something like this: Public Class MyRenderer...
0
by: Duracel | last post by:
Is it possible to add an owner draw combo box (or similar) as a toolstripitem in a toolstrip? thx.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.