How to Paint a little square over the X close button on a TabPage.

How can we get C# (VS10) to display a little square on a TabPage close button when the user mouses over the tab on that TabPage.
Examples include that tab pages in Visual Studio. When we mouse-over the X in the upper right corner of any tab, a little square is painted over the X.
How can we do something similar in our programs using C#?
I’m using the following code to display an X in the upper right corner of the tab on a TabPage. This now only needs the ability to paint a square over the X when the user mouses over the X.
// Using statements.
using System.Drawing;
using System.Windows.Forms;
// Accomplished during initialization.
mTabControlMain.DrawMode = TabDrawMode.OwnerDawFixed;
mTabControlMain.DrawItem += new DrawItemEventHandler(TabControlMain_DrawItem);
mTabControlMain.MouseDown += new MouseEventHandler(TabControlMain_MouseDown);
//  Accomplished when creating a new tab page.
TabPage newTabPage = new TabPage(“List “ + (mTabConrolMain.TabCount-1).ToString() + “    “;
newTabPage.TooTipText = “Close”;
mTabControlMain.TabPages.Insert(mTabControlMain.TabPages.Count - 1, newTabPage);
// Called when the tab page needs to be drawn/re-drawn.
private void TabControlMain_DrawItem(object sender, DrawItemEventArgs e)
    TabControl tabControl = (TabControl)sender;
    Font font = new Font(e.Font, FontStyle.Bold);
    if(e.Index >= tabControl.TabCount)
        return;
    Rectangle rect = tabControl.GetTabRect(e.Index);
    e.Graphics.DrawString(“X”, font, Brushes.SlateGray, e.Bounds.Right-15, e.Bounds.Top+4);
    e.Graphics.DrawString(mTabControlMain.TabPages[e.Index].Text, font, Brushes.Black, e.Bounds.Left), e.Bounds.Top+4);
// Called when the user clicks the mouse button on a tab page.
private void TabControlMain_MouseDown(object sender, MouseEventArgs e)
    for(int i=0; i<mTabControlMain.TabPages.Count; i++)
        Rectangle rect = mTabControlMain.GetTabRect(0);
        Rectangle closeButton = new Rectangle(rect.Right-15, rect.Top+4, 9, 7);
        if(closeButton.Contains(e.Location)
            mTabConrolMain.TabPages.RemoveAt(i);
            break;
Ideas?
Thanks  :-)
-Mike

You mean like windows 7 behaviour where the red area appears behind a white X as you mouse over?
I would do that by putting the X in a button.
You then have something concrete there to work with.
Change the background color on mouseenter and again on mouseleave.
Otherwise you'd have to work out whether the mouse was over that X you drew on there.  And I think that'd be difficult.
Or am I missing something?
Why are you using Drawstring to draw an X on there?
By the way, you should really be asking windows forms questions in the windows forms forum.
It's in your interest as you ought to get more windows forms developers hang out there.
In theory anyhow.
Hope that helps.
Technet articles: Uneventful MVVM;
All my Technet Articles

Similar Messages

  • When I am turning my iphone off, while sliding it makes white little square in the final part of sliding. Is this a bug or only I have this problem?

    When I am turning my iphone off, while sliding it makes white little square in the final part of sliding. Is this a bug or only I have this problem?

    Please look over the System Requirements for Lion:
    Mac OS X Lion System Requirements
    In order to install Mac OS X 10.7 you will need:
    Intel Core 2 Duo, Core i3, Core i5, Core i7, or Xeon processor
    2GB of RAM (4GB recommended)
    Mac OS X 10.6.6 or later with the Mac App Store installed( 10.6.8 Recommended)
    At least 4GB of additional disk space to accommodate the download, but more is obviously recommended

  • How do I view a website over the full screen while using the 6 plus in horizontal mode

    How do I view a website over the full screen while using the iPhone 6 plus in horizontal mod?

    You said you found several domain.sites files.
    iWeb uses one at a time to create webpages.
    Your webpages, your site, has disappeared with MobileMe.
    You have to find a new host and publish there.
    But to publish you need one of your domain files.
    Try iWebSites to open them :
    http://www.wyodor.net/_Demo/Aptana/iWebSites.html

  • How to bring back the black dot on the red close button for edited/unsaved files?

    I've ticked the box for "Ask to keep changes when closing documents" System Preferences / General. I'm operating within Mac OS 10.8.4 (Mountain Lion).
    When I make changes to an open file in most every program, a black dot appears on the red close button in the top-left corner of the file's window. This convention goes back a decade to early Mac OS X, as I recall.
    However, I don't see this behavior in a few applications lately, such as Xcode 4.6.3 or QuickTime Player 10.2.
    Anyone know how to bring this functionality back?
    Thank you.

    Nobody knows? Not even administrators?
    Please it would be really nice to have help on that to take all the benefit of the remote app.
    Thank you very much in advance.

  • Rewards - I have plenty of points and my account is in good standing. When I hover over the Place Bid button, a hand appears but I can't actually bid on anything. What's the deal?

    Rewards - I have plenty of points and my account is in good standing. When I hover over the Place Bid button, a hand appears but I can't actually bid on anything. What's the deal?

        I'm glad you are taking advantage of Smart Rewards, holla2012. When attempting to place a bid, have you noticed if the time on the item is near expiration? Have you tried clearing your cookies and cache on your browser?
    AndreaS_VZW
    Follow us on Twitter @VZWSupport

  • The X close button doesn't show on Tabs in 3.6.3. How do I get them back?

    The X close button stopped showing on Tabs when I upgraded to version 3.6.3. How do I get them back?
    == This happened ==
    Every time Firefox opened
    == latest version 3.6.3 downloaded on May 28th - 29th..

    I had the home page set to "about:blank" when I noticed that the x was missing. I then clicked on "Restore to Default", restarted and then selected "Show a blank page" - Restarted again and this time it worked, except that there is no x when there is only one tab. As soon as a second tab opens, an x suddenly appears on all the tabs. Keep in mind that I also updated the Walnut theme and all other add-ons. Not entirely happy with this niggle, but I can live with it. Version 3.6.3 is faster and that makes up for it.

  • HT201401 How can i reset my iphone if the Sleep/Wake button does not work?

    My camera shuts off every time that I try to take a picture. I would like to reset my IPhone in order to try and solve the problem. My Sleep/Wake button does not work.
    How can I reset my IPhone without the Sleep/Wake Button working?
    Thanks for the help.

    When pressing the sheep/wake button, the iPhone's screen is not turned off if on and does not turn on if off, and pressing and holding the sleep/wake or on/off button does not bring up slide to power off?
    And you can't do a reset by pressing and holding the home button and the sleep/wake or on/off button simultaneously until you see the Apple logo and then release?
    If so and there is no change after restoring the iPhone with iTunes, make an appointment at an Apple store if there is one nearby since more than likely there is a hardware problem.

  • I have these black boxes surrounding things, e.g., there is a black box around the red "close" button on the upper left corner of this page.  There is also an oblong black box

    Hi - I'm not only having trouble waking up my MBP from sleep and having to restart repeatedly which is a pain in itself, but now when it restarted, I have these black boxes surrounding things, e.g., there is a black box around the red "close" button on the upper left corner of this page.  There is also an oblong resizable black box sitting on top of anything.  The content changes depending on the actions I take.  Right now it says, "You are currently on a close button.  To click this button, which closes the current window, press Control-Option-Space."  Right now I'm open in Firefox, but it doesn't matter if only Finder is open, it's still there.  I've tried closing all my applications and restarting and I also reset the PRAM.  It won't go away.  It's probably something simple, but I don't know how to get rid of it.  Any suggestions are welcome.
    Thanks,
    Janet

    Thanks so much.  I saw this on "desktop strangeness" immediately after I posted and tried to retract my question.  It worked perfectly.  I'm not sure how VoiceOver got turned on unless something happened when I was trying to wake up the computer.  I open the lid and it flashes whatever is open and then the screen goes black and I can't wake it up.  Still looking for the resolution to this.

  • [Android][Other] the "X" {close} button not right after the " " {next} button in lockscreen

    do you listen to spotify while commuting?Well, wouldn't you wisht that the spotify lockscreen player buttons would be bigger and that the "X" {close} button would not be really close in space to the ">>" {next}  button. Well I would.Its frustrating when I'm listening to a song I don't like, while im driving, then i click the next button but i accidentally click the close button and the music stop. Now I can't listen to my music because I'm driving and now it involves unlocking my phone and going back to spotify while i'm driving /; not so safe.  Attechment shows a comparison between Spotify and Google Music in the lockscreen 

    You mean like windows 7 behaviour where the red area appears behind a white X as you mouse over?
    I would do that by putting the X in a button.
    You then have something concrete there to work with.
    Change the background color on mouseenter and again on mouseleave.
    Otherwise you'd have to work out whether the mouse was over that X you drew on there.  And I think that'd be difficult.
    Or am I missing something?
    Why are you using Drawstring to draw an X on there?
    By the way, you should really be asking windows forms questions in the windows forms forum.
    It's in your interest as you ought to get more windows forms developers hang out there.
    In theory anyhow.
    Hope that helps.
    Technet articles: Uneventful MVVM;
    All my Technet Articles

  • Why can't I cloes a webpage with the top close button V29.0.1

    Ever since updating to version 28.0.1 I can no longer use the top close button to close a website. I have to go to the site in the task bar and then close it or close Firefox with task manager!

    '''''[https://support.mozilla.org/en-US/kb/troubleshoot-firefox-issues-using-safe-mode Start Firefox in Safe Mode]''''' {web link}
    While you are in safe mode;
    Press the '''<Alt>''' or '''<F10>''' key to bring up the tool bar.
    Followed by; Windows; '''Tools > Options''' Linux; '''Edit > Preferences'''
    Mac; ''application name'' '''> Preferences'''
    Then '''Advanced > General.'''
    Look for and turn off '''Use Hardware Acceleration'''.
    Poke around safe web sites and see if there is still a problem. Then restart.

  • How can I download a file over the internet from a WebDAV server?

    I am trying to download a file over the internet from a WebDAV server. I've tried doing it with Datasocket as suggested in these articles,
    <a href="http://digital.ni.com/public.nsf/websearch/f3cc5f7e60a75cb2862567e700696abf?opendocument">Retrieving an Unformatted Text File via FTP or HTTP Using DataSocket</a>
    <a href="http://digital.ni.com/public.nsf/websearch/4FA09E7B3674DA34C1256BD400555C41?OpenDocument">Download a Text File from a Password Protected URL Using DataSocket</a>
    but all I get is error 1181 (protocol unrecognized by Datasocket).
    I know I have the URL correct, because I can put it into a web browser and it works fine - I can download the file manually.
    But I want to have a LabVIEW program do the download automatically.
    I have the internet toolkit, but don't have the foggiest clue how to use it, and am using LabVIEW 7.1
    I am a bit out of my depth here, so any advice welcome.
    Regards,
    Mark.

    MIG,
    What is the URL to the website? Is it an FTP site? The articles you referenced are for specific transfer protocols. If the stie you're trying to get to doesn't follow these protocols, then you'll get the error you're seeing. You may have to use ActiveX to control IE and download the files programmatically.
    Chris C
    Chris Cilino
    National Instruments
    LabVIEW Product Marketing Manager
    Certified LabVIEW Architect

  • How to Avoid another Black X Over the Battery?

    Forgive me if this is already a topic. If so, please direct me to the correct thread.
    I was recently working on my Late 2010 Macbook Pro 13 inch laptop when it just shutdown. It took about 5 minutes to start back up, and I immidatley noticed that there was a black X over the battery symbol, and the fan was running at a full (and a very loud) speed. I shut it down and plugged in the power cord, which only glowed very faintly.
    After some googleing, I figured out what was wrong and fixed it using a different thread. I basically had to restart the SMC. The thread I used is here: http://support.apple.com/kb/HT3964
    However, even though it helped me fix the problem, it didn't answer any questions. So, if you could please help me. Why did this happen to my Mac? How did resetting the SMC fix the problem? How can I avoid this problem in the future? Is this an issue with the battery, or is it something else?
    I want to know what I did to make this happen and how to avoid it in the future, if it's possible. All input is appreciated. I am not very computer savy when it comes to the inner workings, so I'm hoping someone smarter than me can help me understand what just happened with my computer.
    Thanks!

    An SMC reset can 'fix' several battery issues -
    A portable Mac doesn't appear to respond properly when you close or open the lid.
    The computer sleeps or shuts down unexpectedly.
    The battery does not appear to be charging properly.
    The MagSafe power adaptor LED doesn't appear to indicate the correct activity
    - but I've no idea why you had your problem in the first place, so I can't tell you how to avoid it in the future. Maybe you let your battery drain completely down? I don't know - but now you know the 'fix' for it should it happen again.
    Clinton

  • How do I share a folder over the internet with Mountain Lion server?

    I am new to using formal servers.  In Snow Leopard I was able to use web sharing to serve a small website and if I wanted to share a folder with someone I would  just provide the person I wanted to share a file with the path to the file inside the sites directory.  With Mountain Lion this functionality was removed from the sharing section of system preferences.
    I purchased mountain lion server and was able to restore the website serving ability, but I haven't been able to figure out how to share a folder.  I am still looking over what documentation I can find, but for the most part it just tells me to set up the services without telling me how.  Any assistance would be helpful.  Networking is not my area of expertise.
    Best Regards,
    David Finell

    I purchased server to assist with this as I am unfamiliar with the command line protocols for using apache.  Because of the UNIX architechture of OSX and I presume apache, I am uncomfortable using the command line for fear of causing serious problems.
    Unfortunately, the documentation that I have seen for mountain lion server is wanting in either its completeness or layout/functionability.  To summarize the server instructions as I understand them.  It just says to configure it and my system to meet my requirements without telling me how.
    I am confident that both the apache command line and server are capable of accomplishing what I was able to do before under snow leopard.  I just haven't figured out how.
    I was able to provide a link to family and clients like http://ipaddress/~user/folder
    This no longer works.

  • How to Enable Wake On Lan over the Internet??

    Hi, I am using RV220W with the latest firmware, I want to make "Wake on LAN" work for my NAS, I found the following description on Internet:
    "If you wish to use Wake On Lan over the internet you will need to set up your destination firewall/router to allow "Subnet Directed Broadcasts". Most routers and firewalls disable this option by default.
    You will then need to allow traffic through on your firewall/router on a specific port. The choice of ports is up to you."
    So how can I enable "Subnet Directed Broadcasts" on RV220W??
    Thanks.
    Raymond

    Hi Jasbryan,
    If RV220W doesn't forward UDP to a broadcast address, could you ( i.e. Cisco) provide a tools for sending WOL Magic Packet to the LAN on Router Device Manager page?
    I see many routers also provide this tools from their manager page.
    Thanks.
    Raymond

  • Can someone point in the right direction for how to make a multiplayer game over the internet

    Hello,
    I am looking into making a game where two people who can be in different places would log on to the app, log in and can play - i.e. they would be connected over the internet. I'm looking for a hint on what is the direction to take and which technologies.
    For example is there a best practice for example if you make an app with DirectX and C++, and you use some kind of web service or something? or is it easier using C# and XNA? just looking for some pointers in the right direction. I have played around
    with DirectX, far from proficient but have familiarity, I have no experience with XNA but hear it's less hardcore and easier going. I'm particularly interested in what the best way to connect over the internet.
    Thanks

    What you are asking is very complicated and one of the more difficult things you can do in gaming. I'd strongly recommend you start smaller to learn and then move up to multi-player games as your skills grow.
    From the multiplayer client perspective it doesn't really matter which technology you use. You can write a multiplayer game in any engine or technology that can talk to the network. Choose the client technology that you are most adept at and interested in
    and learn it. You can go straight to DX, use a third party library such as Monogame (XNA isn't supported for Windows Store apps), or a complete game engine such as Unity. Once you can write a decent one-player game you'll have the foundation to start on to
    build a two-player game.
    At that point you'll need to define the problem much more specifically. As you state it, it is really wide open. How do you want the users to connect? Directly machine to machine? Matched through a web server but running client side? Connecting to a game
    running on a remote server? Something else?
    The network connection itself is probably fairly straightforward, but where to connect and how to manage that can be difficult. You'll have to decide what properties you want. Is this an action game where responsiveness is important or
    a turn based game where timing is less relevant?
    Are the players connecting locally or completely remotely? If the former then they can probably connect directly over the local network (NFC is great here). If the latter then they probably will need to connect to a matchmaker service to avoid firewalls.
    This can get very complex, but there are existing solutions you can use rather than writing your own.
    --Rob

Maybe you are looking for

  • How do i get the lines off of my cracked phone?

    MY PHONE IS CRACKED BABLY AND IT HAS GOTTE WORSE AND I DONT WANT TO GET THE SCREEN REPLACE NOT NOW CAN ANYONE HELP ME FIND A WAY TO DO IT FREE OF PRICE FIRST MY DAD WAS GOING TO GET THE CREEN REPLACE BUT I WANT TO DO IT AN EASY WAY WHERE I CAN DO SOM

  • What's with the new user acct after using Migration Asst? Can I merge users or should I even care?

    I used Migration Assistant to bring over photos and music from my PC and a new user account was created on my iMac. I expected this since the instructions on the Apple site mentioned this would happen. But now that it's all over and done it really an

  • Network preferences: symbol and text swapped

    Hello, On our new MacBook Pro with Mavericks the Wi-Fi symbol and Ethernet symbol are swapped with the text. After the word Wi-Fi the icon Ethernet is displayed and after the word Ethernet the icon Wi-Fi is displayed. How can this be put in correct o

  • Dreamweaver CS6 crashes shortly after opening any document

    I'm using a new install of CS 6 on OS X 10.7.4, and the program opens and closes fine unless I open a document - I've tried HTML, PHP, and CSS. Any time between immediately and about 1 minute thereafter, DW crashes. It's in either code or split view.

  • Project Plan Implementation

    Hi all, Some body has sent me this URL to see how we plan the project ,but its not opening in my system. I dont know why, can any one open this and send me the information Please...... Project Plan : http://help.sap.com/bp_biv270/documentation/BWProj