Sign in Join

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

Mailing lists / lazarus / 2014-12

why handle is 0?

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

FreeMan

If I'm not wrong I found my bug in the 4. day

Component has :
procedure LMTimer(var Message: TLMTimer); message LM_TIMER;
here is hold to timerevent
....
var B : boolean;
begin
   if csLoading in ComponentState then Exit;
   if (FTimerID = 0) then begin
     FTimerID := SetTimer(Self.Handle, 1, 500, nil); <-- start
    DebugLn(['UpdateTimer;FTimerID > ', FTimerID, ' : Self.Handle >',
Self.Handle]);
   end;
....
here is destroy event of component
var B : Boolean;
begin
   DebugLn(['Destroy;> ', 1]); //destroy started
   if (FTimerID  0) then begin
    DebugLn(['Destroy;FTimerID > ', FTimerID, ' : Self.Handle >',
Self.Handle]);
     B := KillTimer(Self.Handle, FTimerID);
    DebugLn(['Destroy; FTimerID > ', FTimerID, ' : Self.Handle >',
Self.Handle, ' Killed>', B]);
     FTimerID := 0;
   end;
   DebugLn(['Destroy;> ', 2]);//destroy ended

and this is debug lines:

UpdateTimer;FTimerID > 1 : Self.Handle >_*140042733101744*_ TMainIDE.DoFixupComponentReferences UNRESOLVED BEFORE loading 0 Root=FRM_Appointment:TFRM_Appointment RefRoot=DM Refs="MainConn" Destroy;> 1
Destroy;FTimerID > 1 : Self.Handle >_*0*_
Destroy; FTimerID > 1 : Self.Handle >_*0 *_Killed>False Destroy;> 2

where is my handle ? why its "0" if its come 0 howto access self handle so access then childs?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20141211/7d862141/attachment.html>

Reply by email

FreeMan
to FreeMan
Self_Handle: HWND;
I added this variable, and set "Self_Handle := Self.Handle;" in
component "loaded" event, create still have not handle!

Loaded;> 1 Self_Handle >140091380829392 Self.Handle >140091380829392 UpdateTimer;FTimerID > 1 : Self.Handle >140091380829392 TMainIDE.DoFixupComponentReferences UNRESOLVED BEFORE loading 0 Root=FRM_Appointment:TFRM_Appointment RefRoot=DM Refs="MainConn" Destroy;> 1 Self_Handle >140091380829392
Destroy;FTimerID > 1 : Self.Handle >0 Self_Handle >140091380829392 Destroy; FTimerID > 1 : Self.Handle >0 Self_Handle >140091380829392 Killed>True _*<--- timer has to killed or widgetset say lie :)*_ Destroy;> 2
Destroy;> 99 <-- component destroyed last line

reopen form, ofcourse handle changed, but(FTimerID) SetTimer return 2 at this time?

Loaded;> 1 Self_Handle >140091456299056 Self.Handle >140091456299056 UpdateTimer;FTimerID > 2 : Self.Handle >140091456299056 TMainIDE.DoFixupComponentReferences UNRESOLVED BEFORE loading 0 Root=FRM_Appointment:TFRM_Appointment RefRoot=DM Refs="MainConn" Destroy;> 1 Self_Handle >140091456299056
Destroy;FTimerID > 2 : Self.Handle >0 Self_Handle >140091456299056 Destroy; FTimerID > 2 : Self.Handle >0 Self_Handle >140091456299056 Killed>False _*<-- at this time can NOT killed timer so problem start*_ "B := KillTimer(*Self_Handle*, FTimerID);"
Destroy;> 2
Destroy;> 99
QCoreApplication::postEvent: Unexpected null receiver QCoreApplication::postEvent: Unexpected null receiver QCoreApplication::postEvent: Unexpected null receiver

FreeMan wrote 53 lines
If I'm not wrong I found my bug in the 4. day Component has : procedure LMTimer(var Message: TLMTimer); message LM_TIMER; here is hold to timerevent .... var B : boolean; begin if csLoading in ComponentState then Exit; if (FTimerID = 0) then begin FTimerID := SetTimer(Self.Handle, 1, 500, nil); <-- start DebugLn(['UpdateTimer;FTimerID > ', FTimerID, ' : Self.Handle >', Self.Handle]); end; .... here is destroy event of component var B : Boolean; begin DebugLn(['Destroy;> ', 1]); //destroy started if (FTimerID 0) then begin DebugLn(['Destroy;FTimerID > ', FTimerID, ' : Self.Handle >', Self.Handle]); B := KillTimer(Self.Handle, FTimerID); DebugLn(['Destroy; FTimerID > ', FTimerID, ' : Self.Handle >', Self.Handle, ' Killed>', B]); FTimerID := 0; end; DebugLn(['Destroy;> ', 2]);//destroy ended and this is debug lines: UpdateTimer;FTimerID > 1 : Self.Handle >_*140042733101744*_ TMainIDE.DoFixupComponentReferences UNRESOLVED BEFORE loading 0 Root=FRM_Appointment:TFRM_Appointment RefRoot=DM Refs="MainConn" Destroy;> 1 Destroy;FTimerID > 1 : Self.Handle >_*0*_ Destroy; FTimerID > 1 : Self.Handle >_*0 *_Killed>False Destroy;> 2 where is my handle ? why its "0" if its come 0 howto access self handle so access then childs? -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20141211/94c8ec78/attachment.html>

Reply by email

Mattias Gaertner
to FreeMan
Show quoted text 6 lines
FreeMan hat am 11. Dezember 2014 um 12:43 geschrieben: Self_Handle: HWND; I added this variable, and set "Self_Handle := Self.Handle;" in component "loaded" event, create still have not handle!

Don't .

Override InitializeWnd and DestroyWnd.

Mattias

Reply by email