C
CJ
Unregistered / Unconfirmed
GUEST, unregistred user!
This is Courtesy of the guys at http://www.egroups.com/group/delphi-webbrowser/
If you import the msinternet controls, drop a browser on a form and navigate to a few location, then check GDI memory, you'll find you are loosing some, do the same after implementing the following and it's a lot less of a leek... however it's still there. I have actually switched to using CBC4 for this type of work.
Type TOleControlFix = class(TOleControl)
//Private
//Protected
procedure WMPaint(var Message: TWMPaint)
message WM_PAINT
function GetIUnknownProp(Index: Integer): IUnknown
function GetIDispatchProp(Index: Integer): IDispatch
end
implementation
procedure TOleControlFix.WMPaint(var Message: TWMPaint)
var
PS: TPaintStruct
begin
if Message.DC = 0 then begin
BeginPaint(Handle, PS)
EndPaint(Handle, PS)
endend
function TOleControlFix.GetIDispatchProp(Index: integer): IDispatch
var
Temp: TVarData
begin
GetProperty(Index, Temp)
// Result := IDispatch(Temp.VDispatch);// this caused //memory leak
Pointer(Result) := Temp.VDispatch
// changed to this
end
function TOleControlFix.GetIUnknownProp(Index: Integer): IUnknown;var
Temp: TVarData
begin
GetProperty(Index, Temp)
//Result := IUnknown(Temp.VUnknown)
// this caused //memory leak
Pointer(Result) := Temp.VUnknown
// changed to this to //avoid extra addref
end
end.
If you import the msinternet controls, drop a browser on a form and navigate to a few location, then check GDI memory, you'll find you are loosing some, do the same after implementing the following and it's a lot less of a leek... however it's still there. I have actually switched to using CBC4 for this type of work.
Type TOleControlFix = class(TOleControl)
//Private
//Protected
procedure WMPaint(var Message: TWMPaint)
message WM_PAINT
function GetIUnknownProp(Index: Integer): IUnknown
function GetIDispatchProp(Index: Integer): IDispatch
end
implementation
procedure TOleControlFix.WMPaint(var Message: TWMPaint)
var
PS: TPaintStruct
begin
if Message.DC = 0 then begin
BeginPaint(Handle, PS)
EndPaint(Handle, PS)
endend
function TOleControlFix.GetIDispatchProp(Index: integer): IDispatch
var
Temp: TVarData
begin
GetProperty(Index, Temp)
// Result := IDispatch(Temp.VDispatch);// this caused //memory leak
Pointer(Result) := Temp.VDispatch
// changed to this
end
function TOleControlFix.GetIUnknownProp(Index: Integer): IUnknown;var
Temp: TVarData
begin
GetProperty(Index, Temp)
//Result := IUnknown(Temp.VUnknown)
// this caused //memory leak
Pointer(Result) := Temp.VUnknown
// changed to this to //avoid extra addref
end
end.