implement overlay window for designer

git-svn-id: trunk@5050 -
This commit is contained in:
micha 2004-01-12 08:20:50 +00:00
parent 77217ed9fa
commit 1903f6fc4f
2 changed files with 64 additions and 6 deletions

View File

@ -73,6 +73,43 @@ Begin
Assert(False, 'Trace:PropEnumProc - Exit');
End;
{------------------------------------------------------------------------------
Function: OverlayWindowProc
Params: Window - The window that receives a message
Msg - The message received
WParam - Word parameter
LParam - Long-integer parameter
Returns: 0 if Msg is handled; non-zero long-integer result otherwise
Handles messages specifically for the window used by GetDesignerDC
------------------------------------------------------------------------------}
function OverlayWindowProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam;
LParam: Windows.LParam): LResult; stdcall;
var
PS: PAINTSTRUCT;
PrevWndProc: Pointer;
begin
case Msg of
WM_ERASEBKGND:
begin
Result := 1;
end;
WM_PAINT:
begin
Windows.BeginPaint(Window, @PS);
Windows.EndPaint(Window, @PS);
Result := 1;
end;
else
// default handling of message
PrevWndProc := GetProp(Window, 'DefWndProc');
if PrevWndProc = nil then
Result := Windows.DefWindowProc(Window, Msg, WParam, LParam)
else
Result := Windows.CallWindowProc(Windows.WNDPROC(PrevWndProc), Window, Msg, WParam, LParam);
end;
end;
{------------------------------------------------------------------------------
Function: WindowProc
Params: Window - The window that receives a message
@ -733,10 +770,9 @@ Begin
Unused := WParam;
WindowPos := PWindowPos(LParam);
End;
// GetClientRect(Window, R);
// SendMessage(Window, WM_MOVE, 0, MakeLParam(PWindowPos(LParam)^.x, PWindowPos(LParam)^.y));
// SendMessage(Window, WM_SIZE, 0, MakeLParam(R.right-R.left, R.bottom-R.top));
// WinProcess:=false;
// cross-interface compatible: complete invalidate on resize
if (PWindowPos(LParam)^.flags and SWP_NOSIZE) = 0 then
Windows.InvalidateRect(Window, nil, true);
End;
WM_MEASUREITEM:
Begin
@ -938,6 +974,9 @@ end;
{
$Log$
Revision 1.87 2004/01/12 08:20:50 micha
implement overlay window for designer
Revision 1.86 2004/01/07 18:05:46 micha
add TWinControl.DoubleBuffered property which is a hint for the interface to do double-buffering for this control

View File

@ -1364,8 +1364,24 @@ begin
end;
function TWin32Object.GetDesignerDC(WindowHandle: HWND): HDC;
var
OverlayWindow: HWND;
ARect: Windows.RECT;
begin
Result := Windows.GetDC(0);
OverlayWindow := HWND(Windows.GetProp(WindowHandle, 'Overlay'));
if OverlayWindow = HWND(nil) then
begin
// create 'overlay' window
Windows.GetClientRect(WindowHandle, @ARect);
OverlayWindow := Windows.CreateWindowEx(WS_EX_TRANSPARENT,
'STATIC', '', WS_CHILD or WS_VISIBLE,
ARect.Left, ARect.Top, ARect.Right, ARect.Bottom,
WindowHandle, HMENU(nil), HInstance, nil);
Windows.SetProp(OverlayWindow, 'DefWndProc', Windows.SetWindowLong(
OverlayWindow, GWL_WNDPROC, LongInt(@OverlayWindowProc)));
Windows.SetProp(WindowHandle, 'Overlay', OverlayWindow);
end;
Result := Windows.GetDC(OverlayWindow);
end;
function TWin32Object.GetDeviceSize(DC: HDC; var P: TPoint): Boolean;
@ -2320,7 +2336,7 @@ End;
Function TWin32Object.ReleaseDesignerDC(HWnd: HWND; DC: HDC): Integer;
Begin
Assert(False, Format('Trace:> [TWin32Object.ReleaseDC] DC:0x%x', [DC]));
Result := Windows.ReleaseDC(0, DC);
Result := Windows.ReleaseDC(HWnd, DC);
Assert(False, Format('Trace:< [TWin32Object.ReleaseDC] DC:0x%x', [DC]));
End;
@ -2887,6 +2903,9 @@ end;
{ =============================================================================
$Log$
Revision 1.92 2004/01/12 08:20:50 micha
implement overlay window for designer
Revision 1.91 2004/01/03 21:06:06 micha
- fix win32/checklistbox
- implement proper lcl to interface move/size notify via setwindowpos