|
-
Jul 26th, 2005, 12:56 PM
#1
[RESOLVED] How do I BitBlt onto an MDI client area when the client rect is adjusted?
I am drawing a tabstrip onto an MDI client area, and subclassing to catch the WM_NCCALCSIZE message and altering the client area to give myself some room at the top to draw the tab strip. However, when it comes to actually drawing the tabstrip, I am stuck... I am trying to BitBlt from a picturebox on to the "off-limits" area I have just created, but no success (Nothing gets drawn). However drawing on to the rest of the client area works perfectly.
Maybe some code would help, this is the WndProc code which shows the client area size adjustment (which works) and the BitBlt (which doesn't)
VB Code:
Private Function WndProc( _
ByVal hWnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long _
) As Long
Dim udtNCCalcSize As NCCALCSIZE_PARAMS
Dim udtWndPos As WINDOWPOS
Dim udtWndRect As RECT
Dim udtPicBoxRect As RECT
Dim lhDC As Long
Select Case uMsg
Case WM_NCCALCSIZE
' Adjust the client area size calculation to allow for our tabstrip
If (wParam <> 0) Then
RtlMoveMemory udtNCCalcSize, _
ByVal lParam, _
Len(udtNCCalcSize)
RtlMoveMemory udtWndPos, _
ByVal udtNCCalcSize.lppos, _
Len(udtWndPos)
With udtNCCalcSize.rgrc(0)
.Left = udtWndPos.x + 2
.Top = udtWndPos.y + MAGICNUMBER
.Right = (udtWndPos.x + udtWndPos.cX) - 2
.Bottom = (udtWndPos.y + udtWndPos.cY) - 2
End With
LSet udtNCCalcSize.rgrc(1) = udtNCCalcSize.rgrc(0)
RtlMoveMemory ByVal lParam, _
udtNCCalcSize, _
Len(udtNCCalcSize)
WndProc = WVR_VALIDRECTS
Else
WndProc = CallWindowProc(mlpfnOldWindowProc, _
hWnd, _
uMsg, _
wParam, _
lParam)
End If
Case WM_PAINT, WM_NCPAINT
GetWindowRect hWnd, udtWndRect
GetWindowRect mobjDrawPicBox.hWnd, udtPicBoxRect
DrawGradient GradientColorEnd, _
GradientColorStart, _
GRADIENT_DRAW_VERTICAL, _
MAGICNUMBER, _
udtWndRect.Right - udtWndRect.Left
lhDC = GetDC(hWnd)
BitBlt lhDC, 0, _
(-MAGICNUMBER), _
udtWndRect.Right - udtWndRect.Left, _
MAGICNUMBER, _
mobjDrawPicBox.hDC, _
0, _
0, _
vbSrcCopy
ReleaseDC hWnd, lhDC
WndProc = CallWindowProc(mlpfnOldWindowProc, _
hWnd, _
uMsg, _
wParam, _
lParam)
Case Else
WndProc = CallWindowProc(mlpfnOldWindowProc, _
hWnd, _
uMsg, _
wParam, _
lParam)
End Select
End Function
MAGICNUMBER = 23.
Bear in mind that BitBlt'ing to a y value > 0 works, but I need it to be absolute 0, i.e. adjusted top of client area minus adjustment offset. Above this point nothing is drawn, it just picks up bits from the rest of the screen when I resize the window (not refreshing effect).
Any ideas?
-
Jul 26th, 2005, 01:29 PM
#2
Re: How do I BitBlt onto an MDI client area when the client rect is adjusted?
You have to make sure the standard non-client drawing is done before you try to paint your own tabs otherwise they might get overpainted when the standard painting is done. So the first thing you should do when you get the WM_NCPAINT message is to call the old WndProc procedure.
-
Jul 26th, 2005, 01:48 PM
#3
Re: How do I BitBlt onto an MDI client area when the client rect is adjusted?
Thanks for the reply, I tried it, however it made no difference... the drawing still does not work properly.
Is it possible I am drawing to the wrong DC? I have tried both the MDIClient area and the MDI form itself, but neither worked; maybe I have somehow lost my drawing area in that space?
-
Jul 26th, 2005, 02:05 PM
#4
Re: How do I BitBlt onto an MDI client area when the client rect is adjusted?
You're trying to draw on the non-client area that is above the resized MDI client area right? In that case, first of all I don't think you should use the same code for both WM_PAINT and WM_NCPAINT, I don't even think you need to catch the WM_PAINT message, at least not to draw on the non-client area. Secondly you use GetDC to get a device context, that's fine except that DC will only be for the client area and you will not be able to draw anything in the non-client area. You should use GetWindowDC instead.
-
Jul 26th, 2005, 02:19 PM
#5
Re: How do I BitBlt onto an MDI client area when the client rect is adjusted?
I was about to reply that I had been trying GetWindowDC and GetDCEx also until it occured to me that of course the coordinates are different... it works now Thanks so much
-
Jul 26th, 2005, 02:31 PM
#6
Re: [RESOLVED] How do I BitBlt onto an MDI client area when the client rect is adjusted?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|