Board index » Visual Studio » Drawing "splitter" bars

Drawing "splitter" bars

Visual Studio124
Hello,



I have a CDialog derived object that contains two child windows. I

implement splitter-like functionality (without using CSplitterWnd) and

have everything working correctly.



Now, I want to add a "track bar" so when the user drags to resize, he

sees where the split will end up being. I use code like this:



CDC *pDC = GetDC()



if(pDC)

{

CBrush *pBrush = pDC->GetHalftoneBrush();



if(pBrush)

pBrush = pDC->SelectObject(pBrush);



pDC->PatBlt(rc.left, rc.top, rc.Width(),

rc.Height(), PATINVERT);



if(pBrush)

pDC->SelectObject(pBrush);



ReleaseDC(pDC);

}



This *seems* to work OK, except the drawing (understandably) takes

place *under* the child windows, and the bar is, therefore, occluded.



Any ideas on how I can make the tracking bar paint on top of child windows?



-n


-
 

Re:Drawing "splitter" bars

Nikolaos D. Bougalis wrote:

Quote
Hello,



I have a CDialog derived object that contains two child windows. I

implement splitter-like functionality (without using CSplitterWnd) and

have everything working correctly.



Now, I want to add a "track bar" so when the user drags to resize,

he sees where the split will end up being. I use code like this:



CDC *pDC = GetDC()



if(pDC)

{

CBrush *pBrush = pDC->GetHalftoneBrush();



if(pBrush)

pBrush = pDC->SelectObject(pBrush);



pDC->PatBlt(rc.left, rc.top, rc.Width(),

rc.Height(), PATINVERT);



if(pBrush)

pDC->SelectObject(pBrush);



ReleaseDC(pDC);

}



This *seems* to work OK, except the drawing (understandably) takes

place *under* the child windows, and the bar is, therefore, occluded.



Any ideas on how I can make the tracking bar paint on top of child

windows?



-n



You need to remove WS_CLIPCHILDREN from the parent wnd. If that screws

up the dialog controls then you would need an underlying splitter window

as the parent of the panes, just like CSplitterWnd uses.



--

Scott McPhillips [VC++ MVP]



-

Re:Drawing "splitter" bars

Scott McPhillips [MVP] wrote:



Quote
Nikolaos D. Bougalis wrote:



>Hello,

>

>I have a CDialog derived object that contains two child windows. I

>implement splitter-like functionality (without using CSplitterWnd) and

>have everything working correctly.

>

>Now, I want to add a "track bar" so when the user drags to resize,

>he sees where the split will end up being. I use code like this:

>

>CDC *pDC = GetDC()

>

>if(pDC)

>{

>CBrush *pBrush = pDC->GetHalftoneBrush();

>

>if(pBrush)

>pBrush = pDC->SelectObject(pBrush);

>

>pDC->PatBlt(rc.left, rc.top, rc.Width(),

>rc.Height(), PATINVERT);

>

>if(pBrush)

>pDC->SelectObject(pBrush);

>

>ReleaseDC(pDC);

>}

>

>This *seems* to work OK, except the drawing (understandably) takes

>place *under* the child windows, and the bar is, therefore, occluded.

>

>Any ideas on how I can make the tracking bar paint on top of child

>windows?

>

>-n





You need to remove WS_CLIPCHILDREN from the parent wnd. If that screws

up the dialog controls then you would need an underlying splitter window

as the parent of the panes, just like CSplitterWnd uses.



Ahh!!! WS_CLIPCHILDREN it is!!! Silly me!



And here I was about to resort to using CWindowDC and doing all sorts

of magic to map the client-space rectangle to window-space.



Thanks!



-

Re:Drawing "splitter" bars

Since the rest has been answered, the question is why are you doing something as

complicated as declaring a CDC * and doing GetDC(), when

CClientDC dc(this);

works just fine?

joe



On Thu, 24 Jun 2004 13:09:54 -0700, "Nikolaos D. Bougalis" <nikb@webmaster.com>wrote:



Quote
Hello,



I have a CDialog derived object that contains two child windows. I

implement splitter-like functionality (without using CSplitterWnd) and

have everything working correctly.



Now, I want to add a "track bar" so when the user drags to resize, he

sees where the split will end up being. I use code like this:



CDC *pDC = GetDC()



if(pDC)

{

CBrush *pBrush = pDC->GetHalftoneBrush();



if(pBrush)

pBrush = pDC->SelectObject(pBrush);



pDC->PatBlt(rc.left, rc.top, rc.Width(),

rc.Height(), PATINVERT);



if(pBrush)

pDC->SelectObject(pBrush);



ReleaseDC(pDC);

}



This *seems* to work OK, except the drawing (understandably) takes

place *under* the child windows, and the bar is, therefore, occluded.



Any ideas on how I can make the tracking bar paint on top of child windows?



-n



Joseph M. Newcomer [MVP]

email: newcomer@flounder.com

Web: www.flounder.com">www.flounder.com

MVP Tips: www.flounder.com/mvp_tips.htm">www.flounder.com/mvp_tips.htm

-

Re:Drawing "splitter" bars

Joseph M. Newcomer wrote:



Quote
Since the rest has been answered, the question is why are you doing something as

complicated as declaring a CDC * and doing GetDC(), when

CClientDC dc(this);

works just fine?



I have a memory DC wrapper class; You declare an instance of it, and

pass it a pointer to a DC. You do all the drawing to the memory DC, and

then, it blits itself to the screen and releases the DC you passed to it.



I didn't copy code verbatim, but I didn't want to significantly change

it either, so "GetDC" stayed (in lieu of WMemoryDC dc(GetDC())) and a

ReleaseDC was added to avoid comments about the DC not being released.



Granted, I could (and probably should) make WMemoryDC get a CWnd or an

HWND and deal with all the DC stuff internally.



-n





-