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

Win32 helper #894

Closed
retailcoder opened this issue Dec 23, 2015 · 15 comments
Closed

Win32 helper #894

retailcoder opened this issue Dec 23, 2015 · 15 comments
Labels
enhancement Feature requests, or enhancements to existing features. Ideas. Anything within the project's scope. status-declined This will not be implemented. up-for-grabs Use this label in conjunction with a difficulty level label, e.g. difficulty-02-ducky

Comments

@retailcoder
Copy link
Member

Let's make a little tool that will bring up a browser dialog that lists some commonly used User32 and Kernel32 functions and procedures, and inserts the appropriate Declare statements for 32 and/or 64-bit. There should be a small description for each function, and a small preview box showing the code to be inserted.

When 64-bit is selected, declare statement should use the PtrSafe keyword, and when both 32 and 64 bit are selected, code should include an #If directive to conditionally compile the declaration.

The helper should allow inserting multiple declarations at once, and place the multiple x64 declarations inside a single #If directive.

@retailcoder retailcoder added feature-request up-for-grabs Use this label in conjunction with a difficulty level label, e.g. difficulty-02-ducky labels Dec 23, 2015
@ThunderFrame
Copy link
Member

Does this feature need to work in conjunction with SmartIndenter, so that compiler directives and declare statements are indented and line-continued upon insertion?

@ThunderFrame
Copy link
Member

Would also be great if this helper could create the required Types for function structs, and enums for function parameters.

@retailcoder
Copy link
Member Author

@ThunderFrame I wouldn't make it depend on the indenter; the code could easily be inserted "pre-formatted" - running the indenter would then make it conform to whatever options the user configured it for.

@retailcoder
Copy link
Member Author

And yeah, it should create the needed types on the fly if they don't already exist in the active project.

@ThunderFrame
Copy link
Member

Might be good to put the definitions into XML format. That would allow us to filter/find functions suitable for the platform, apply category tags, define dependencies.
It would also allow obscure MS APIs and 3rd party APIs to be added to the project, or by end users.

@retailcoder
Copy link
Member Author

retailcoder commented Jan 12, 2016 via email

@ThunderFrame
Copy link
Member

might also be nice to build classes and callbacks for functions that require them. Eg. CopyFileEx and CopyFile2ProgressRoutine

@ThunderFrame
Copy link
Member

and finally (this might be a separate issue)...
Encapsulate, by library, the RegisteredFunctions under Excel, so you can call a function with Intellisense, instead of Application.Run(...)

@ThunderFrame
Copy link
Member

I had a look at how the PInvoke VS extension gets function declarations. The extenaion gets the full declaration (in both VB.Net and C#) in an XML SOAP request.

Being a full declaration, it doesn't break the arguments, types and return types down into XML nodes.

But the XML schema could be enhanced to handle that.

@rubberduck203
Copy link
Member

👍

@ThunderFrame
Copy link
Member

This probably isn't capturing enough detail, and the schema could probably be tweaked, but this is what I'm thinking...

<?xml version="1.0" encoding="UTF-8"?>
<signatures>
  <types>
    <struct name="RECT">
      <member ordinal="0" name="Left" type="Long" />
      <member ordinal="1" name="Top" type="Long"  />
      <member ordinal="2" name="Right" type="Long"  />
      <member ordinal="3" name="Bottom" type="Long"  />
    </struct>
  <types>
  <functions>
    <function library="user32" name="GetWindowRect" Win64="1" Win32="1" WinMin="5" WinMax="-1" tags="window,rectangle" Unicode="-1" ANSI="-1">
      <argument ordinal="0" name="hWnd" direction="in" type="Long" />
      <argument ordinal="1" name="lpRect" direction="out" type="struct.RECT" />
      <return type="Boolean" />
    </function>
  </functions>
</signatures>

@coramuirgen
Copy link

Hi guys,

I'm not sure if this is helpful since @ThunderFrame might have a way to implement PInvoke's VS extension method already, but I requested a copy of a sqlite database from Dennis Wallentin via Ron de Bruin's website who compiled the api declarations for vba some time ago. It's also not very granular but a fair amount of work has been done and it looks to be high quality after some perusal of tricky cases.

I was going to use this personally. I don't know if this would be overkill for rd but my thought was to store the declarations in an external repository, scan my projects (or a helper class) for api calls just in time for compilation, and then write the found api references to a public module in my project using the proper conditional compilation constants for supporting 32bit, 64bit, vba7 etc.

Either way, here is the database attached:
win32 declarations vba.zip

@Vogel612 Vogel612 added this to the Future Versions milestone Oct 20, 2016
@rubberduck203
Copy link
Member

Hey @coramuirgen! Thank you very much for the leg work! The team appreciates it.

@coramuirgen
Copy link

Dennis, who contributed the db, is really interested to hear about rd and wants to "spread the word"/write a review about it when v2 is out. He occasionally writes pieces for Daily Dose of Excel. I'll let him know, and his address is Dennis Wallentin consult@excelkb.com.

@retailcoder retailcoder added the status-declined This will not be implemented. label Jan 13, 2017
@retailcoder
Copy link
Member Author

out of scope. a plugin for this isn't out of question though

@Vogel612 Vogel612 added enhancement Feature requests, or enhancements to existing features. Ideas. Anything within the project's scope. and removed feature-request labels Aug 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests, or enhancements to existing features. Ideas. Anything within the project's scope. status-declined This will not be implemented. up-for-grabs Use this label in conjunction with a difficulty level label, e.g. difficulty-02-ducky
Projects
None yet
Development

No branches or pull requests

5 participants