473,499 Members | 1,510 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 3688
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....but 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
1237
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...
2
1342
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...
1
23667
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...
0
2122
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. ...
1
1738
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,...
1
5722
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....
0
1771
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...
2
2811
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...
0
1616
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...
1
2687
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...
0
7128
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7169
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
7215
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...
0
5467
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,...
1
4917
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...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
661
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
294
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...

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.