ComputerBooks.ru - Электронные книги, самоучители.

 
Электронные кники доступные для скачивания
На главную Добавить в избранное Форма отправки почты Если книг читать не будешь - скоро грамоту забудешь!

56. FAQ o Win API

Q> Как обрабатывать сообщения от колеса ms intellimouse?
A>

Для BCB: (не работает в Win95)

в файле unit1.h:

#ifndef WM_MOUSEWHEEL
#define WM_MOUSEWHEEL                   0x020A
#endif
.
.
.

 public:                       // User declarations

     __fastcall TForm1(TComponent * Owner);

void __fastcall OnWheel(TMessage &msg);

BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(WM_MOUSEWHEEL,TMessage,OnWheel)
END_MESSAGE_MAP(TForm)

в файле unit1.cpp:

void __fastcall TForm1::OnWheel(TMessage &msg)
{

if(HIWORD( msg.WParam)<=32512)
{ <moved up> };
else
{ <moved down> };

}

Для MSVC:

The IntelliMouse (the mouse with the wheel in the center) is pretty neat.
You can register to get the wheel messages from it in your top level frame. 
If you want to handle the message in a view you must pass the message down 
manually as is illustrated. To get messages from the wheel add the following 
to your application:

To make the wheel act like a simple middle button just add handlers for:

WM_MBUTTONDOWN
WM_MBUTTONUP

and so-on just like left and right buttons. 
You won't find this in the class wizzard but you can add them manually.
  
For wheel messages do the following:

Declare a global in your app as follows:

UINT uMSH_MOUSEWHEEL;

and everyplace else declare an external so you can get at it
extern UINT uMSH_MOUSEWHEEL;
  
In your initialization code register the following message
uMSH_MOUSEWHEEL = RegisterWindowMessage("MSWHEEL_ROLLMSG");
  
(In the MAIN FRAME add the following:

To the message map in the .H file add
afx_msg LONG OnWheel(UINT a, LONG b);

To the message map in the .CPP file add
ON_REGISTERED_MESSAGE(uMSH_MOUSEWHEEL,OnWheel) 

And then add the message handler as follows

LONG CMainFrame::OnMouseWheel(UINT nFlags, LONG pValue) 
{
        if(nFlags & 0x0100) // Rolled in
        {
                // do rolled in stuff here
        }
        else // Rolled out
        {
                // do rolled out stuff here
        }
        return 0;
}

  
if you want to receive this message in a view then add the same handlers
shown above to your view and then do the following in your main frame.

LONG CMainFrame::OnWheel(UINT a, LONG b)
{
        BOOL yn;
        MDIChildWnd* aw = (MDIChildWnd*)MDIGetActive(&yn); 
        if(aw)
        {
                CView * junk;
                junk = aw->GetActiveView();
                if(junk)
                        junk->SendMessage(uMSH_MOUSEWHEEL,a,b);
        }
        return 0;
}

Более подробно обо всем этом можно почитать в MS Intellimouse SDK

2000(c)

Электронные Книги по компьютерным программам
На правах рекламы:
-->

Для добавления страницы электронной книги в избранное нажмине Ctrl+D

Книги | Статьи | Скачать

Правовая информация   

  © ComputerBooks.ru,
  При копировании материалов со страницы обязательно разместите ссылку на источник.