[DUG] Stack Overflow in WndProc

Karl Reynolds kreynolds at chocfishsoft.co.nz
Fri Jun 3 12:54:32 NZST 2011


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, jason at software-solutions.co.nz
<jason at 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 at delphi.org.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-request at delphi.org.nz with Subject:
> unsubscribe
>



More information about the Delphi mailing list