customdrawn-windows: Fixes startup crashes

git-svn-id: trunk@33971 -
This commit is contained in:
sekelsenmat 2011-12-05 13:43:49 +00:00
parent 5d2d0b17ec
commit 7ab9c2029b
2 changed files with 17 additions and 4 deletions

View File

@ -176,6 +176,8 @@ procedure LCLBoundsToWin32Bounds(Sender: TObject;
procedure LCLFormSizeToWin32Size(Form: TCustomForm; var AWidth, AHeight: Integer);
procedure GetWin32ControlPos(Window, Parent: HWND; var Left, Top: integer);
function GetWindowInfo(AWindow: HWND): TWindowInfo;
procedure UpdateWindowStyle(Handle: HWnd; Style: integer; StyleMask: integer);
function BorderStyleToWinAPIFlags(Style: TFormBorderStyle): DWORD;
function BorderStyleToWinAPIFlagsEx(AForm: TCustomForm; Style: TFormBorderStyle): DWORD;
@ -1257,6 +1259,12 @@ begin
Top := winRect.Top - parRect.Top;
end;
function GetWindowInfo(AWindow: HWND): TWindowInfo;
begin
Result := TWindowInfo(FindFormWithNativeHandle(AWindow));
if Result = nil then Result := DefaultWindowInfo;
end;
{
Updates the window style of the window indicated by Handle.
The new style is the Style parameter.
@ -1704,7 +1712,7 @@ begin
end;
initialization
FillChar(DefaultWindowInfo, sizeof(DefaultWindowInfo), 0);
DefaultWindowInfo := TWindowInfo.Create;
WindowInfoAtom := Windows.GlobalAddAtom('WindowInfo');
ChangedMenus := TList.Create;
UpdateWindowsVersion();

View File

@ -70,7 +70,7 @@ begin
DebugLn('Trace:CallDefaultWindowProc - Start');
{$endif}
WindowInfo := TWindowInfo(FindFormWithNativeHandle(Window));
WindowInfo := GetWindowInfo(Window);
PrevWndProc := WindowInfo.DefWndProc;
if (PrevWndProc = nil) or (PrevWndProc = @WindowProc) // <- prevent recursion
@ -495,13 +495,18 @@ begin
WinProcess := True;
NotifyUserInput := False;
{$ifdef VerboseCDMessages}
DebugLn(Format('WindowProc Window= %x FAppHandle=%x MSG=%s',
[Window, CDWidgetset.FAppHandle, WM_To_String(Msg)]));
{$endif}
//DebugLn('Trace:WindowProc - Getting Object with Callback Procedure');
WindowInfo := TWindowInfo(FindFormWithNativeHandle(Window));
WindowInfo := GetWindowInfo(Window);
lWinControl := WindowInfo.LCLForm;
{$ifdef VerboseCDMessages}
DebugLn('WindowProc lWinControl: ',DbgSName(lWinControl),' MSG=',WM_To_String(Msg));
DebugLn('WindowProc lWinControl: ',DbgSName(lWinControl));
{$endif}
if (IgnoreNextCharWindow <> 0) and ((Msg = WM_CHAR) or (Msg = WM_SYSCHAR)) then
begin