PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
EBMode works in hook proc set in Add-In-VBForums
Results 1 to 13 of 13

Thread: EBMode works in hook proc set in Add-In

  1. #1

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,308

    EBMode works in hook proc set in Add-In

    Not exactly a question, but there is a related question.

    I just figured out something potentially useful. It seems that a call to EBMode works as one might hope (1=Runtime, 0=DesignTime) when it's called within a hook procedure within an Add-In. Within my Add-In, I was struggling to figure out whether I was in Runtime or DesignTime, so I tried EBMode, and voila.

    It seems that this could be useful for other things as well, such as a small Add-In that could be used for UCs or subclassing to answer this Runtime/DesignTime question. However, testing would be needed to see when EBMode goes true.

    Also, and this is the related question ... I don't know of an easy way to easily get data between an Add-In and the code-window VB code I'm writing. It would obviously have to be through some late-bound object so the project would compile. Or, another idea is to communicate through some property of a form in the project, but that feels sloppy.

    Any ideas on how to communicate between an Add-In and project code?

    Y'all Take Care,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  2. #2
    Frenzied Member
    Join Date
    Feb 2017
    Posts
    1,540

    Re: EBMode works in hook proc set in Add-In

    Quote Originally Posted by Elroy View Post
    Also, and this is the related question ... I don't know of an easy way to easily get data between an Add-In and the code-window VB code I'm writing. It would obviously have to be through some late-bound object so the project would compile. Or, another idea is to communicate through some property of a form in the project, but that feels sloppy.

    Any ideas on how to communicate between an Add-In and project code?
    What data do you want to get?

    You have CodePane and CodeModule objects.

    In the CodePane you have, for instance, properties like CodeModule, CountOfVisibleLines and TopLine and methods GetSelection and SetSelection

    In the CodeModule you have CodePane, CountOfDeclarationLines, CountOfLines, Lines, ProcBodyLine... and methods InsertLines, DeleteLines, Find and others.

    AFAIK there are no events to tell you when the programmer writes something.

  3. #3

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,308

    Re: EBMode works in hook proc set in Add-In

    Hi Eduardo,

    I'm sorry, I wasn't clear about my question. Let's say I've got some Add-In with a Module1 and a variable in it declared as ...

    Code:
    
    Public iValue As Long
    
    

    But now, from my VB6 code (not the Add-In), I'd like to know the value of that iValue variable.

    -------------------

    Also, regarding ...

    Quote Originally Posted by Eduardo- View Post
    AFAIK there are no events to tell you when the programmer writes something.
    I could just hook the keyboard for the thread and do that. I'm already doing something similar with the mouse. However, that's not something I need right now. It would be nice to be able to communicate some data between an Add-In and the p-code of a project I'm writing.

    Thanks,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  4. #4
    Lively Member
    Join Date
    Feb 2019
    Posts
    110

    Re: EBMode works in hook proc set in Add-In

    You could use something like WM_COPYDATA. I am not sure that there is something built in that lets you talk to Add-ins.

  5. #5
    Frenzied Member
    Join Date
    Feb 2017
    Posts
    1,540

    Re: EBMode works in hook proc set in Add-In

    Quote Originally Posted by Elroy View Post
    Hi Eduardo,

    I'm sorry, I wasn't clear about my question. Let's say I've got some Add-In with a Module1 and a variable in it declared as ...

    Code:
    
    Public iValue As Long
    
    

    But now, from my VB6 code (not the Add-In), I'd like to know the value of that iValue variable.
    You have two code environments, 1) the add-in and 2) the host program. If it is not from the add-in then it is from the host program, where the variable declaration is.
    For the variable to have a value, that host program must be running.

    Then, to know its value:

    Code:
    MsgBox iValue
    What I'm missing?

  6. #6

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,308

    Re: EBMode works in hook proc set in Add-In

    Quote Originally Posted by Eduardo- View Post
    You have two code environments, 1) the add-in and 2) the host program.
    Yes, I totally agree, and that's precisely what I'm getting at. It's also interesting that both of those environments are running in the same thread.


    Quote Originally Posted by Eduardo- View Post
    For the variable to have a value, that host program must be running.
    This is what's not entirely true. There are at least three situations I can think of where this isn't true:

    1. Code that's in a UC. This code can execute while in design-mode.
    2. Code that's executed in the Immediate Window, that might even call some Public BAS procedures.
    3. Subclassed procedure code that's executed after the "Stop" button is clicked. This is often used to clean-up subclassing.

    And it's precisely those situations where possibly getting a value out of an Add-In might be useful.

    Thanks,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  7. #7

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,308

    Re: EBMode works in hook proc set in Add-In

    @qvb6: Yes, I'm quite familiar with WM_COPYDATA. However, in addition to the Add-In, that'd take a form in the project dedicated to the Add-In communications. I was hoping for something a bit more simple. But that's certainly an option.

    Thanks,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  8. #8
    Frenzied Member
    Join Date
    Feb 2017
    Posts
    1,540

    Re: EBMode works in hook proc set in Add-In

    Quote Originally Posted by Elroy View Post
    This is what's not entirely true. There are at least three situations I can think of where this isn't true:

    1. Code that's in a UC. This code can execute while in design-mode.
    2. Code that's executed in the Immediate Window, that might even call some Public BAS procedures.
    3. Subclassed procedure code that's executed after the "Stop" button is clicked. This is often used to clean-up subclassing.

    And it's precisely those situations where possibly getting a value out of an Add-In might be useful.

    Thanks,
    Elroy
    In all cases the code is running.

    Anyway, MsgBox iValue was what you were asking for? (I don't think so)

  9. #9
    Frenzied Member
    Join Date
    Feb 2017
    Posts
    1,540

    Re: EBMode works in hook proc set in Add-In

    I think what you want is to get the iValue variable value from the add-in.

    The host program might be in design mode, but still some parts be running.
    As I understand it, it takes times. The moments that those parts are running are shown in the IDE because the caption of the IDE's window says "...[running]"

    One way to deal with the issue would be to see them as comunicating two separate programs, something as qvb6 aproach.
    There are many ways to communicate two programs as I think that you already know (messages, DDE, files, registry, SetProp/GetProp, Etc.)

    Other aproach would be to expose that variable value as a property of an UserControl. That property value could be fetched by the add-in.

    What do you think?

  10. #10

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,308

    Re: EBMode works in hook proc set in Add-In

    Hi Eduardo,

    Yes, those are some good ideas. I'm working on another Add-In at the moment, and I'll start playing with this AddIn-to-Program communication after I finish this other little project. And yeah, you're right about EbMode. I haven't worked out all the details, but it does seem that an AddIn might be able to figure out a basic state of EbMode (running P-Code, designing, running but in break-mode). I'll have to play around with it.

    Thanks,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  11. #11
    Lively Member
    Join Date
    Feb 2019
    Posts
    110

    Re: EBMode works in hook proc set in Add-In

    Instead of pulling EBMode, you can get an event from VB when running/stopping a project. These are undocumented events in "Microsoft Visual Basic 6.0 Extensibility". Open Object Browser(F2), right-click anywhere, then enable "Show Hidden Members", then search for "VBBuildEvents". You will find these 3 events:

    BeginCompile(VBProject As VBProject)
    EnterDesignMode()
    EnterRunMode()

    I learned about them from a simple Add-in called ImmClear(and the Readme mentions Addin newsgroups). This Add-in clears the Immediate window when you start a project. You can find the Add-in here, along with the source code.

  12. #12
    Lively Member
    Join Date
    Feb 2019
    Posts
    110

    Re: EBMode works in hook proc set in Add-In

    Also, when clicking on menu items or the toolbar in VB6 IDE, VB sends a message to VB main window with message ID: &H1044. wParam contains the ID of the item clicked. Here are the ones that relates to running projects from an Add-in that I have made:

    VB Code:
    1. Public Function VB6IDEWindowProc(ByVal hwnd As Long, ByVal uMsg As Long, _
    2.     ByVal wParam As Long, ByVal lParam As Long) As Long
    3.    
    4.     If hwnd = hWndVB6IDE Then
    5.         Select Case uMsg
    6.             Case &H1044: ' VB6 IDE Toolbar or menu item clicked
    7.                 Select Case wParam
    8.                     Case &H31: ' Start <F5>
    9.                     Case &H32: ' Start With Full Compile <Ctrl+F5>
    10.                     Case &HE1: ' Make EXE
    11.                     Case &H30: ' Break <Ctrl+Break>
    12.                     Case &H33: ' End
    13.                     Case &H34: ' Restart <Shift+F5>
    14.                     Case &H35: ' Step Into <F8>
    15.                     Case &H36: ' Step Over <Shift+F8>
    16.                     Case &HAA: ' Step Out <Ctrl+Shift+F8>
    17.                     Case &H37: ' Run To Cursor <Ctrl+F8>
    18.                     Case Else
    19.                         VB6IDEWindowProc = CallWindowProc( _
    20.                             oldVB6IDEWindowProc, hwnd, uMsg, wParam, lParam)
    21.                         Exit Function
    22.                 End Select
    23.                 'VB6IDEWindowProc = 0 ' Cancel the click
    24.                 VB6IDEWindowProc = CallWindowProc(oldVB6IDEWindowProc, _
    25.                     hwnd, uMsg, wParam, lParam)
    26.             Case Else
    27.                 VB6IDEWindowProc = CallWindowProc(oldVB6IDEWindowProc, _
    28.                     hwnd, uMsg, wParam, lParam)
    29.         End Select
    30.     Else
    31.         VB6IDEWindowProc = CallWindowProc(oldVB6IDEWindowProc, hwnd, uMsg, _
    32.             wParam, lParam)
    33.     End If
    34. End Function
    Last edited by qvb6; Apr 18th, 2019 at 05:11 AM.

  13. #13

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,308

    Re: EBMode works in hook proc set in Add-In

    Thanks qvb6,

    It looks like good stuff. I'll definitely take a look.

    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width