Mega Search
23.2 Million


Sign Up

Make a donation  
Error creating window device context  
News Group: borland.public.delphi.nativeapi

I decided to test my application on Windows 9x after developing on Win2000.  I am now always recieving the error EOutOfResources.  However, it only occurs when changing the TCoolbar from vertical to horizontal position.  Plus, there is no way that all the handles could be used up (that I know of).  I traced the error to this function:

function TCoolBar.GetCaptionFontHeight: Integer;
var
  TxtMetric: TTextMetric;
begin
  Result := 0;
  if HandleAllocated then
    with TControlCanvas.Create do
    try
      Control := Self;
      Font := FCaptionFont;
      if (GetTextMetrics(Handle, TxtMetric)) then
        Result := TxtMetric.tmHeight;
    finally
      Free;
    end;
end;

and the error occurs on the creation of the TCanvas.  Does anyone have any idea why I would be getting this error when going from horizontal to vertical?  It doesn't seem like anyone else has had this problem...so just wondering...

Matt

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 25-Jun-2003, at 9:34 PM EST
From: Matt
 
Re: Error creating window device context  
News Group: borland.public.delphi.nativeapi
In article <3efa77c7$1@newsgroups.borland.com>, Matt wrote:
> I decided to test my application on Windows 9x after developing on Win2000.  
> I am now always recieving the error EOutOfResources.  However, it only 
>  occurs when changing the TCoolbar from vertical to horizontal position.  
>  Plus, there is no way that all the handles could be used up (that I know of).  

The error message is likely not quite correct. You will get that in some cases 
if an API call failed unexpectedly, even if it has nothing to do with resources.

> I traced the error to this function:
> 
> function TCoolBar.GetCaptionFontHeight: Integer;
> var
>   TxtMetric: TTextMetric;
> begin
>   Result := 0;
>   if HandleAllocated then
>     with TControlCanvas.Create do
>     try
>       Control := Self;
>       Font := FCaptionFont;
>       if (GetTextMetrics(Handle, TxtMetric)) then

Is Handle <> 0 at this point? I suspect the error is raised in the getter for 
the TControlCanvas Handle property, since it fails to get a device context handle
for the coolbar for some reason. What that reason may be is anybodies guess...



--
Peter Below (TeamB)  
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be



Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 26-Jun-2003, at 11:51 AM EST
From: Peter Below (TeamB)
 
Re: Error creating window device context  
News Group: borland.public.delphi.nativeapi
Actually to be more exact the error occurs during the function call GetTextMetrics.

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 25-Jun-2003, at 9:43 PM EST
From: Matt