Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-08

Help with AllocateHwnd in Lazarus 0.9.30 on WindowsXP

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Curt Carpenter

I have a non-visual component that uses AllocateHwnd and DeAllocateHwnd. My component compiles, but
gives me a 'RunError(217)' when I try to use it in a test program . The error is occurs at the AllocateHwnd instruction in my component's constructor, where the exact usage is:

              if not (csDesigning in ComponentState) then FNotifyWnd :=
AllocateHWnd(@TimerWndProc);

TimerWndProc is declared in the protected section of my component code.

Can anyone tell me if AllocateHwnd is implemented in my version of Lazarus, and where I may be going wrong in
my usage? I'm stumped. I see that it was discussed quite a bit in 2007, but not sure of the current status.

Any input appreciated.

PS: if I try

        if not (csDesigning in ComponentState) then FNotifyWnd :=
AllocateHWnd(TimerWndProc);

the component won't compile. But I've seen this usage at various places too.

Reply by email

Max Vlasov
to Curt Carpenter
Curt Carpenter wrote 5 lines
Can anyone tell me if AllocateHwnd is implemented in my version of Lazarus, and where I may be going wrong in my usage? ?I'm stumped. ? I see that it was discussed quite a bit in 2007, but not sure of the current status.

As I understand potentially any WidgetSet can implement such functionality, but only windows-related actually implemented it. If you're going to use it only in Windows, it should work. But for cross-platform solution you will probably need something else. If your timer does not require great accuracy /resolution and your program is lcl-based, I think the safest bet is to use TTimer directly, programmatically creating and destroying it. Otherwise (you program is console one, you need micro-second accuracy) imho you have to implement it on every OS by yourself.

Max

Reply by email