Board index » delphi » EAccessViolation when I show a popupmenu. BUG?

EAccessViolation when I show a popupmenu. BUG?

Hi

I got this code attached to a button:

Var
    FormXLeft, FormYTop: Integer;
begin
    FormXLeft := frmOptions.Left;
    FormYTop := frmOptions.Top;

    mnuSelectFileAndPlayer.popup(FormXLeft, FormYTop);
End;

If I run it like this I get a EAccessViolation with message 'Access violation at
address 0048C6CE in module 'project1.exe''. Read of address 00000040'.

If I change popup line and only use number if work but if I use FormXLeft and/or FormYLeft
I get a error. Or use frmOptions.Left and/or := frmOptions.Top.

I can't find any wrong with form, button or popupmenu.

// Peter

 

Re:EAccessViolation when I show a popupmenu. BUG?


Quote
In article <3b3e8e5a_2@dnews>, Peter wrote:
> Var
>     FormXLeft, FormYTop: Integer;
> begin
>     FormXLeft := frmOptions.Left;
>     FormYTop := frmOptions.Top;

>     mnuSelectFileAndPlayer.popup(FormXLeft, FormYTop);
> End;

> If I run it like this I get a EAccessViolation with message 'Access violation at
> address 0048C6CE in module 'project1.exe''. Read of address 00000040'.

My bet is that frmOptions has not been created yet or at least the reference
in the frmOptions variable is not valid.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.

Re:EAccessViolation when I show a popupmenu. BUG?


Hi
Thanks for respond.

I used your code from another message (Button to popup menu with focus),
and that one worked and it was easyer to use.

// peter

Other Threads