Recent

Author Topic: [SOLVED] Questions regarding PopupNotifier  (Read 2581 times)

MathMan

  • Sr. Member
  • ****
  • Posts: 325
[SOLVED] Questions regarding PopupNotifier
« on: September 21, 2014, 01:35:10 am »
Hi all,

I am currently using Lazarus 1.2.4 with FPC 2.6.4 on Win7 / 64bit on my notebook with Intel CPU.

What I would like to do is indicate progress to the user when processing a test pattern file. I thought that using the PopupNotifier is an easy way to do this. However I struggle a lot with this component - very probably due to my so far limited experience with object oriented programming.

I looked up the PopupNotifier demo and tried to follow it - that is I included the PopupNotifier in my form and tried to initialize and use it like follows

Code: [Select]
  TLongCalc = class(TForm)
    MainMenu1: TMainMenu;
    ...
    WorkNote: TPopupNotifier;
    ...
    procedure TestAllClick(Sender: TObject);

procedure TLongCalc.TestAllClick(Sender: TObject);

var
  TestPatternName: string;

  fTestPattern: TEXT;
  fResult: TEXT;

  TestDialog: TOpenDialog;

begin
  TestDialog := TOpenDialog.Create( Self );
  TestDialog.Title := 'Select test pattern file ...';
  TestDialog.Filter := 'Text file|*.txt|All files|*.*';

  if( TestDialog.Execute ) then
  begin
    TestPatternName := TestDialog.FileName;

    WorkNote.ShowAtPos( 100, 100 );

    ShowMessage( TestPatternName );
  end else begin
    ShowMessage( 'No file selected ...' );
  end;

  TestDialog.Destroy;
end;

This however generates SIGSEGV - and I can't find out what I am missing. The PopupNotifier demo contains a pre-compiled init that I can't decipher and probably contains the parts I am missing. What I did see however when looking through the PopupNotifier unit is that it seems to be related to a TComponent and not a TForm ...

Any help would be highly appreciated.

Kind regards,
Jens
« Last Edit: September 21, 2014, 11:47:10 am by MathMan »

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Questions regarding PopupNotifier
« Reply #1 on: September 21, 2014, 03:20:03 am »
You did not create an instance of TPopupNotifier at run-time nor at design-time.

Either put this line:
Code: [Select]
  WorkNote := TPopupNotifier.Create(Self);
before you call ShowAt. Don't forget to call WorkNote.Free when you are done with it.

Or, at design time:
1-Delete WorkNote from your form.
2-Click on the Common Controls tab
3-Choose TPopupNotifier
4-Drop it anywhere on your form
5-Name it WorkNote.
This way you do *not* need to create/destroy it!

MathMan

  • Sr. Member
  • ****
  • Posts: 325
Re: Questions regarding PopupNotifier
« Reply #2 on: September 21, 2014, 11:46:31 am »
You did not create an instance of TPopupNotifier at run-time nor at design-time.

Either put this line:
Code: [Select]
  WorkNote := TPopupNotifier.Create(Self);
before you call ShowAt. Don't forget to call WorkNote.Free when you are done with it.

Or, at design time:
1-Delete WorkNote from your form.
2-Click on the Common Controls tab
3-Choose TPopupNotifier
4-Drop it anywhere on your form
5-Name it WorkNote.
This way you do *not* need to create/destroy it!

Thanks engkin! I thought that I had these two options tested myself - but it was late and I made some stupid mistakes. When adding the PopupNotifier on my form I only renamed it in my sources and when I tried the dynamic creation I did

Quote
  WorkNote := WorkNote.Create( Self );

Both of course also generated SIGSEGV  :) Oh my - at least good to see that I do understand the general principle (but have to be more careful in my programming).

Regards,
Jens

 

TinyPortal © 2005-2018