1

I am working on a MFC C++ application. I was working on a dialog that has SystemMenu property set to FALSE, so it does not have the ability to maximize. I want to handle the double-click message on the title bar. How can I do that?

EDIT:

I hope this time it will be clear for everybody. I have a dialog that does not have system menu (and system buttons or icon). When the user double-clicks the titlebar of that dialog, I want the program to call function x();.

Victor
  • 13,914
  • 19
  • 78
  • 147
  • What have you tried? Have you tried [intercepting messages](http://stackoverflow.com/questions/843711/how-do-i-intercept-messages-being-sent-to-a-window) sent to your application's root window? –  Jan 07 '13 at 20:07
  • I tried just searching through the Windows messages... I am not so "old" in VC++ – Victor Jan 07 '13 at 20:13
  • Do not reuse shortcuts known to user (like titlebar dblclick) for another function. It may seem cool to you, but it's just making fool out of users. – Agent_L Jan 07 '13 at 20:37

2 Answers2

5

Technically, you would have to handle WM_NCLBUTTONDBLCLK and check if the double click occurred in the caption area of the window, possibly by sending it WM_NCHITTEST and testing that the return value is HTCAPTION.

(Update: As JohnCz rightfully points out, sending WM_NCHITTESTis not actually necessary, since WM_NCLBUTTONDBLCLK already carries its result in wParam.)

Then you would only have to send WM_SYSCOMMAND with SC_MAXIMIZE in wParam to the window to maximize it.

In practice, however, it will not achieve much if your dialog box is not ready to handle size changes and layout its controls accordingly. This feature did not come out of the box in MFC last time I checked.

Frédéric Hamidi
  • 258,201
  • 41
  • 486
  • 479
  • my diolog is no made to be resized or maximized – Victor Jan 07 '13 at 20:19
  • thanks. but I made the dialog not to be resized by myself, this is what I want. :) – Victor Jan 07 '13 at 21:01
  • btw. If you add some code to your answer, it will be better. I will mark it anyway, couse I believe what you wrote here is true. – Victor Jan 07 '13 at 21:03
  • @Victor, you're right that a code sample makes better answers, but it also makes better questions :) If you update your question with the code of your dialog box class, it will be easier for us to help you extend it (and test the results). – Frédéric Hamidi Jan 07 '13 at 21:08
  • Now I am not in front of my computer, but as soon as I can, I will provide you anything you need to help me. – Victor Jan 07 '13 at 21:12
  • @Victor, perhaps we both misunderstood. Do you want the double-click to maximize the window, or do you want it to perform some other function? – Mark Ransom Jan 07 '13 at 22:11
  • I want the doble-click to perform some other operation, not to maximize the window – Victor Jan 08 '13 at 19:04
1

I think there is some kind of confusion here:

Frédéric Hamidi

You are correct, handling WM_NCLBUTTONDBLCLK message is the right way to go, however it is no necessary to call HitTest, since WM_NCLBUTTONDBLCLK message delivers hit information that MFC framework translates in the WM_NCLBUTTONDBLCLK handler.

Victor,

What is exactly that you are trying to achieve by handling WM_NCLBUTTONDBLCLK message?

Maybe there is some other way to fulfill your requirement once you make it clear to us. The fact that you do not have system menu, does not prevent your app from receiving non-client area messages.

JohnCz
  • 1,613
  • 1
  • 9
  • 9