lcl: further work on TWinControl.ParentWindow:

- implement LCLIntf.SetParent for win32, wince and qt
  - implement TWinControl.SetParentWindow

git-svn-id: trunk@23846 -
This commit is contained in:
paul 2010-03-06 19:40:29 +00:00
parent b548b49db5
commit d6ffb794fb
11 changed files with 49 additions and 4 deletions

View File

@ -1555,6 +1555,11 @@ begin
Result := False; Result := False;
end; end;
function TWidgetSet.SetParent(hWndChild: HWND; hWndParent: HWND): HWND;
begin
Result := 0;
end;
function TWidgetSet.SetProp(Handle: hwnd; Str : PChar; function TWidgetSet.SetProp(Handle: hwnd; Str : PChar;
Data : Pointer) : Boolean; Data : Pointer) : Boolean;
Begin Begin

View File

@ -821,6 +821,11 @@ begin
Result := WidgetSet.SetMenu(AWindowHandle, AMenuHandle); Result := WidgetSet.SetMenu(AWindowHandle, AMenuHandle);
end; end;
function SetParent(hWndChild: HWND; hWndParent: HWND): HWND;
begin
Result := WidgetSet.SetParent(hWndChild, hWndParent);
end;
function SetProp(Handle: hwnd; Str : PChar; Data : Pointer) : Boolean; function SetProp(Handle: hwnd; Str : PChar; Data : Pointer) : Boolean;
begin begin
Result := WidgetSet.SetProp(Handle,Str,Data); Result := WidgetSet.SetProp(Handle,Str,Data);

View File

@ -236,6 +236,7 @@ function SetFocus(hWnd: HWND): HWND; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function SetForegroundWindow(hWnd : HWND): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF} function SetForegroundWindow(hWnd : HWND): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function SetMapMode(DC: HDC; fnMapMode : Integer): Integer; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF} function SetMapMode(DC: HDC; fnMapMode : Integer): Integer; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function SetMenu(AWindowHandle: HWND; AMenuHandle: HMENU): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF} function SetMenu(AWindowHandle: HWND; AMenuHandle: HMENU): Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function SetParent(hWndChild: HWND; hWndParent: HWND): HWND; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
function SetProp(Handle: hwnd; Str : PChar; Data : Pointer) : Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF} function SetProp(Handle: hwnd; Str : PChar; Data : Pointer) : Boolean; {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
//function SetRect --> independent //function SetRect --> independent
//function SetRectEmpty --> independent //function SetRectEmpty --> independent

View File

@ -3968,8 +3968,14 @@ end;
procedure TWinControl.SetParentWindow(const AValue: HWND); procedure TWinControl.SetParentWindow(const AValue: HWND);
begin begin
// todo: recreate window? if (ParentWindow = AValue) or Assigned(Parent) then Exit;
FParentWindow := AValue; FParentWindow := AValue;
if HandleAllocated then
if (AValue <> 0) then
LCLIntf.SetParent(Handle, AValue)
else
DestroyHandle;
UpdateControlState
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------

View File

@ -1457,9 +1457,14 @@ begin
// default color roles // default color roles
SetDefaultColorRoles; SetDefaultColorRoles;
FPalette := nil; FPalette := nil;
// Creates the widget
// creates the widget
Widget := CreateWidget(FParams); Widget := CreateWidget(FParams);
// attach to parent
if FParams.WndParent <> 0 then
setParent(TQtWidget(FParams.WndParent).GetContainerWidget);
// retrieve default cursor on create // retrieve default cursor on create
FDefaultCursor := QCursor_create(); FDefaultCursor := QCursor_create();
QWidget_cursor(Widget, FDefaultCursor); QWidget_cursor(Widget, FDefaultCursor);

View File

@ -2608,7 +2608,7 @@ function TQtWidgetSet.GetParent(Handle : HWND): HWND;
var var
QtWidget: TQtWidget; QtWidget: TQtWidget;
begin begin
{$ifdef VerboseQtWinAPI} {$ifdef VerboseQtWinAPI}
writeln('Trace:> [WinAPI GetParent] Handle: ' + dbghex(Handle)); writeln('Trace:> [WinAPI GetParent] Handle: ' + dbghex(Handle));
{$endif} {$endif}
Result := 0; Result := 0;
@ -2619,7 +2619,7 @@ begin
Result := HWND(QtObjectFromWidgetH(QtWidget.getParent)); Result := HWND(QtObjectFromWidgetH(QtWidget.getParent));
{$ifdef VerboseQtWinAPI} {$ifdef VerboseQtWinAPI}
writeln('Trace:< [WinAPI GetParent] : ' + dbghex(Result)); writeln('Trace:< [WinAPI GetParent] : ' + dbghex(Result));
{$endif} {$endif}
end; end;
@ -4651,6 +4651,16 @@ begin
end; end;
end; end;
function TQtWidgetSet.SetParent(hWndChild: HWND; hWndParent: HWND): HWND;
var
OldVisible: Boolean;
begin
Result := GetParent(hWndChild);
OldVisible := TQtWidget(hWndChild).getVisible;
TQtWidget(hWndChild).setParent(TQtWidget(hWndParent).GetContainerWidget);
TQtWidget(hWndChild).setVisible(OldVisible);
end;
function TQtWidgetSet.SetMapMode(DC: HDC; fnMapMode : Integer): Integer; function TQtWidgetSet.SetMapMode(DC: HDC; fnMapMode : Integer): Integer;
var var
AWindowExt: TPoint; AWindowExt: TPoint;

View File

@ -185,6 +185,7 @@ function SetFocus(hWnd: HWND): HWND; override;
function SetForegroundWindow(HWnd: HWND): boolean; override; function SetForegroundWindow(HWnd: HWND): boolean; override;
function SetMapMode(DC: HDC; fnMapMode : Integer): Integer; override; function SetMapMode(DC: HDC; fnMapMode : Integer): Integer; override;
function SetMenu(AWindowHandle: HWND; AMenuHandle: HMENU): Boolean; override; function SetMenu(AWindowHandle: HWND; AMenuHandle: HMENU): Boolean; override;
function SetParent(hWndChild: HWND; hWndParent: HWND): HWND; override;
function SetProp(Handle: hwnd; Str : PChar; Data : Pointer) : Boolean; override; function SetProp(Handle: hwnd; Str : PChar; Data : Pointer) : Boolean; override;
function SetROP2(DC: HDC; Mode: Integer): Integer; override; function SetROP2(DC: HDC; Mode: Integer): Integer; override;
function SetScrollInfo(Handle : HWND; SBStyle : Integer; ScrollInfo: TScrollInfo; bRedraw : Boolean): Integer; override; function SetScrollInfo(Handle : HWND; SBStyle : Integer; ScrollInfo: TScrollInfo; bRedraw : Boolean): Integer; override;

View File

@ -3058,6 +3058,11 @@ begin
AddToChangedMenus(AWindowHandle); AddToChangedMenus(AWindowHandle);
end; end;
function TWin32WidgetSet.SetParent(hWndChild: HWND; hWndParent: HWND): HWND;
begin
Result := Windows.SetParent(hWndchild, hWndParent);
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Method: SetMapMode Method: SetMapMode

View File

@ -196,6 +196,7 @@ function SetFocus(HWnd: HWND): HWND; override;
function SetForegroundWindow(HWnd: HWND): boolean; override; function SetForegroundWindow(HWnd: HWND): boolean; override;
function SetMapMode(DC: HDC; fnMapMode : Integer): Integer; override; function SetMapMode(DC: HDC; fnMapMode : Integer): Integer; override;
function SetMenu(AWindowHandle: HWND; AMenuHandle: HMENU): Boolean; override; function SetMenu(AWindowHandle: HWND; AMenuHandle: HMENU): Boolean; override;
function SetParent(hWndChild: HWND; hWndParent: HWND): HWND; override;
function SetProp(Handle: hwnd; Str: PChar; Data: Pointer): Boolean; override; function SetProp(Handle: hwnd; Str: PChar; Data: Pointer): Boolean; override;
function SetROP2(DC: HDC; Mode: Integer): Integer; override; function SetROP2(DC: HDC; Mode: Integer): Integer; override;
function SetScrollInfo(Handle: HWND; SBStyle: Integer; ScrollInfo: TScrollInfo; BRedraw: Boolean): Integer; override; function SetScrollInfo(Handle: HWND; SBStyle: Integer; ScrollInfo: TScrollInfo; BRedraw: Boolean): Integer; override;

View File

@ -2731,6 +2731,11 @@ begin
Result := Windows.SetForegroundWindow(HWnd); Result := Windows.SetForegroundWindow(HWnd);
end; end;
function TWinCEWidgetSet.SetParent(hWndChild: HWND; hWndParent: HWND): HWND;
begin
Result := Windows.SetParent(hWndChild,hWndParent);
end;
function TWinCEWidgetSet.SetMenu(AWindowHandle: HWND; AMenuHandle: HMENU): Boolean; function TWinCEWidgetSet.SetMenu(AWindowHandle: HWND; AMenuHandle: HMENU): Boolean;
{$ifndef Win32} {$ifndef Win32}
var var

View File

@ -203,6 +203,7 @@ function SetCursor(hCursor: HICON): HCURSOR; override;
//function SetCursorPos(X, Y: Integer): Boolean; override; //function SetCursorPos(X, Y: Integer): Boolean; override;
function SetFocus(hWnd: HWND): HWND; override; function SetFocus(hWnd: HWND): HWND; override;
function SetForegroundWindow(HWnd: HWND): boolean; override; function SetForegroundWindow(HWnd: HWND): boolean; override;
function SetParent(hWndChild: HWND; hWndParent: HWND): HWND; override;
function SetProp(Handle: hwnd; Str : PChar; Data : Pointer) : Boolean; override; function SetProp(Handle: hwnd; Str : PChar; Data : Pointer) : Boolean; override;
function SetMenu(AWindowHandle: HWND; AMenuHandle: HMENU): Boolean; override; function SetMenu(AWindowHandle: HWND; AMenuHandle: HMENU): Boolean; override;
function SetROP2(DC: HDC; Mode: Integer): Integer; override; function SetROP2(DC: HDC; Mode: Integer): Integer; override;