Re: Trouble with DeselectAll()

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



JuneTheSecond wrote:
How about DoCmd?
dc.Window.Application.DoCmd(1213);

DoCmd(1213) behaves exactly like calling DeselectAll(), meaning that it
doesn nothing at all in my event handler.

I've found that calling DeselectAll() twice in a row does work, meaning
that the first call does nothing but the second call does what it is
supposed to. Calling DoCmd(1213) twice also works. This is not a good
work-around for me because the real problem involves exceptions being
thrown is certain cases.

So I reinstalled Visual Studio 2003 and Visio 2003. Same problem. Then
I got a different computer with a clean install of Windows XP and
installed VS 2003 and Visio 2003. Same problem.

I think my problem is related to event handling. Calling DeselectAll
from an event handler seems to be what is broken. Calling it twice in
the same event handler works, but calling it once each in two
subsequent event handlers fails. Using Selection.DeselectAll() works
wrong just like Window.DeselectAll().

Why doesn't this work for me:
- Create a new Visual Studio C# project.
- Add a drawing control and two buttons named Draw and Deselect.
- In the event handler for the Draw button, put:
dc.Document.Pages[1].DrawRectangle(2, 2, 4, 4);
- In the event handler for the Deselect button, put:
dc.Document.Application.Window.DeselectAll();

Run the project and click the Draw button. It draws a square and
selects it so you see the eight green resize handles around it. Click
the Deselect button. The shape is still selected. Why is it still
selected?

Thanks for any help you can give me.

.



Relevant Pages

  • Re: Trouble with DeselectAll()
    ... DoCmdbehaves exactly like calling DeselectAll(), meaning that it ... Calling DoCmdtwice also works. ...
    (microsoft.public.visio.developer)
  • Re: Spanning thread in WS Async Call
    ... I am calling a web service asynchronously as follows ... I want to span thread here to do some operation on the the result data and ... Why don't you do your processing within the event handler? ... John Saunders | MVP – Windows Server System – Connected System Developer ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: How to programmatically invoke Click event of the Button ?
    ... Or if I need to invoke an event of Label class? ... click event handler should call the TakeOrdermethod. ... you can call TakeOrderinstead of calling the ... was just calling your button's OnClick() method to do what the button was ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Idea
    ... its context object could be the control. ... that Sender is a requisite in every event handler, ... And I take it you mean the called code, not the calling code? ... > called in which you pass in a method pointer to set values in the ...
    (comp.lang.pascal.delphi.misc)
  • Re: Call Sub vs. fake a key press
    ... Rather then calling an event handler directly, ... > containing the code and that sub would be called from the If in the open ... > routine and from the stop routine. ...
    (microsoft.public.dotnet.languages.vb)