🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #3856

WM_MOUSEMOVE

#3856
From: JD
Date: Sat, 22 Apr 2006 10:06
132 lines
5713 bytes
I've subclassed a ListView's Header WndProc and the problem I'm
having is (I think) with WM_MOUSEMOVE. More specifically, when
moving the mouse over any of the Column's right boundry, the
cursor changes to crSizeAll and I don't get how because I'm not
passing on the message for processing.

How does it know to change the cursor and how can I change this
behavior?

Minimal sample:

#include "MyListView.h"
//--------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
{
    new TMyListView( this );
}
//--------------------------------------------------------------


//--------------------------------------------------------------
#ifndef MyListViewH
#define MyListViewH
//--------------------------------------------------------------
#include <Classes.hpp>
#include <ComCtrls.hpp>
//--------------------------------------------------------------
#ifdef STRICT
#define HEADERWNDPROC WNDPROC
#else
#define HEADERWNDPROC FARPROC
#endif
//--------------------------------------------------------------
class TMyListView : public TListView
{
    private:
        typedef TListView inherited;
        HWND hHeader;
        LONG HeaderWndProcPtr;
        HEADERWNDPROC OldHeaderWndProc;
        void  __fastcall HeaderWndProc( TMessage &Message );
        void  __fastcall SubclassHeaderWndProc();
        void  __fastcall HeaderMouseMove( TShiftState Shift, int X, int Y );
        MESSAGE void __fastcall CMRecreateWnd( TMessage &Message );
    public:
        BEGIN_MESSAGE_MAP
            VCL_MESSAGE_HANDLER( CM_RECREATEWND, TMessage, CMRecreateWnd )
        END_MESSAGE_MAP( inherited )
    public:
        __fastcall  TMyListView( TComponent* Owner );
        __fastcall ~TMyListView();
};
//--------------------------------------------------------------
#endif

//--------------------------------------------------------------
#pragma hdrstop
#include "MyListView.h"
#include "shlwapi.h"
#pragma package(smart_init)
//--------------------------------------------------------------
__fastcall TMyListView::TMyListView(TComponent* Owner) : TListView( Owner )
{
    Parent = dynamic_cast<TWinControl*>( Owner );
    Align = alClient;
    ShowColumnHeaders = true;
    ViewStyle = vsReport;

    TListColumn *pColumn;
    for( int x = 0; x < 3; ++x )
      {
          pColumn = Columns->Add();
          pColumn->Caption = "Column " + IntToStr(x);
          pColumn->Width   = (Width - 20) / 3;
      }

    TListItem *pItem;
    for( int x = 0; x < 3; ++x )
      {
          pItem = Items->Add();
          pItem->Caption = "Col " + IntToStr(0) + " ,Row " + IntToStr(x);
          for( int y = 0; y < Columns->Count; ++y )
            {
                pItem->SubItems->Add("Col " + IntToStr(y+1) + " ,Row " + IntToStr(x));
            }
      }

    HeaderWndProcPtr = reinterpret_cast<LONG>( MakeObjectInstance(HeaderWndProc) );
    SubclassHeaderWndProc();
}
//--------------------------------------------------------------
__fastcall TMyListView::~TMyListView()
{
    if( hHeader ) ::SetWindowLong( hHeader, GWL_WNDPROC, reinterpret_cast<LONG>(OldHeaderWndProc) );
    FreeObjectInstance( reinterpret_cast<void*>(HeaderWndProcPtr) );
}
//--------------------------------------------------------------
MESSAGE void __fastcall TMyListView::CMRecreateWnd( TMessage &Message )
{
    inherited::Dispatch( &Message );
    SubclassHeaderWndProc();
}
//--------------------------------------------------------------
void __fastcall TMyListView::SubclassHeaderWndProc()
{
    hHeader = ListView_GetHeader( Handle );
    if( hHeader ) OldHeaderWndProc = reinterpret_cast<HEADERWNDPROC>( ::SetWindowLong(hHeader, GWL_WNDPROC, HeaderWndProcPtr) );
}
//--------------------------------------------------------------
void __fastcall TMyListView::HeaderWndProc( TMessage &Message )
{
    switch( Message.Msg )
      {
          case   WM_MOUSEMOVE: HeaderMouseMove( KeysToShiftState(Message.WParam), LOWORD(Message.LParam), HIWORD(Message.LParam) );
                               Message.Result = 0;
                               return;
          case     WM_DESTROY: Message.Result = ::CallWindowProc(OldHeaderWndProc, hHeader, Message.Msg, Message.WParam, Message.LParam );
                               ::SetWindowLong( hHeader, GWL_WNDPROC, reinterpret_cast<LONG>(OldHeaderWndProc) );
                               hHeader = NULL;
                               return;
      }
    Message.Result = ::CallWindowProc( OldHeaderWndProc, hHeader, Message.Msg, Message.WParam, Message.LParam );
}
//--------------------------------------------------------------
void __fastcall TMyListView::HeaderMouseMove( TShiftState Shift, int X, int Y )
{
    //
}
//--------------------------------------------------------------

~ JD
Technical Details
Message-ID: <444a0026$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,75696ebf01497ced,start
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "JD" <nospam@nospam.com>
Sender: "JD" <nospam@nospam.com>
Reply-To: "JD" <nospam@nospam.com>
Subject: WM_MOUSEMOVE
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 64.12.116.201     
X-Forwarded-For: 172.161.30.6
NNTP-Posting-Host: 207.105.83.66
Message-ID: <444a0026$1@newsgroups.borland.com>
Date: 22 Apr 2006 03:06:30 -0700
X-Trace: newsgroups.borland.com 1145700390 207.105.83.66 (22 Apr 2006 03:06:30 -0700)
Lines: 133
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail