bluetree999 :感謝你的回應~雖然我是學C++,但是還是有一點懂Delphi的語法,你的做法是在用滑鼠的事件去達成的...所以..我用了C++ 試了一下...
以下是我的CODE:
h.檔
//--------------------------------------------------------------------------- #ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include
#include
#include
#include <Forms.hpp>
#include
#include
#include
#include
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TDBGrid *DBGrid1;
TTable *Table1;
TDataSource *DataSource1;
void __fastcall FormCreate(TObject *Sender);
private: // User declarations
TWndMethod oldDBGridProc;
void __fastcall DBGridWndProc(Messages::TMessage &Message); public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif cpp.檔
//--------------------------------------------------------------------------- #include
#pragma hdrstop #include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
void __fastcall TForm1::DBGridWndProc(Messages::TMessage &Message)
{
short int Delta;
if ( Message.Msg == WM_MOUSEWHEEL ) {
Delta = Message.WParamHi;
if ( Delta < 0 )
Table1->Next();
if ( Delta > 0 )
Table1->Prior();
}
else
oldDBGridProc(Message);
}
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
oldDBGridProc = DBGrid1->WindowProc;
DBGrid1->WindowProc=DBGridWndProc;
}
//---------------------------------------------------------------------------
以上只供参考
還是再次感謝bluetree999
< >< >