locked
Why does Windows change control's Handle? RRS feed

  • Question

  • I wish everybody Yappy New Year!

    I encountered a strange TextBox behavior when exploring its messages according to this method:

    http://www.smartmobiledevice.co.uk/HowTo

    I had seen messages, which Windows sent to the TextBox, until I changed TextBox.ScrollBars property. For example, from ScrollBars.None to ScrollBars.Vertical.

    After that Spy hadn't received one more message for this control. But the TextBox worked absolutely adequately.

    When I disconnected the Spy from an emulator and connected again, I found out, that TextBox Handle had changed ! Handles of other windows (in my case - Form and two Buttons) remained the same, as expected.

    I tried to do this with Windows moile 6 Classic and Professional VGA emulators with the same results.

    I deployed progect, based on NativeWindow class, which intercepts TextBox messages, on Windows mobile 6 device with the same results: after changing TextBox.ScrollBars property no messages for this Handle at all!

    Does anybody have any idea why Windows change TextBox's Handle?

    Thanks.
    Sunday, January 3, 2010 11:55 AM

Answers

  • Yes it does. The reason it does this (that's my story anyhow) is that the scrollbars constitute their own control with a handle. As such when you add/remove them from the text box at runtime, the text box needs to be recreated to register/unregister the scrollbar handle. You can capture the new handle easily in HandleCreated/HandleDestroyed events of the textbox in question.
    Tuesday, January 5, 2010 3:08 AM

All replies

  • Yes it does. The reason it does this (that's my story anyhow) is that the scrollbars constitute their own control with a handle. As such when you add/remove them from the text box at runtime, the text box needs to be recreated to register/unregister the scrollbar handle. You can capture the new handle easily in HandleCreated/HandleDestroyed events of the textbox in question.
    Tuesday, January 5, 2010 3:08 AM
  • Hi Luna Tick!

    Your story seems to me verisimilar.

    Thanks for Your help!

    Best regards,
    Anatoly.
    Tuesday, January 5, 2010 4:35 PM