f



subclassed title bar wnd and mouse click

Hello/2.

I subclassed the title bar window of one of my windows in an 
application. Reason is to implement a special processing for a mouse 
button 2 click for that window.

But i can't see a WM_BUTTON2CLICK message.
A WM_BUTTON1DBLCLK or a WM_BUTTON2DOWN message receives the title bar 
window function.
What can i do to get a WM_BUTTON2CLICK message ?

Regards, Peter
0
Peter
10/27/2009 4:57:26 PM
comp.os.os2.programmer.misc 1326 articles. 0 followers. Post Follow

5 Replies
254 Views

Similar Articles

[PageSpeed] 16

There is no trick.  You subclass the window you want to subclass and then 
use WM_BUTTON2DBLCLK etc to catch Mouse button 2.
The only reason to subclass a window is to be able to catch messages that 
are otherwise hidden to you.
If you have a standard window

     hwndFrame = WinCreateStdWindow (
                    HWND_DESKTOP,       /* Parent window handle 
*/
                    WS_VISIBLE,               /* Style of frame window 
*/
                    &flFrameFlags,              /* Pointer to control data 
*/
                    szClientClass,               /* Client window class name 
*/
                    SPVERSION,                /* Title bar text 
*/
                    0L,                            /* Style of client window 
*/
                    langhmod,                  /* Module handle for 
resources     */
                    ID_RESOURCE,        /* ID of resources 
*/
                    &hwndClient) ;         /* Pointer to client window 
handle */

you already have the frame handle as well as the client window handle. 
Assuming you want to do something when the mouse is in the client area then
you don't need to subclass that window as the message is avialable.  But do 
I understand you in that you are subclassing the title bar of a window?
The handle to the title bar you should be able to get using

HwndTitle = WinWindowFromID(hwndFrame,FID_TITLEBAR);

you would then subclass as follows


OrigpProc = 
WinSubclassWindowWinWindowFromID(hwndFrame,FID_TITLEBAR),(PFNWP)TitleBarProc);


and in the TitleBarProc use WM_BUTTON2DBLCLK.

I haven't tried this in a title bar but I do know that even when subclassing 
you don't get everything.
You can cross check that you have the correct handle for the titlebar by for 
exanple changing the text title font to something obvious

using

WinSetPresParam(WinWindowFromID(hwndFrame,FID_TITLEBAR),PP_FONTNAMESIZE,strlen(fontb)+1,fontb);

where fontb is  for example "16.TimesRoman";

Hope this helps

Keith
"Peter Kumpf" <PaleKumNOSPAM@t-online.de> wrote in message 
news:hc78pm$tdj$02$1@news.t-online.com...
> Hello/2.
>
> I subclassed the title bar window of one of my windows in an application. 
> Reason is to implement a special processing for a mouse button 2 click for 
> that window.
>
> But i can't see a WM_BUTTON2CLICK message.
> A WM_BUTTON1DBLCLK or a WM_BUTTON2DOWN message receives the title bar 
> window function.
> What can i do to get a WM_BUTTON2CLICK message ?
>
> Regards, Peter 


0
Keith
10/28/2009 7:48:57 AM
Hello Keith.

Thanks for the answer.

Keith wrote:
> There is no trick.  You subclass the window you want to subclass and then 
> use WM_BUTTON2DBLCLK etc to catch Mouse button 2.
> The only reason to subclass a window is to be able to catch messages that 
> are otherwise hidden to you.
Yes, i know.
> But do I understand you in that you are subclassing the title bar of a window?
Yes.
> 
> and in the TitleBarProc use WM_BUTTON2DBLCLK.
Yes, and WM_BUTTON2DBLCLK is a message that i can "see" im my 
"TitleBarProc". But i can't "see" a WM_BUTTON2CLICK message.

Regards, Peter
> 
> I haven't tried this in a title bar but I do know that even when subclassing 
> you don't get everything.
> Hope this helps
> 
> Keith
> "Peter Kumpf" <PaleKumNOSPAM@t-online.de> wrote in message 
> news:hc78pm$tdj$02$1@news.t-online.com...
>> Hello/2.
>>
>> I subclassed the title bar window of one of my windows in an application. 
>> Reason is to implement a special processing for a mouse button 2 click for 
>> that window.
>>
>> But i can't see a WM_BUTTON2CLICK message.
>> A WM_BUTTON1DBLCLK or a WM_BUTTON2DOWN message receives the title bar 
>> window function.
>> What can i do to get a WM_BUTTON2CLICK message ?
>>
>> Regards, Peter 
> 
> 
0
Peter
10/29/2009 6:17:32 PM
On Thu, 29 Oct 2009 18:17:32 UTC, Peter Kumpf 
<PaleKumNOSPAM@t-online.de> wrote:

> > and in the TitleBarProc use WM_BUTTON2DBLCLK.
> Yes, and WM_BUTTON2DBLCLK is a message that i can "see" im my 
> "TitleBarProc". But i can't "see" a WM_BUTTON2CLICK message.

Are you sure the message is getting generated?  Use pmspy to see where
the message is going?  For this, spy on the message queue and limit 
the spied messages to avoid data overload.

Steven


-- 
---------------------------------------------------------------------
Steven Levine <steve53@earthlink.bogus.net>
eCS/Warp/DIY etc. www.scoug.com www.ecomstation.com
---------------------------------------------------------------------
0
Steven
10/29/2009 8:17:54 PM
Hello Steven.

Steven Levine wrote:
> Are you sure the message is getting generated?
I think, it should be generated. 'Cause i do a right click with the 
mouse over the title bar.
> Use pmspy to see where the message is going?
With PMSPY i can see only a WM_BUTTON2DOWN message. No WM_BUTTON2UP !
Seems the WM_BUTTON2CLICK message isn't generated. BUT WHY ? And why is 
no WM_BUTTON2UP message received ?
(PM SPY reports the same for the left mouse button !)

My subclassed title bar window functions is:

MRESULT EXPENTRY pfnTBarCFunc( HWND hWindow, ULONG ulMsg, MPARAM mp1, 
MPARAM mp2 )

{
  PFNWP             pfnOrgFFunc;

  pfnOrgFFunc = WinQueryWindowPtr( hWindow, UQWL_ORGFUNC );
  if (!pfnOrgFFunc)
  {
   return (MRESULT) FALSE;
  }
  switch( ulMsg )
  {
   case WM_BUTTON2CLICK:
printf("WM_BUTTON2CLICK\n");
   break;

   default: return pfnOrgFFunc( hWindow, ulMsg, mp1, mp2 );
  }
  return (MRESULT) FALSE;
}


This work well for a lot of other windows i subclassed. Why and what is 
different with title bar windows ?

Regards, Peter
0
Peter
10/31/2009 3:02:55 PM
On Sat, 31 Oct 2009 16:02:55 +0100, Peter Kumpf <PaleKumNOSPAM@t-online.de>
wrote:

>> Are you sure the message is getting generated?
> I think, it should be generated. 'Cause i do a right click with the 
> mouse over the title bar.
>> Use pmspy to see where the message is going?
> With PMSPY i can see only a WM_BUTTON2DOWN message. No WM_BUTTON2UP !
> Seems the WM_BUTTON2CLICK message isn't generated. BUT WHY ? And why is 
> no WM_BUTTON2UP message received ?

The message *is* generated. You can see it if you "Select system queue".
(You will need to filter out everything apart from the MouseButton message
group first, otherwise PMSpy will get deluged and hang the system.)

Because the mouse is captured by the button down messages on the title bar,
some other window is getting the messages. That is what "captured" means.
I guess you will need to handle all the button messages yourself and
provide the appropriate functionality, rather than passing the messages
to the default procedure.
0
Paul
10/31/2009 4:52:13 PM
Reply: