|
-
Aug 23rd, 2000, 12:10 PM
#1
Thread Starter
Lively Member
I am wondering if this can be done with subclassing, I am trying to "Change" code for a close button on another program, so when the person clicks the little x it sets the window to nottopmost instead of closing it. If this is possible please show me an example or where I can find one.
Thank you,
Jeremy H
-
Aug 23rd, 2000, 01:37 PM
#2
Monday Morning Lunatic
You cannot subclass out of your own thread. (Please don't ask for the reason, it's very complicated and I don't understand it. I believe Sam Finch knows)
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 23rd, 2000, 02:01 PM
#3
Guru
The reason is: MSDN said so. 
Really, that is the true reason.
Windows programmers decided to only let you Subclass windows in your own thread.
-
Aug 23rd, 2000, 02:05 PM
#4
Monday Morning Lunatic
I think it's to do with the way Windows handles thunks...jeez. What a stupid name
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 23rd, 2000, 03:34 PM
#5
Frenzied Member
Parksie's right, It's a thunk thing.
I'm not exactly sure why windows uses thunks or why they're called thunks, you'd have to ask Bill (of the Gates variety)
I think they are to do with the way windows interfaces between Virtual Memory and physical memory where code is concerned, when compiled code runs it doesn't bother with virtual memory, an instruction runs, and then goes straight on to the next place in physical memory and runs whatever's there.storing large amounts of code in virtual memory won't work because the next address in Virtual memory is not neccacerally the next address in physical memory (For the superheroes guide to virtual memory see Here
but if we want to call some code from an address we need to give an address in virtual memory, because the windows programmer doesn't know where anything in his program will be in physical memory.
To get around this windows used something called a thunk, it's a small piece of machine code in Virtual Memory, when the programm calls a procedure he actually calls the thunk, and the thunk calls the actual procedure.
The way a Standard Dll exports its functions of by exporting these thunks, when you load a dll into your process (which you must do when you use it) you map virtual adresses in your process to the thunks exportad by the dll, you can then call these thunks and use the functions in the dll.
So if you want to subclass a window that isn't in your procedure and you use SetWindowLong to indicate where the thunk for your window procedure is it will look at that address in its own process, and it won't find it, however if we write our procedure into our dll we can force the foreign procedure to inject our dll, and hence it can access our thunk.
Unfortunaltey VB Can't create standard dlls and we can't subclass foreign procedures.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|