+ Reply to Thread
Results 1 to 13 of 13

Help Understanding hook MessageBoxA Positioning with API WindowsHook “User32” dll stuff

  1. #1
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Help Understanding hook MessageBoxA Positioning with API WindowsHook “User32” dll stuff

    Help Understanding hook MessageBoxA Positioning with API WindowsHook “User32” dll stuff

    Hi
    I would like to try and understand as much as possible a code which I may need to use and adapt
    I have tried very hard to find some explanations that I can understand, but I am hitting a brick wall with this one every time. I either cannot find any information, or, the sparse info. that I have found is totally beyond my ability to understand it.

    The code, ( here: https://pastebin.com/0Q2DKn5T
    https://www.excelforum.com/developme...ml#post4830947
    ) , I have Pieced together from various sources and/ or have made up from a lot of trial and error experiments. The section I call Rem 1 I understand after a bit of recent Forum participation. ( That is all about a “pseudo non modal MsgBox”. I have that sussed – No problem there )

    Rem 2 and Rem 3 and Rem 4 parts I have been struggling on now for a week. My brain has become comfortably numb
    I hate working blind and not having a clue what I am doing. I think the code and variations of it could be very useful to me, but I am very reluctant to use it until I can get some understanding of.

    Can anyone put me put of my misery. I have a fairly good basic Excel VBA Knowledge but apart from that I know nothing about computers and programming. There are things going on in this code that are not to be seen by mortals and I need a real computer Expert to help spread some light

    Could anyone explain what is going on in this code , or rather how it is working. If you could do that in as close to Layman’s terms that you can give then I would be very grateful..

    ( I have just started reading a 1500 page book on this that may get me somewhere on this in a few years.. , but any help now could probably save me a lot of time).

    The code is here:
    https://www.excelforum.com/developme...ml#post4830947
    and here:
    https://pastebin.com/0Q2DKn5T
    and in code module “RapeAHook” in the uploaded file

    It works brilliantly: ( I tried it on Excel 2003, 2007 and 2010 on three different computers )
    This is what it does with my best up until now explanation of how..
    The main point of the code is to get up a Pop up Message Box where I want it using the “Windows API” route. This Pop up box I can set to a position at will and also still select the spreadsheet whilst it is up. The Message Box is pseudo non modal, that is to say, unlike the conventional VBA MsgBox Function, it does not “wait” for me to hit OK. It works great just as I want, but I am bugged if I can work out how.

    ( Rem 1 This is the message Box stuff that I am happy with. I have the APIssinUserDLL_MsgBox , and the related code lines near that, well sussed, - no problem there ) .

    Rem 2 Various Declare lines make the Windows API codes available to the main code.
    ( The main code is Sub AkaApiApplicationPromptToRangeInputBox and there is also a single VBA Function code, Private Function HoldRapeAHookPro )

    Rem 3 This is where the main stuff starts , and at the outset globial variables are filled for the left and top position of/ for use in my pop up box. Those get used in some unconventional way and exactly when and how is part of the whole mystery to me… I expect they have to be Globial. I don’t know.

    I am guessing that a code line I have in the main Sub AkaApiApplicationPromptToRangeInputBox of this form = SetWindowsHookExA(__ arguments, , is getting some identifying number for a position on a chain of events. ( I am guessing that when the chain is pulled it waggles and all hell sets loose internally). In its __ arguments, , it does some AddressOf thingy and I can only guess that it somehow makes a note of an address of my VBA Function code, Private Function HoldRapeAHookPro in such a way that when this chain of events is at the said noted reference point then that triggers off the VBA Function code, Private Function HoldRapeAHookPro
    How on earth it then catches my fairly conventional API Message Box procedure call APIssinUserDLL_MsgBox before it brings up that message box and pauses it while it starts that VBA Function code, Private Function HoldRapeAHookPro is a mystery to me
    But that does happen, that is to say the code Sub AkaApiApplicationPromptToRangeInputBox pauses in the code line APIssinUserDLL_MsgBox . Then at that point, seemingly magically , up springs the Function code, Private Function HoldRapeAHookPro

    Function code, Private Function HoldRapeAHookPro then appears not to do much other than returning the value of _ 0 _ ( HoldRapeAHookPro = 0 ) . It does that 5 times. That is to say, after it has finished it starts magically again, 4 times, giving 5 of these runs where it don’t do much.

    After those first 5 not very eventful runs…..It starts a 6th time. As previously it has started possibly due to the sprinkling of Fairy dust.
    This time it appears to do a bit more by virtue of a specific condition being met. This condition is If on the first argument in the function, ( If lMsg = 5. God knows what and where that parameter magically comes from. There is no obvious way to be seen where that parameter is filled. In fact it is a mystery how any of those arguments in the signature line of Private Function HoldRapeAHookPro are filled.
    Any road up, .. at this point we are on the 6th run of the Function. But it has never been called in the conventional way. Consequently no variables have been seen to be passed to it as far as mortal can see. But they are there anyway. Because the If condition was met on the 6th magically started run, a code line is done of the form
    SetWindowPos wParam, 0, poX, pussY, 400, 150, 4
    That code line almost looks sensible and understandable and is probably mainly “setting a windows position” based on some co ordinates and size dimensions in its arguments.
    What however, is far from sensible is that that code line on running actually sets of the Function again. !!! As we almost programmers in the trade say, it “calls” the function again , or it “calls itself” or it does “recursion wonks”. Assuming that this is following the normal VBA recursion routine way of doing things then that means that a fresh copy of the Function is now started whilst the original “calling” Function copy ( the 6th run of the original first copy ) pauses .
    That happens a further 29 times. ( That makes 30 copies in total of the Function running one after the other ).
    Eventually then after the 30th Function copy run , that copy of the Function ends followed sequentially by the other 29 ending. Just before they end two code lines are done:_..
    _.. another Windows API "user32" thingy , UnhookWindowsHookEx
    and the same code line that ways also done by the initial 5 code runs of the function in not recurring runs
    _.. HoldRapeAHookPro = 0
    After that crazy set of operations are finished then the main code un pauses with the message box coming up.
    It is doing exactly what I want… but how????


    I put some code lines on to help see what is going on and have pseudo dumped a Log, obtained via Debug.Print in a few strategic places, ( Here a runny log dump copy: https://www.excelforum.com/developme...ml#post4829796 )
    I don’t know what the stuff in that log means, but maybe it is of significance to someone who knows what is going on in this code.
    _.....

    So, I can’t really make head or tail of the damn thing. There are some really weird things going on when you step through it in Debug F8 mode.

    The code works well. It looks a mess as I am not sure how to organise it in a way that well suits how it is working and what exactly it is doing as I don’t really know what and how it is working.- so, once again…
    The main code bits that most concern me:
    '_-===== 4 main Declaration things I do not fully understand.

    '_-=====Weird thing with an AddressOf in it. I have read loads on this, but I do not understand a word and you get sent off on a never ending path of links trying to get to the bottom of what it all means.

    I am fairly happy with the _ APIssinUserDLL_MsgBox _ code line on its own. That works similarly to a VBA MsgBox. But I do not understand how it works in conjunction with the crazy Function HoldRapeAHookPro(
    '_-====
    Function HoldRapeAHookPro(
    That is weird:.. as you step through the code line _ APIssinUserDLL_MsgBox _ then _ Function HoldRapeAHookPro( _ starts somehow on its own. An If condition ( If lMsg = 5 Then ) is not met which results In the _ Function HoldRapeAHookPro _ being set to 0 ( HoldRapeAHookPro = 0 ) … The function starts again after it finishes … it does that 4 times in total doing the same, so then in effect a total of 5 times.
    It then starts again a 6th time, but this time the If condition is met. As a result an Windows API "user32" thingy, SetWindowPos , starts … and this is weird… that somehow sets the _ Function HoldRapeAHookPro( _ off again, effectively in a recursion process starting another copy run of the _ Function HoldRapeAHookPro( _ . That happens another 29 times making in total 30 separate runs of separate copies of the Function with the If condition satisfied. After the 30th Function copy run , that copy of the Function ends followed sequentially by all the other 29 function copies ending. Just before they end, two code lines are done:_..
    _.. another Windows API "user32" thingy , UnhookWindowsHookEx
    and the same code line that was also done by the initial 5 code runs of the function runs when not recurring
    _.. HoldRapeAHookPro = 0

    Once that strange stuff is finished the Message box, ( APIssinUserDLL_MsgBox ), comes up as I want it.

    Can anyone give me some easy to understand explanations of what is going on.

    Many Thanks
    Alan







    refs:
    Mystery to me is also.. http://listenonrepeat.com/watch/?v=iFZzN5qIiUs .. how she looks so young.
    1500 page Book: “Visual Basic Programmer’s Guide to the Win32 API” by Dan Appleman
    http://listenonrepeat.com/watch/?v=_...mfortably_numb
    http://www.vbforums.com/showthread.p...3-but-not-2007
    https://www.techrepublic.com/blog/10...-applications/
    http://www.eileenslounge.com/viewtop...=28885#p223629
    https://stackoverflow.com/questions/...excel-vba-why/
    http://www.mrexcel.com/forum/excel-q...ox-method.html
    http://www.excely.com/excel-vba/defi...ssagebox.shtml
    Attached Files Attached Files
    Last edited by Doc.AElstein; 01-29-2018 at 06:49 AM.
    '_- Google first, like this _ site:ExcelForum.com Gamut
    Use Code Tags: Highlight code; click on the # icon above,
    Post screenshots COPYABLE to a Spredsheet; NOT IMAGES PLEASE
    http://www.excelforum.com/the-water-...ml#post4109080
    https://app.box.com/s/gjpa8mk8ko4vkwcke3ig2w8z2wkfvrtv
    http://excelmatters.com/excel-forums/ ( Scrolll down to bottom )

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Help Understanding hook MessageBoxA Positioning with API WindowsHook “User32” dll stu

    In simple terms
    - You set a hook, confined to the current thread (so it doesn't get triggered by other things going on) and give it the address of the function that you want to call in response to the hook being triggered. In this case you are using a CBT hook which is triggered generally by Window messages (activating, creating, destroying, minimizing, maximizing, moving, or sizing a window- see here)
    - You then trigger an Inputbox call, which creates a new window for the inputbox. Your code monitors all the window events being created (creating the window etc) and only responds when the Window is activated, at which point it calls the function you specified, passing a couple of parameters (see link). The only one you are interested in here is the wparam which is the window handle, needed for your SetWindowPos call which does pretty much what it says on the tin.
    - Having positioned the window, you then release the hook since it is no longer needed.

    Does that help?
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Help Understanding hook MessageBoxA Positioning with API WindowsHook “User32” dll stu

    At the risk of asking a stupid question, why not just use a userform?

  4. #4
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: Help Understanding hook MessageBoxA Positioning with API WindowsHook “User32” dll stu

    Hi Kyle,
    I am going to look at the Userform alternative as well, … I am getting clued up on UserForms in parallel as well in preparation to that.
    I am trying to get well clued up generally on all the “User Interface Pop up stuff” for a few weeks, then I will consider all the alternatives, and decide what to use for my stuff


    @ Don ,
    Thanks – that is getting me further.. I am having a quick play with my stuff then I will post again


    Alan

  5. #5
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Help Understanding hook MessageBoxA Positioning with API WindowsHook “User32” dll stu

    In response to your rep comment, yes userforms use ActiveX, but they do not "break stuff". Using ActiveX for userforms is not the same as using ActiveX controls on worksheets - it's a completely different thing.

    Even if they did "break stuff" they wouldn't breaks as much stuff as you getting a windows API call wrong

  6. #6
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: Help Understanding hook MessageBoxA Positioning with API WindowsHook “User32” dll stu

    Quote Originally Posted by Kyle123 View Post
    ... Using ActiveX for userforms is not the same as using ActiveX controls on worksheets - it's a completely different ....
    Ah that is very interesting. I have been preparing for some time a Thread question on some problems I am having with controls on worksheets … that point was one going to be of my questions.. I have not posted that yet, but when I do I will bare that in mind. Thanks.
    That will certainly have a big bearing on my decision whether or not to use userforms.
    I am trying to go through and get some experience with the “standard “User Interface Pop up stuff” “ just now
    I have been having a lot of fun this last week braking stuff with my API call experiments. It happened a lot, about 50 times a day. But it has not yet done any permanent damage ( I think and hope )

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Help Understanding hook MessageBoxA Positioning with API WindowsHook “User32” dll stu

    You realise that what you're doing here is not “standard “User Interface Pop up stuff” right? You're meddling with things that are definitively non standard.

  8. #8
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: Help Understanding hook MessageBoxA Positioning with API WindowsHook “User32” dll stu

    so does this mean that I am doing “advanced stuff” ...like an “advanced user” does do
    Last edited by Doc.AElstein; 01-29-2018 at 08:33 AM.

  9. #9
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Help Understanding hook MessageBoxA Positioning with API WindowsHook “User32” dll stu

    Either that or "unnecessary stuff" that a "sensible" user does not do.

  10. #10
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: Help Understanding hook MessageBoxA Positioning with API WindowsHook “User32” dll stu

    Quote Originally Posted by xlnitwit View Post
    Either that or "unnecessary stuff" that a "sensible" user does not do.
    or maybe a special sort of “advanced state of retarded user”… a sort of ” retousism” … going back to remember the possibly useful stuff that everyone forgot..
    _...___________________

    Quote Originally Posted by xlnitwit View Post
    In simple terms......
    Does that help?
    Hi Don, Thanks.
    I think that is a help..

    Can you tell me then if these make sense then.
    _1) The Thread is what is going on, I expect that means in this case my VBA. My computer might do something else with or without me knowing.
    I suppose somehow everything has a thread number.
    _1b) When called / used in my code, Function GetCurrentThreadId will return a number referring to the Excel instance that that code line is in

    _2) CBT hook ****
    I remember reading about that. I had read that link you gave a few times and I was thinking a bit along those lines of what you said…
    That CBT hook is my option 5 here: SetWindowsHookExample(5, ,
    _2b) So what exactly in my code is triggering that? Or is that not clear? Is it just likely to be something of many things that a Message box “opening” might do.. ? –

    _2c) I just replaced my APIssinUserDLL_MsgBox code line with a simple MsgBox
    It sort of did something similar. Except that it resized my Excel spreadsheet window to the size and position of what it had done to my APIssinUserDLL_MsgBox.
    MsgBoxPooResizedMySpreadsheet.JPG https://imgur.com/QjaWggb
    If I think a bit longer I might have an idea what is going on there.
    Do you have any immediate thoughts on that?

    ( I dumped another Log: .. For MsgBox “Poo”:-
    MsgBoxPoo.jpg https://imgur.com/qaBO2tp
    https://www.excelforum.com/developme...ml#post4831335 )


    _2c(ii) _ How’s this.. “The VBA MsgBox is a WRapper for the MessageBoxA….. it effectively gives it to or hooks it in the Excel Window… The VBA MsgBox hooks the MessageBoxA in the Excel Window… so that is the one that gets moved and resized…

    _2c)(iii) I opened up a second instance of Excel and repeated _2c). The results were the same, that is to say nothing happened to the new Excel Instance Window. Is that telling me that the second Excel instance has a different Thread number?

    _.__
    ****_3) CBTProc callback function ( call ) ( https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx )
    In that article I have pseudo
    Function CBTProc(WhatIsAboutToHappen, wParam , lParam ) ‘InumerationWonks Before_WindowActivation = 5 ……………….
    In my code, I have pseudo going on somewhere unseen…like… is .. going on is..:.- „…. code monitors all the window events….”…. ==
    Function CBTProc(WindowAboutToOpen, wParam , lParam

    In my code, I have
    Function HoldRapeAHookPro( lMsg ,wParam , lParam )
    My guess is that ,

    There is clearly some significance to those two parameters , wParam , lParam ,

    But wParam is not a “hidden reserved word” of some sort… I do not have to use that
    So for example if I change all “seen” occurrences of it with something else, thenthere is no problem
    Please Login or Register  to view this content.
    But there is some predefined form to the Private Function HoldRapeAHookPro
    I can get an error if I try to add another parameter to the signature line. So there is some predefined form.

    I can still see the obvious parts of
    ____SetWindowPosition SomeFinkElse, 0, poX, pussY, 400, 150, 4
    But I am still not quite clear on how the SomeFinkElse ( wParam ) is being used, for example it remains a mystery why the Private Function HoldRapeAHookPro does 5 runs itself, followed by 30 recurring copy runs before it stops. There is still a lot there not written on the tin..
    Last edited by Doc.AElstein; 01-29-2018 at 12:14 PM.

  11. #11
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Help Understanding hook MessageBoxA Positioning with API WindowsHook “User32” dll stu

    1) Roughly speaking, yes.
    2) You can set all kinds of hooks- keyboard, mouse, or the one here, which basically monitors windows. Having set the hook, and told it what to call when it is triggered, you fire it by calling your inputbox (which creates a new window). Re 2c, I think we've discussed that already in another question.
    3) The function you set up as the hook callback has to match the CBTProc specification (parameter names are not important, but order, type and number are).
    To be entirely honest, I didn't look at your code, I was commenting based on "Sid's code". Your code style only manages to make an already complex subject more obscure to my eye, I'm afraid.

    Perhaps 'idiot savant' might be the term...

  12. #12
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    MessageBoxA Positioning with API WindowsHook “User32” dll User Inpfuts Plop up stuff

    Hi Don
    I quite like the idea of being an….2 'idiot savant'.”….. but I am not sure if I have found what I am a genius in yet though .. one thing is for sure its not in computing.. lol.

    ….”……kinds of hooks- keyboard, mouse, or the one here, which basically monitors windows. Having set the hook, and told it what to call when it is triggered, you fire it by calling your inputbox (which creates a new window) ….”….. that’s all starting to make a bit of sense to me, Thanks
    ( I think you mean message Box, or maybe not… come to think of it .. I actually look at it like an Input box of a sort.. it can be used to return stuff based in the User’s input.. that is the sort of thing I want to do with it .. I have been calling all this .. “User Interface Pop up stuff” .. I think I will change that to “User Inpfuts Plop up stuff”.. that sounds better and more descriptive. I leave the Interface embedded in the stuff, like exposing of interface stuff, to get stuff up. … that may become a lot less clearer in some future Thread post of mine on the “User Inpfuts Plop up stuff”..

    In the meantime I have tried my basic code in a few variations on different computers and operating systems and Excel versions. It is working consistently. This is encouraging, as I am trying to look at these non standard standard stuff using the standard shipped Windows User 32 dll, libraries, at least I assume that is mostly what I am using. I guess they might themselves call something else. I don’t know. Probably no one knows for sure as Microsoft wouldn’t necessarily tell.

    ……”…..2c, I think we've discussed that already in another question………”…... I expect you may be remembering this https://www.excelforum.com/excel-pro...rary-list.html the “non model” MsgBox
    My APIssinUserDLL_MsgBox was just an example of a more complex fundamental standard non standard more complicated simple way that I am looking at doing stuff with API calls. We got a bit side tracked in that Thread, usefully, as it often turns out, looking at the hook which has helped me in the current issue which is why I initially was looking at the MessageBoxA here.
    The actual MessageBoxA example came from a solution to another thread ( that did not work as it happened ) and we discussed that also, and, also in addition we discussed the working solution which should have been the Shell.Popup but wasn’t as that is broke also , ….. and in that case the more fundamental standard non standard more complicated simple way of the MessageBoxTimeoutA came to the rescue. But that is all by the way. I was not sizing or positioning anything there. That is what I have moved on to do in this Thread.

    That “VBA API List” Thread is left hanging now – I have not forgotten about it… I will Solve it in about 10 years – that’s how long I need to read the 1500 page book – it has no structure that I can make out yet so I will probably have to read it all to find any relevant bits..

    As another slightly aside related thing: About …..”…Sid…..”….. What he did was a workaround that is for the Application.InputBox Method which was broke from the start and got Broker from 2003 to 2007 when the positioning option stopped working.. ( I did some “Blog” posts on that in the meantime last week https://www.excelforum.com/developme...ml#post4828681 https://www.excelforum.com/excel-new...ml#post4827566 )

    What I am attempting now here is to start cutting out the messy middle stuff of relying on something being broken in order that the fix works. I used Sid’s fix for a year or so and had some problem….s possibly that may have been that the broke thing maybe sometimes works so the fix has a different effect…
    I am not taking something that should be able to be sized but sometimes can’t be when it is broke and then making a trick to make it look not broke.
    I do not know if Sid was the original source of the codes I found. I did reference his posts at the start along with the others where I found similar codes. No disrespect to Sid but I want to know how it works, so that I can do it myself and variations of it. It is difficult for me to ask him anyway as my posts often get deleted routinely on first sight where the likes of him hang out.. lol.. ( And if his Avatar is real then I probably don’t want to mess with him anyway … )


    I take Kyle’s point about the UserForm alternative, I just have not got that far yet: I have already finished preparing a Thread weeks ago , on my worksheet control problems I have, but have not got around to post that either yet.

    I am not to concerned just now about API calls causing problems when they are wrong just now at this stage.. , .. I am hoping once I have them correct then they may consistently work and more consistently than some other things.. I want to be sure and not leave it to my or anybodies opinion , although I am very welcome for the experienced people chipping in with their experience based considered opinions. Obviously they are leagues ahead of me in experience.
    I may not use the API stuff eventually, I don’t know yet.
    ( I spent months last year getting quite good at ADO stuff. Then I trashed the approach as for me, other seemingly less professional things were actually miles better… )

    _._________________________
    Anyway.
    Back to “Understanding hook MessageBoxA Positioning with API WindowsHook “User32” dll stuff
    ……”….. 3) The function you set up as the hook callback has to match the CBTProc specification (parameter names are not important, but order, type and number are)….”…...
    That confirms and helps clarify what I was seeing and thinking , thanks

    I am still guessing that the_..
    __AddressOf HoldRapeAHookPro
    in the main Sub code line
    __ hHook = SetWindowsHookExample(5, AddressOf HoldRapeAHookPro, 0, GetCurrentThreadId)
    _.. is what is responsible for the making this function the …..”…. function … set up as the hook callback …”…….. - in other words this is the “ “I’ve been hooked……hold you back, call you back, hold you back, slow ya down”** while the window is sized before it is released to plop up when I am dropped off the hook/ unhooked…” **


    I think I may have noticed something now that I had missed. I was always puzzled by this globial declaration:
    Private hHook As Long
    I have added that to my Debug.Print lines and taken another dump or two.
    Here is a sample again of my dumped log https://www.excelforum.com/developme...ml#post4831382
    In my log that is indeed the number wiped off the chain … that may have been one of my missing links. I had missed that link in the chain of events. Somewhere in the hidden coding that is somehow the identifier for this hidden procedure.
    I expect the original idea from Microsoft was to use the API user32 dll thingy called
    UnHookWindowsHookCodEx hHook####
    To end the hidden ….. …“I’ve been hooked……hold you back, call you back, hold you back, slow ya down……. procedure . My guess is that it probably didn’t work… _....

    _....I was still puzzled why the Function HoldRapeAHookPro goes on a further 29 times after the initial successful satisfied If lMsg = 5 Then run. Possibly this is an accident, a bit like an event code that sets itself off. I note that in all systems and versions etc.. the number of copy runs is in total always with a satisfied If lMsg = 5 _is 1+29=30. Possibly a workaround has been set to stop the processes when the stack reaches 30 #### The original idea was to use the command line
    UnHookWindowsHookCodEx hHook
    To end the procedure . It maybe never worked and the system always went into stack overflow. So they limited the stack to 30 arbitrarily, or probably wired the UnHookWindowsHookCodEx to maximum 30 sequential runs…



    I still don’t see what the significance of the wParam is yet. I suspect the penny may drop on that soon. That could possibly be the Window number of my APIssinUserDLL_MsgBox.

    What may understandably be confusion me is the somewhat imprecise use of the word handle. This might mean to some people at some time a Window identifying number and sometimes the number of a hidden code procedure… maybe… Handle is a generally imprecise word..



    Thanks again for the inpfuts .. I think I am not far off as far as I need to understand this one now.
    Alan

    _._________



    Quote Originally Posted by xlnitwit View Post
    ....Your code style only manages to make an already complex subject more obscure to my eye, I'm afraid....
    No one understands the Beauty of my codes








    ** http://listenonrepeat.com/watch/?v=x..._BACK-original **
    http://www.tek-tips.com/faqs.cfm?fid=4699

  13. #13
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Help Understanding hook MessageBoxA Positioning with API WindowsHook “User32” dll stu

    Every window has a handle (memory location) that uniquely identifies it. Wparam gives you that value so you can use it in other function calls that need it, like Setwindowpos.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Excel VBA Function Method API Windows Function User32.dll Alias Declare Library List . :)
    By Doc.AElstein in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-17-2018, 07:51 PM
  2. [SOLVED] Hook letter formula
    By makinmomb in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 01-05-2017, 09:06 AM
  3. scrabble hook macro
    By makinmomb in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-28-2016, 02:59 AM
  4. [SOLVED] Vowel hook search
    By makinmomb in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-26-2016, 03:10 PM
  5. [SOLVED] user32.dll
    By Hemant_india in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-26-2006, 11:25 AM
  6. Getting a hook on Toolbar Events
    By WhytheQ in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-09-2006, 07:40 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1