Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow End or GUI stop button when debugging TimerProcs #1

Open
Greedquest opened this issue Jul 9, 2020 · 1 comment
Open

Allow End or GUI stop button when debugging TimerProcs #1

Greedquest opened this issue Jul 9, 2020 · 1 comment

Comments

@Greedquest
Copy link
Owner

Right now, there is a known limitation that Ending code execution of a TimerProc (through the debugger + Stop button, or the End keyword) will crash Excel. This is because stopping the TimerProc from returning means WinAPI never gets a response from Excel, and there is no way of catching the Error with VBA code as End destroys everything.

Now RubberDuck uses a clever method of invoking methods in their test explorer which circumvents this issue

https://github.com/rubberduck-vba/Rubberduck/blob/e498d9501935428f1a4918b228429c273e56687f/Rubberduck.VBEEditor/ComManagement/TypeLibs/TypeInfoVBEExtensions.cs#L141

However this cannot be implemented directly in VBA since even if the method of invoking catches End statements, there needs to be some code to handle that caught error, and if it's VBA then it will be destroyed - https://chat.stackexchange.com/transcript/message/54875311#54875311

There are 3 solutions I can think of:

  1. Use the RD method of invocation, but write some assembler to convert from WinAPI timer procs and whatever signature the invocation requires, and this way VBA is avoided entirely

  2. Create an addin in C# or VB6 perhaps which does what RD does natively and is unaffected by the code termination

  3. Write the error handling stuff in native assembler and forward the function call through that

@cristianbuse
Copy link

I came across this repo by mistake and I remembered I saw on your GitHub account that you have a massive repo with timers and subclassing. I am having the same issue as you in my repo but I have it with hooking the mouse. I just thought you might want to see it. The owner does assembler as you mentioned here, but in a really cool way with no need for addins or dlls. Unfortunately it's a VB6 repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants