Link to home
Start Free TrialLog in
Avatar of moshei
moshei

asked on

URGENT !!! CTabCtrl creation without border

How can i create a ctabctrl without a bourder.
I have painted the CtabCtrl with black and i want the tab
items bourder or to be black too , or not to be created
as a border tabcontrol . How Can it be done or the border
to be black ???
Avatar of duneram
duneram

Hi,

In windows, every control in itself is a window.  Keep that in mind and you will always be able to find solutions.  Every window has the ability to have Window Styles.  You can find these styles in the include file:   winuser.h    In that file you will find a style named
WS_BORDER.

All of the window styles pretty much start with WS_   There are some extended styles you can use too like  WS_EX_TRANSPARENT   stuff like that.

With experimentation at run time you can modify the appearance of a given 'window' / 'control' by doing a (16 bits) GetWindowWord  and SetWindowWord to whatever window style you are setting.  If using 32 bits use GetWindowLong and SetWindowLong.

An example:
HWND hWnd = FindWindow("WordPadClass",NULL); // the WordPad app main window
long x = GetWindowLong(hWnd, GWL_STYLE);

Now if it contains the WS_BORDER, remove it then
x ~= WS_BORDER;
//call SetWindowLong and give it the new value of x (minus the WS_BORDER)
SetWindowLong(hWnd, GWL_STYLE,  x);

and the WS_BORDER style will be gone.


Hope this helps.   yOU Can use this methodology to change the 'style' of any window at runtime.



Avatar of moshei

ASKER

When Using the GetWindowLong i recieve a long number .
How Can i Know from this number whether the WS_BORDER is set
why is x~=WS_BORDER not working ( from your answer )
Using  GetWindowLong(hWnd, GWL_STYLE)...

That number you receive from GetWindowLong is explained in Microsoft's knowledgebase in article #Q83366.

Essentially that number contains the full attributes for the style of a window.  You can check if  a given attribute is part of that number by masking & testing like this (in C)

Here is a function that will remove a given style for a window.

void CNoborderDlg::RemoveStyle(HWND hWnd, long Style)
{
    long x;
      x = GetWindowLong(hWnd, GWL_STYLE);
      if (x & Style)
      {
            x &= ~(Style) ; /* REMOVING IT FROM X */
            SetWindowLong(hWnd, GWL_STYLE, x);
      }

}
I typed it wrong in the first example so thats why it didn't work.  you can repeat that style of checking and setting for any of the attributes you are interested in.  I will take a look and see why it didn't work.
It looks like I was mistaken.  You are probably going to have to deal with the WM_PAINT command...


ASKER CERTIFIED SOLUTION
Avatar of Priyesh
Priyesh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
same algorithm...