BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

FastMM4: CreateWindow('STATIC'.... fails, memory manager is

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Language BASM
View previous topic :: View next topic  
Author Message
Carsten Schuette
Guest





PostPosted: Thu Apr 19, 2007 12:37 am    Post subject: FastMM4: CreateWindow('STATIC'.... fails, memory manager is Reply with quote



Hi,

I have a strange problem using FastMM. During my debug sessions I saw
that in FastMM4.pas the statement

MMWindow := CreateWindow('STATIC',
PChar(@UniqueProcessIDString[1]),
WS_POPUP, 0, 0, 0, 0, 0, 0, hInstance, nil);

returns 0. There are some more CreateWindow calls in FastMM, all fail
with the same error: class STATIC is not registered. What's wrong?

Carsten
Back to top
Pierre le Riche
Guest





PostPosted: Sun Apr 22, 2007 3:21 am    Post subject: Re: FastMM4: CreateWindow('STATIC'.... fails, memory manager Reply with quote



Hi Carsten,

Quote:
MMWindow := CreateWindow('STATIC',
PChar(@UniqueProcessIDString[1]),
WS_POPUP, 0, 0, 0, 0, 0, 0, hInstance, nil);
returns 0. There are some more CreateWindow calls in FastMM, all fail
with the same error: class STATIC is not registered. What's wrong?

That's very strange since 'STATIC' is a predefined system class. Do you
have a code sample that shows this?

Thanks,
Pierre
Back to top
Carsten Schuette
Guest





PostPosted: Mon Apr 23, 2007 2:07 am    Post subject: Re: FastMM4: CreateWindow('STATIC'.... fails, memory manager Reply with quote



Pierre le Riche wrote:

Quote:
MMWindow := CreateWindow('STATIC',
PChar(@UniqueProcessIDString[1]),
WS_POPUP, 0, 0, 0, 0, 0, 0, hInstance, nil);

Pierre,

please find the source code of a simple project below. But a breakpoint
after the CreateWindow line in procedure Test1 and check the value of
MMWindow. It's 0. The Delphi 2007 memory manager itself is also
affected by this problem. A simple look with the debugger confirms this.

Now add "Forms" to the uses and run the software again - it works fine
now.

As a workaround (that breaks compatibility with FastMM and Delphi's MM)
take a look at Test2. This code will not fail, even if the project does
not use VCL forms.

Carsten

--- sample project follows ---

program Project1;

uses
Windows;

{$R *.res}

var
MMWindow: THandle;

var
UniqueProcessIDString: String[23] = '????????_PIDtestest_BE'#0;
HexTable: array[0..15] of char = '0123456789ABCDEF';

procedure BuildProcessIDString;
var
i, LProcessID: Cardinal;
begin
LProcessID := GetCurrentProcessId;
for i := 0 to 7 do
begin
UniqueProcessIDString[8 - i] := HexTable[((LProcessID shr (i * 4))
and $F)];
end;
end;

procedure Test1;
var
MMWindow: THandle;
begin
BuildProcessIDString;
MMWindow := CreateWindow('STATIC', PChar(@UniqueProcessIDString[1]),
WS_POPUP, 0, 0, 0, 0, 0, 0, hInstance, nil);
CloseHandle(MMWindow);
end;

procedure Test2;
var
TempClass: TWndClass;
const
WindowClass: TWndClass = (
style: 0;
lpfnWndProc: @DefWindowProc;
cbClsExtra: 0;
cbWndExtra: 0;
hInstance: 0;
hIcon: 0;
hCursor: 0;
hbrBackground: 0;
lpszMenuName: nil;
lpszClassName: '');
begin
BuildProcessIDString;
if not GetClassInfo(hInstance, PChar(@UniqueProcessIDString[1]),
TempClass) then
begin
WindowClass.hInstance := hInstance;
WindowClass.lpszClassName := @UniqueProcessIDString[1];
if RegisterClass(WindowClass) = 0 then
Exit;
end;
MMWindow := CreateWindow(PChar(@UniqueProcessIDString[1]),
PChar(@UniqueProcessIDString[1]), WS_POPUP, 0, 0, 0, 0, 0, 0,
hInstance, nil);
CloseHandle(MMWindow);
end;

begin
Test1;
//Test2;
end.

--
Back to top
Pierre le Riche
Guest





PostPosted: Thu Apr 26, 2007 6:10 pm    Post subject: Re: FastMM4: CreateWindow('STATIC'.... fails, memory manager Reply with quote

Hi Carsten,

Quote:
As a workaround (that breaks compatibility with FastMM and Delphi's MM)
take a look at Test2. This code will not fail, even if the project does
not use VCL forms.

Thank you for the test case. It appears that the automatic inclusion of an
XP Manifest even in console applications by D2007 is what is causing the
problem. I will report the problem in QC.

Regards,
Pierre
Back to top
Carsten Schuette
Guest





PostPosted: Thu Apr 26, 2007 7:10 pm    Post subject: Re: FastMM4: CreateWindow('STATIC'.... fails, memory manager Reply with quote

Pierre le Riche wrote:

Quote:
Thank you for the test case. It appears that the automatic inclusion
of an XP Manifest even in console applications by D2007 is what is
causing the problem. I will report the problem in QC.

Great that you were able to reproduce the problem and found a possible
cause. I hope this will be fixed soon because also Delphi's MM is
affected by this and does not work correctly.

Carsten

--
Back to top
Thorsten Engler [NexusDB]
Guest





PostPosted: Thu Apr 26, 2007 7:47 pm    Post subject: Re: FastMM4: CreateWindow('STATIC'.... fails, memory manager Reply with quote

Carsten Schuette wrote:

Quote:
Pierre le Riche wrote:

Thank you for the test case. It appears that the automatic inclusion
of an XP Manifest even in console applications by D2007 is what is
causing the problem. I will report the problem in QC.

Great that you were able to reproduce the problem and found a possible
cause. I hope this will be fixed soon because also Delphi's MM is
affected by this and does not work correctly.

With the project open:

Main Menu -> Project -> Options -> Application -> "Enable runtime
themes" (turn this off).


--
Back to top
Carsten Schuette
Guest





PostPosted: Thu Apr 26, 2007 8:56 pm    Post subject: Re: FastMM4: CreateWindow('STATIC'.... fails, memory manager Reply with quote

Thorsten Engler [NexusDB] wrote:

Quote:
Main Menu -> Project -> Options -> Application -> "Enable runtime
themes" (turn this off).

Do you know where exactly the difference between a project with and a
project without runtime themes is?

Carsten

--
Back to top
Thorsten Engler [NexusDB]
Guest





PostPosted: Thu Apr 26, 2007 9:22 pm    Post subject: Re: FastMM4: CreateWindow('STATIC'.... fails, memory manager Reply with quote

Carsten Schuette wrote:

Quote:
Thorsten Engler [NexusDB] wrote:

Main Menu -> Project -> Options -> Application -> "Enable runtime
themes" (turn this off).

Do you know where exactly the difference between a project with and a
project without runtime themes is?

If the option is active then a manifest is added to the project .res
file which requests linking against common controls v6 (without the
manifest applications get linked against common controls v5).



--
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Language BASM All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.