[DUG] Stack Overflow in WndProc

2011-06-02 Thread ja...@software-solutions.co.nz
Hi there,

I have been experiencing a Stack Overflow error in my WndProc override and not 
sure why this is

Basic form below..

TMyForm = class(TForm)
...
Protected
procedure WndProc(var Message: TMessage); override;
...
End;

procedure TMyForm.WndProc(var Message: TMessage);
var
  fActive   : Boolean;
begin
  case Message.Msg of
WM_NCPAINT, WM_NCACTIVATE:
  begin
if not IsIconic(Handle) then
begin
  if Message.Msg = WM_NCPAINT then
fActive   := (Handle = 
GetActiveWindow)
  else
fActive   := (Message.wparam  
0);
  if fActive then
  begin
   //Do Stuff
  end;
end;
if Message.Msg = WM_NCPAINT then
begin
  if DwmCompositionEnabled then
inherited WndProc(Message);
end
else
  inherited WndProc(Message);
  end;
CM_DEACTIVATE:
  begin
  end;
CM_ACTIVATE:
  begin
  end;
else
begin
  inherited WndProc(Message);
end;
  end;
end;

any ideas what could be wrong here?
I am trapping other windows messages in other message traps like...

procedure WMCommand(var Message: TWMCommand); message WM_COMMAND;
procedure WMActivate(var Msg: TWMActivate); message WM_ACTIVATE;



Regards from New Zealand (GMT+12)

Jason Coley
Software Solutions

___
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe

Re: [DUG] Stack Overflow in WndProc

2011-06-02 Thread Karl Reynolds
GetActiveWindow re-enters the message queue so I'm guessing that has
something to do with it.

Cheers,
Karl

On Fri, Jun 3, 2011 at 11:35 AM, ja...@software-solutions.co.nz
ja...@software-solutions.co.nz wrote:
 Hi there,



 I have been experiencing a Stack Overflow error in my WndProc override and
 not sure why this is….



 Basic form below..



 TMyForm = class(TForm)

 …

 Protected

     procedure WndProc(var Message: TMessage); override;

 …

 End;



 procedure TMyForm.WndProc(var Message: TMessage);

 var

   fActive   : Boolean;

 begin

   case Message.Msg of

     WM_NCPAINT, WM_NCACTIVATE:

   begin

     if not IsIconic(Handle) then

     begin

   if Message.Msg = WM_NCPAINT then

     fActive   := (Handle =
 GetActiveWindow)

   else

     fActive   := (Message.wparam
  0);

   if fActive then

   begin

    //Do Stuff

   end;

     end;

     if Message.Msg = WM_NCPAINT then

     begin

   if DwmCompositionEnabled then

     inherited WndProc(Message);

     end

     else

   inherited WndProc(Message);

   end;

     CM_DEACTIVATE:

   begin

   end;

     CM_ACTIVATE:

   begin

   end;

     else

     begin

   inherited WndProc(Message);

     end;

   end;

 end;



 any ideas what could be wrong here?

 I am trapping other windows messages in other message traps like…



 procedure WMCommand(var Message: TWMCommand); message WM_COMMAND;

     procedure WMActivate(var Msg: TWMActivate); message WM_ACTIVATE;







 Regards from New Zealand (GMT+12)



 Jason Coley

 Software Solutions



 ___
 NZ Borland Developers Group - Delphi mailing list
 Post: delphi@delphi.org.nz
 Admin: http://delphi.org.nz/mailman/listinfo/delphi
 Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject:
 unsubscribe


___
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe


Re: [DUG] Stack Overflow in WndProc

2011-06-02 Thread ja...@software-solutions.co.nz
I have just removed the code in Dostuff, all it was doing however was painting 
a border around the form. I shall try this although I am sure I tried this 
before. The overflow only happens after a while running, thanks I shall report 
back.

Regards from New Zealand (GMT+12)

Jason Coley
Software Solutions

From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On 
Behalf Of Jolyon Smith
Sent: Friday, 3 June 2011 1:01 p.m.
To: 'NZ Borland Developers Group - Delphi List'
Subject: Re: [DUG] Stack Overflow in WndProc

I can't trigger a stack overflow with this WndProc implementation.

Are you sure you haven't pruned out the offending code in the // Do Stuff ?


From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On 
Behalf Of ja...@software-solutions.co.nz
Sent: Friday, 3 June 2011 11:35
To: delphi@delphi.org.nz
Subject: [DUG] Stack Overflow in WndProc

Hi there,

I have been experiencing a Stack Overflow error in my WndProc override and not 
sure why this is

Basic form below..

TMyForm = class(TForm)
...
Protected
procedure WndProc(var Message: TMessage); override;
...
End;

procedure TMyForm.WndProc(var Message: TMessage);
var
  fActive   : Boolean;
begin
  case Message.Msg of
WM_NCPAINT, WM_NCACTIVATE:
  begin
if not IsIconic(Handle) then
begin
  if Message.Msg = WM_NCPAINT then
fActive   := (Handle = 
GetActiveWindow)
  else
fActive   := (Message.wparam  
0);
  if fActive then
  begin
   //Do Stuff
  end;
end;
if Message.Msg = WM_NCPAINT then
begin
  if DwmCompositionEnabled then
inherited WndProc(Message);
end
else
  inherited WndProc(Message);
  end;
CM_DEACTIVATE:
  begin
  end;
CM_ACTIVATE:
  begin
  end;
else
begin
  inherited WndProc(Message);
end;
  end;
end;

any ideas what could be wrong here?
I am trapping other windows messages in other message traps like...

procedure WMCommand(var Message: TWMCommand); message WM_COMMAND;
procedure WMActivate(var Msg: TWMActivate); message WM_ACTIVATE;



Regards from New Zealand (GMT+12)

Jason Coley
Software Solutions

___
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe

Re: [DUG] Stack Overflow in WndProc

2011-06-02 Thread Kyley Harris
Put a break point in and when you hit about 10 deep stack trace the
repeating call.

On Friday, June 3, 2011, ja...@software-solutions.co.nz
ja...@software-solutions.co.nz wrote:
 Hi there, I have been experiencing a Stack Overflow error in my WndProc 
 override and not sure why this is…. Basic form below.. TMyForm = 
 class(TForm)…Protected    procedure WndProc(var Message: TMessage); 
 override;…End; procedure TMyForm.WndProc(var Message: TMessage);var  
 fActive   : Boolean;begin  case Message.Msg of    WM_NCPAINT, 
 WM_NCACTIVATE:  begin    if not IsIconic(Handle) then    
 begin  if Message.Msg = WM_NCPAINT then    
 fActive   := (Handle = 
 GetActiveWindow)  else    fActive     
   := (Message.wparam  0);  if fActive then  
 begin   //Do Stuff  end;    end;    if Message.Msg = 
 WM_NCPAINT then    begin  if DwmCompositionEnabled 
 then    inherited WndProc(Message);    end    else  
 inherited WndProc(Message);  end;    CM_DEACTIVATE:  begin  
 end;    CM_ACTIVATE:  begin  end;    else    begin  inherited 
 WndProc(Message);    end;  end;end; any ideas what could be wrong here?I am 
 trapping other windows messages in other message traps like…    procedure 
 WMCommand(var Message: TWMCommand); message WM_COMMAND;    procedure 
 WMActivate(var Msg: TWMActivate); message WM_ACTIVATE;   Regards from New 
 Zealand (GMT+12) Jason ColeySoftware Solutions

-- 
Kyley Harris
Harris Software
+64-21-671-821

___
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: 
unsubscribe