Click here to Skip to main content
15,914,163 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Getting version information from a resource Pin
Michael Dunn26-May-03 4:30
sitebuilderMichael Dunn26-May-03 4:30 
GeneralRe: Getting version information from a resource Pin
Trollslayer26-May-03 5:04
mentorTrollslayer26-May-03 5:04 
GeneralRe: Getting version information from a resource Pin
Michael Dunn26-May-03 9:55
sitebuilderMichael Dunn26-May-03 9:55 
GeneralFile error checking. Pin
73Zeppelin26-May-03 3:06
73Zeppelin26-May-03 3:06 
GeneralRe: File error checking. Pin
Rage26-May-03 3:32
professionalRage26-May-03 3:32 
GeneralRe: File error checking. Pin
73Zeppelin26-May-03 3:37
73Zeppelin26-May-03 3:37 
GeneralRe: File error checking. Pin
Andrew Walker26-May-03 3:39
Andrew Walker26-May-03 3:39 
QuestionHow to owner-draw the titlebar of one SDI ? Pin
scgy94_jiang26-May-03 2:47
scgy94_jiang26-May-03 2:47 
the problem is : where should i put the lines of drawing ? in OnPaint() only? what else should i do ?

i wish to draw the titlebar of one SDI program. but i met some problems.


here is how i do it as following:

i add lines in the CMainFrame::OnPaint() :

	<br />
CFrameWnd::OnPaint();<br />
<br />
	if (IsIconic()) return;<br />
<br />
	RECT stRect1;<br />
<br />
        // Get the coordinates of the window on the screen<br />
        ::GetWindowRect(m_hWnd, &stRect1);<br />
<br />
	CRgn m_rgn0;<br />
        m_rgn0.CreateRectRgn(0,8,stRect1.right-stRect1.left,stRect1.bottom-                             stRect1.top);<br />
<br />
        SetWindowRgn(m_rgn0,1);<br />
<br />
	<br />
	RECT stRect;<br />
<br />
	CRect rect;<br />
<br />
<br />
	CDC *pDC;<br />
	pDC = GetWindowDC();<br />
	<br />
<br />
<br />
<br />
        // Get the coordinates of the window on the screen<br />
        ::GetWindowRect(m_hWnd, &stRect);<br />
<br />
	<br />
<br />
    rect.SetRect(0,0,stRect.right - stRect.left,stRect.bottom - stRect.top);<br />
<br />
    // Get a handle to the window's device context<br />
    HDC hDC = ::GetWindowDC(m_hWnd);<br />
<br />
    HPEN hPen;<br />
    hPen = CreatePen(PS_INSIDEFRAME, 1* GetSystemMetrics(SM_CXBORDER), <br />
        RGB(123, 200, 243));<br />
<br />
	CPen pen;<br />
<br />
	pen.CreatePen(PS_INSIDEFRAME, 1* GetSystemMetrics(SM_CXBORDER), <br />
        RGB(123, 220, 233));<br />
<br />
<br />
	pDC->SelectObject(&pen);<br />
<br />
	//CBrush brush;<br />
<br />
	<br />
<br />
	<br />
    // Draw the rectangle around the window<br />
    HPEN   hOldPen   = (HPEN)SelectObject(hDC, hPen);<br />
    HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC, GetStockObject(NULL_BRUSH));<br />
<br />
	stRect.bottom = stRect.bottom-stRect.top;<br />
	stRect.right = stRect.right-stRect.left;<br />
<br />
	int btm = stRect.bottom;<br />
	<br />
	CRgn m_rgn6,m_rgn5,m_rgn7;<br />
<br />
	m_rgn6.CreateRectRgn(0,0,4,stRect.bottom);<br />
	m_rgn5.CreateRectRgn(stRect.right -4,0,stRect.right,stRect.bottom);<br />
	m_rgn7.CreateRectRgn(0,stRect.bottom-4,stRect.right,stRect.bottom);<br />
<br />
	stRect.left = 0 ;<br />
	stRect.top = 0 ;<br />
	stRect.bottom = 29;<br />
<br />
	<br />
	<br />
	m_rgn2.CreateRectRgn(stRect.left,stRect.top,stRect.right,stRect.bottom);<br />
	//pDC->SelectObject(&brush);<br />
<br />
	m_rgn2.CombineRgn(&m_rgn2,&m_rgn,RGN_DIFF);<br />
	m_rgn2.CombineRgn(&m_rgn2,&m_rgn6,RGN_OR);<br />
	m_rgn2.CombineRgn(&m_rgn2,&m_rgn5,RGN_OR);<br />
	m_rgn2.CombineRgn(&m_rgn2,&m_rgn7,RGN_OR);<br />
<br />
	SelectClipRgn(hDC,HRGN(m_rgn2));<br />
<br />
<br />
	CBrush brush;<br />
<br />
	brush.CreateSolidBrush(RGB(255,255,255));<br />
	//pDC->SelectClipRgn(&m_rgn2,RGN_AND);<br />
	//brush.CreateStockObject(NULL_BRUSH);<br />
	<br />
	<br />
<br />
	//pDC->FillRgn(&m_rgn2,&brush);<br />
<br />
	FillRgn(hDC,HRGN(m_rgn2),HBRUSH(brush));<br />
<br />
	brush.CreateStockObject(NULL_BRUSH);<br />
<br />
	int i = 0;<br />
<br />
	for (i; i < btm;i)<br />
	{<br />
		MoveToEx(hDC,0,i,NULL);<br />
		LineTo(hDC,stRect.right,i);	<br />
		i += 2;<br />
	}<br />
<br />
    hPen = CreatePen(PS_INSIDEFRAME, 2* GetSystemMetrics(SM_CXBORDER), <br />
     RGB(33, 120, 120));<br />
<br />
	SelectObject(hDC, hPen);<br />
<br />
	MoveToEx(hDC,2,28,NULL);<br />
	LineTo(hDC,stRect.right-2,28);<br />
<br />
<br />
	MoveToEx(hDC,3,28,NULL);<br />
	LineTo(hDC,3,btm-3);<br />
	<br />
	MoveToEx(hDC,stRect.right-3,28,NULL);<br />
	LineTo(hDC,stRect.right-3,btm-3);<br />
<br />
	MoveToEx(hDC,3,btm-4,NULL);<br />
	LineTo(hDC,stRect.right-3,btm-4);<br />
<br />
<br />
	MoveToEx(hDC,0,0,NULL);<br />
	LineTo(hDC,0,btm);<br />
<br />
	MoveToEx(hDC,stRect.right,0,NULL);<br />
	LineTo(hDC,stRect.right,btm);<br />
<br />
<br />
    //Give the window its device context back, and destroy our pen<br />
    ::ReleaseDC(m_hWnd,hDC);<br />
<br />
    SelectObject(hDC, hOldPen);<br />
    SelectObject(hDC, hOldBrush);<br />
<br />
    DeleteObject(hPen);<br />
    DeleteObject(hDC);


it works well at most times, but when the window lost focus or reactiviate, it doesn't redraw. when u drag this window, it doesn't redraw after it moves from top-outside area back, either.
Jiang
AnswerWhat message should i handle to perform this? Pin
scgy94_jiang26-May-03 2:58
scgy94_jiang26-May-03 2:58 
GeneralRe: What message should i handle to perform this? Pin
Rage26-May-03 3:40
professionalRage26-May-03 3:40 
AnswerRe: How to owner-draw the titlebar of one SDI ? Pin
Rage26-May-03 3:38
professionalRage26-May-03 3:38 
AnswerRe: How to owner-draw the titlebar of one SDI ? Pin
John R. Shaw26-May-03 9:33
John R. Shaw26-May-03 9:33 
Questionzip, docfile? Pin
novachen26-May-03 2:21
novachen26-May-03 2:21 
AnswerRe: zip, docfile? Pin
Peter Weyzen26-May-03 18:54
Peter Weyzen26-May-03 18:54 
GeneralProblem mapping WM_NCHITTEST message Pin
Anonymous26-May-03 2:17
Anonymous26-May-03 2:17 
GeneralRe: Problem mapping WM_NCHITTEST message Pin
Rage26-May-03 2:30
professionalRage26-May-03 2:30 
GeneralRe: Problem mapping WM_NCHITTEST message Pin
Anonymous26-May-03 3:06
Anonymous26-May-03 3:06 
GeneralRe: Problem mapping WM_NCHITTEST message Pin
Rage26-May-03 3:31
professionalRage26-May-03 3:31 
GeneralCObArray troubles Pin
Anonymous26-May-03 2:01
Anonymous26-May-03 2:01 
GeneralRe: CObArray troubles Pin
Ryan Binns26-May-03 2:34
Ryan Binns26-May-03 2:34 
GeneralRe: CObArray troubles Pin
Anonymous26-May-03 5:09
Anonymous26-May-03 5:09 
GeneralRe: CObArray troubles Pin
Ryan Binns5-Jun-03 23:12
Ryan Binns5-Jun-03 23:12 
GeneralDirectSound Buffer-&gt;Lock Error Pin
Miepmuts26-May-03 1:48
Miepmuts26-May-03 1:48 
GeneralRe: DirectSound Buffer-&gt;Lock Error Pin
Rage26-May-03 2:11
professionalRage26-May-03 2:11 
GeneralRe: DirectSound Buffer-&gt;Lock Error Pin
Miepmuts26-May-03 2:15
Miepmuts26-May-03 2:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.