GetProperty("Window", "HANDLE")

Creative ideas/suggestions for HMG

Moderator: Rathinagiri

Post Reply
KDJ
Posts: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

GetProperty("Window", "HANDLE")

Post by KDJ »

If a window is not defined, GetProperty("WindowName", "HANDLE") causes run-time error.
Maybe in this case the function should return 0?

Now in event handler I am using:
IF IsWindowDefined("WindowName") .and. (nHWnd == GetProperty("WindowName", "HANDLE"))
...
ENDIF

It could be shortened:
IF nHWnd == GetProperty("WindowName", "HANDLE")
...
ENDIF
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: GetProperty("Window", "HANDLE")

Post by srvet_claudio »

It is the responsibility of the programmer to check if the window/control is defined. All properties produces runtime error if a control or window is not defined.

The default return values when a programming error occurs at runtime generate black boxes in the code that are difficult to debug. A well written code can never produce an execution error, this last one more that a complication is a help and insurance for the programmer.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
KDJ
Posts: 243
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland

Re: GetProperty("Window", "HANDLE")

Post by KDJ »

Claudio, thank you very much for your explanation.
Post Reply