How to get mouse input from extended frame?

Started by
10 comments, last by Khatharr 8 years, 9 months ago

I have a window which has a extended frame. It looks like this:

fYpXu.png

I've followed all steps in MSDN's guide for extended frames: Custom Window Frame Using DWM.

But the problem is: I can't capture mouse movement over the extended frame. I don't receive the WM_MOUSEMOVE message, and WM_NCMOUSEMOVE is only received on the resize area and on the top part of the extended frame, which is not what I need.

I've already tried SetCapture but it doesn't allows me to minimize, maximize, close, move nor resize the window, not to mention that it shows the "Working..." cursor.

Does someone knows how to solve this?

Advertisement

Almost sounds like your window proc is attached to the wrong window.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

Almost sounds like your window proc is attached to the wrong window.

Couldn't be. All other messages work fine.

You're describing a lot of messages not working fine, though, and they're all associated with the top-level window. Are you sure that the proc isn't somehow attached to the interior window where the rendering is going on?

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

You're describing a lot of messages not working fine, though, and they're all associated with the top-level window. Are you sure that the proc isn't somehow attached to the interior window where the rendering is going on?

What I wanted to say with "I've already tried SetCapture but it doesn't allows me to minimize, maximize, close, move nor resize the window, not to mention that it shows the "Working..." cursor." is that those messages don't work only when I use SetCapture. When I don't use SetCapture all these messages work fine.

PS: Either way, thanks for your answer.

All I can think of is that the proc could be malformed or else messages are just getting sent to the wrong window somehow. Do you get mousemoves when you use SetCapture?

Actually, if you're getting a busy cursor then that suggests that messages aren't being handled and the queue is backing up.

In any case, can you post the relevant code sections (proc, winclass, etc)?

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.
Wild guess here, are you doing the hit testing that extended frames require? Your mention of not being able to minimize or resize and such sounds suspiciously like the following quote from the page you linked:

A side effect of removing the standard frame is the loss of the default resizing and moving behavior. For your application to properly emulate standard window behavior, you will need to implement logic to handle caption button hit testing and frame resizing/moving.


By extending the frame you basically have to take over some of the tasks that Windows used to do for you automatically, because you've told Windows "It's ok, I've got this, I want to paint stuff myself".

All I can think of is that the proc could be malformed or else messages are just getting sent to the wrong window somehow. Do you get mousemoves when you use SetCapture?

Actually, if you're getting a busy cursor then that suggests that messages aren't being handled and the queue is backing up.

In any case, can you post the relevant code sections (proc, winclass, etc)?

I think I'm going to create a child window in that part of the main window. That sould do the trick.

Wild guess here, are you doing the hit testing that extended frames require? Your mention of not being able to minimize or resize and such sounds suspiciously like the following quote from the page you linked:

A side effect of removing the standard frame is the loss of the default resizing and moving behavior. For your application to properly emulate standard window behavior, you will need to implement logic to handle caption button hit testing and frame resizing/moving.


By extending the frame you basically have to take over some of the tasks that Windows used to do for you automatically, because you've told Windows "It's ok, I've got this, I want to paint stuff myself".

Yes, I am. It works if I don't use SetCapture.

Let us know how it turns out, please. I'm interested in this.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

Let us know how it turns out, please. I'm interested in this.

The problem was simpler than I thought. It was a naive response to WM_NCHITTEST: "if it's not a window border, then it's HTNOWHERE". Changing it to HTCLIENT solved my problem. A weird thing is that that MSDN page tells us to use HTNOWHERE.

Godammit MSDN! F*** you!

(No, actually I'm just kidding)

This topic is closed to new replies.

Advertisement