473,564 Members | 2,768 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to remove the Focus Rectangle from Tabcontrol in VC++?

5 New Member
Hi,

I would like to get rid of the dotted selection rectangle that appears when a Tab is selected or focused. I am using the Owner Draw Mode in Windows Form.

Any ideas?

Cheers

Soorali
Feb 28 '11 #1
2 3698
Banfa
9,065 Recognized Expert Moderator Expert
Erm, if you are drawing it yourself then don't draw the focus rectangle. I look at the code handling the drawing would help.
Feb 28 '11 #2
Soorali
5 New Member
I am not drawing it.

Below is my code:

Expand|Select|Wrap|Line Numbers
  1. // tabControl1
  2.  this->tabControl1->DrawMode = TabDrawMode::OwnerDrawFixed;
  3. this->tabControl1->SizeMode = TabSizeMode::Fixed;
  4. this->tabControl1->Controls->Add(this->tabPage1);
  5. this->tabControl1->Controls->Add(this->tabPage2);
  6. this->tabControl1->Controls->Add(this->tabPage3);
  7. this->tabControl1->Controls->Add(this->tabPage4);
  8. this->tabControl1->Font = (gcnew System::Drawing::Font(L"Arial", 11.13F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
  9. static_cast<System::Byte>(0)));
  10. this->tabControl1->ImeMode = System::Windows::Forms::ImeMode::NoControl;
  11. this->tabControl1->ItemSize = System::Drawing::Size(115, 30);
  12. this->tabControl1->Location = System::Drawing::Point(-4,76);
  13. this->tabControl1->Multiline = true;
  14. this->tabControl1->Name = L"tabControl1";
  15. this->tabControl1->Size = System::Drawing::Size(495, 595);
  16. this->tabControl1->Appearance= TabAppearance::Normal;
  17. this->tabControl1->TabIndex = 0;
  18. this->tabControl1->BackColor = System::Drawing::Color::White;
  19.  
  20. // tabPage1
  21. this->tabPage1->BackColor = System::Drawing::Color::White;
  22. this->tabPage1->BackgroundImage = System::Drawing::Image::FromFile("C:\\Program Files\\Text_General1.png");
  23. this->tabPage1->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Center;
  24.             this->tabPage1->Controls->Add(this->Range1);
  25. this->tabPage1->ForeColor = System::Drawing::Color::White;
  26. this->tabPage1->Location = System::Drawing::Point(-4, 34);
  27. this->tabPage1->Name = L"tabPage1";
  28. this->tabPage1->Size = System::Drawing::Size(495, 559); this->tabPage1->Text = L" GENERAL  ";
  29.             this->tabPage1->MouseMove += gcnew System::Windows::Forms::MouseEventHandler(this, &Form2::tabPage1_MouseMove);
  30. this->tabPage1->Click += gcnew System::EventHandler(this, &Form2::tabPage1_Click);
  31. this->tabPage1->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form2::tabPage1_MouseDown);
  32. this->tabPage1->MouseUp += gcnew System::Windows::Forms::MouseEventHandler(this, &Form2::tabPage1_MouseUp);
  33.  
  34. //Not including code here for all the other tab pages and the controls within each Tabpage
  35. // Below is the Code for the Draw Item
  36. private:void tabControl1_DrawItem( Object^ sender, System::Windows::Forms::DrawItemEventArgs^ e )
  37. {
  38.  
  39. System::Drawing::Rectangle destRect = System::Drawing::Rectangle(0,-20,550,70);  
  40. SolidBrush^ FillBrush = gcnew SolidBrush(Color::Black);// Background Color
  41. SolidBrush^ TextBrush = gcnew SolidBrush(Color::FromArgb(178,178,178));        // Text Color
  42. StringFormat^ sf = gcnew StringFormat();// String Format
  43. sf->Alignment = StringAlignment::Center;//Vertical Alignment
  44. sf->LineAlignment = StringAlignment::Center;
  45. // Horizontal Alignment
  46. e->Graphics->FillRectangle(FillBrush,0,0,550,100);
  47. tabArea1 = tabControl1->GetTabRect(tabPage1->TabIndex); // Gets the Selected tab area defined by its TabIndex.Returns a Rectangle to tabArea.
  48. tabTextArea1 = tabControl1->GetTabRect(tabPage1->TabIndex);
  49. tabArea2 = tabControl1->GetTabRect(tabPage2->TabIndex); tabTextArea2 = tabControl1->GetTabRect(tabPage2->TabIndex);
  50. tabArea3 = tabControl1->GetTabRect(tabPage3->TabIndex); tabTextArea3 = tabControl1->GetTabRect(tabPage3->TabIndex);
  51. tabArea4 = tabControl1->GetTabRect(tabPage4->TabIndex); tabTextArea4 = tabControl1->GetTabRect(tabPage4->TabIndex);
  52. if (tabControl1->SelectedTab==tabPage1)
  53. {
  54. System::Drawing::Font^ font1 = gcnew System::Drawing::Font( "Arial",12.13f, System::Drawing::FontStyle::Bold );// Defines Font face, size, style
  55. System::Drawing::Font^ font2 = gcnew System::Drawing::Font( "Arial",11.13f, System::Drawing::FontStyle::Regular );// Defines Font face, size, style
  56. System::Drawing::Font^ font3 = gcnew System::Drawing::Font( "Arial",11.13f, System::Drawing::FontStyle::Regular );
  57. System::Drawing::Font^ font4 = gcnew System::Drawing::Font( "Arial",11.13f, System::Drawing::FontStyle::Regular );
  58. e->Graphics->DrawString(tabControl1->TabPages[tabPage1->TabIndex]->Text, font1, TextBrush, tabTextArea1, sf);e->Graphics->DrawString(tabControl1->TabPages[tabPage2->TabIndex]->Text, font2, TextBrush, tabTextArea2, sf);e->Graphics->DrawString(tabControl1->TabPages[tabPage3->TabIndex]->Text, font3, TextBrush, tabTextArea3, sf);
  59. e->Graphics->DrawString(tabControl1->TabPages[tabPage4->TabIndex]->Text, font4, TextBrush, tabTextArea4, sf);
  60.             }
  61.  
  62. if (tabControl1->SelectedTab==tabPage2)
  63. {
  64. System::Drawing::Font^ font1 = gcnew System::Drawing::Font( "Arial",11.13f, System::Drawing::FontStyle::Regular );// Defines Font face, size, style
  65. System::Drawing::Font^ font2 = gcnew System::Drawing::Font( "Arial",12.13f, System::Drawing::FontStyle::Bold );// Defines Font face, size, style
  66. System::Drawing::Font^ font3 = gcnew System::Drawing::Font( "Arial",11.13f, System::Drawing::FontStyle::Regular );
  67. System::Drawing::Font^ font4 = gcnew System::Drawing::Font( "Arial",11.13f, System::Drawing::FontStyle::Regular );
  68. e->Graphics->DrawString(tabControl1->TabPages[tabPage1->TabIndex]->Text, font1, TextBrush, tabTextArea1, sf);e->Graphics->DrawString(tabControl1->TabPages[tabPage2->TabIndex]->Text, font2, TextBrush, tabTextArea2, sf);
  69. e->Graphics->DrawString(tabControl1->TabPages[tabPage3->TabIndex]->Text, font3, TextBrush, tabTextArea3, sf);
  70. e->Graphics->DrawString(tabControl1->TabPages[tabPage4->TabIndex]->Text, font4, TextBrush, tabTextArea4, sf);
  71.             }
  72.  
  73. // Same for Tabpage3 and Tabpage4
  74.  

As you can see there is no where that I am drawing a focus rectangle....bu t it definately shows up on each Tab Header

Thanks for your help.

Cheers
Soorali
Feb 28 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1241
by: Steve | last post by:
VS2003 .NET with C# I have a tree view on page 1 of a tabcontrol. When the user right clicks a node they get a popup context menu which gives them 2 options. When they select an option, it builds page 3 of the tab control and changes the page to this Page3. However the context menu remains popped up still over the top of Page3 until you...
2
1346
by: Matthias S. | last post by:
Hi there, I've got a page with two frames. The top frame hosts a menu, which is simply a collection of text-links. Whenever a text-link in the top frame gets selected, the bottom-frame is filled with the appropriate contents. Unfortunately, after clicking the link, a focus-rectangle stays around the selected text-link. Is there a way to get...
1
23675
by: Arfan | last post by:
hi, By default i have set focus on one particular field when the page loads. In one condition when the page loads i want to remove focus from that field of the form. Is there any function in javascript that allows to remove focus from field? Regards, Arfan
0
2134
by: Stephen Bedford | last post by:
I am developing an application that is primarily keyboard not mouse driven. Navigation is very difficult within some controls (list boxes, radio groups etc) unless the focus rectangle is visible. When an application starts the focus rectangle for a control is never visible and only becomes visible once the TAB key is pressed. After that...
1
1743
by: Sandy | last post by:
writing a data to open (.txt) notepad file in desktop from vc++... then small rectangle are coming in the file "\n" is also not working int iLength = (int)::SendMessage(hEdit, WM_GETTEXTLENGTH, 0, 0); ::SendMessage(hEdit, WM_GETTEXT, iLength+1, (LPARAM)textData); CString temp = textData; temp += "\n"; temp += "MFC";...
1
5731
by: Jason | last post by:
I am creating my own tab control in vb.net. I am inheriting System.Windows.Forms.TabControl. I want to provide a property that disables or enables the focus rectangle being drawn on the tabs. Setting the DrawMode to OwnerFixed and adding the drawing methods in overrides OnDrawItem doesn't seem to do it. The focus rectangle is drawn no...
0
1777
by: Brian A. Cline | last post by:
I have a SplitContainer that holds a TreeView and ListView. When using the splitter to resize them, a focus rectangle is shown during and after the resize event. Is there any way to prevent this? I have already tried setting the SplitContainer's TabStop property to false but it had no effect on the aforementioned behavior. Thanks, Brian...
2
2818
by: neihc2 | last post by:
Hi, For some pages I'm styling, the focus rectangle around a link appears just fine in Firefox. However, they are not appearing at all in IE. I don't think there's anything in my css file that gets rid of the focus rectangles: a:link{ color: #3366CC; }
0
1623
by: vsrprasad16 | last post by:
Hi All, I am implementing a notification form similar to outlook email notification. my application call this notification form from a dll. this dll includes a form class and this dll has some object value to display the contents on form. i am filling the form with the object before "form.show." form has some timer to implement hide and...
1
2700
by: john ciriello | last post by:
I created a form and put a button and a label on it. I set the tabstops to false. When I first run it I can click the button and there is no focus rectangle. Which is what I want. However, if I press the tab key nothing initially seems to happen, I know nothing should because I set the tabstop to false, but to my surprise, when I then click...
0
7583
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7642
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.