달력

62025  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

'event'에 해당되는 글 1건

  1. 2008.11.02 mouse wheel 이벤트

//--------------------------------------------------------------
// 마우스 휠
//--------------------------------------------------------------
#pragma comment(linker, "/subsystem:windows")
#define _WIN32_WINNT 0x0501
#define WINVER   0x0501
#include <windows.h>

LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
 switch( msg )
 { 
 case WM_MOUSEWHEEL:
  {
   short delta = HIWORD( wParam );

   delta = ( delta / WHEEL_DELTA ); // WHEEL_DELTA : 120

   RECT rc;
   GetWindowRect( hwnd, &rc); // 현재 윈도우의 위치, 크기

   OffsetRect( &rc, 0, delta * 10 ); // rc를 이동.

   // 윈도우를 이동.
   SetWindowPos( hwnd, 0, rc.left, rc.top, 0, 0,
        SWP_NOZORDER | SWP_NOSIZE );
  }
  return 0;

 case WM_DESTROY:
  PostQuitMessage(0);
  return 0;
 }
 return DefWindowProc( hwnd, msg, wParam, lParam);
}

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
     LPSTR   lpCmdLine, int nShowCmd )
{
 ATOM atom;
 WNDCLASS wc;
 HWND hwnd;
 MSG msg;
 
 wc.cbClsExtra = 0;
 wc.cbWndExtra = 0;
 wc.hbrBackground= (HBRUSH)GetStockObject( WHITE_BRUSH );
 wc.hCursor  = LoadCursor( 0, IDC_ARROW );
 wc.hIcon  = LoadIcon( 0, IDI_APPLICATION);
 wc.hInstance = hInstance;
 wc.lpfnWndProc  = WndProc;
 wc.lpszClassName= "First";
 wc.lpszMenuName = 0;
 wc.style  = 0;

 atom = RegisterClass( &wc);
 
 if ( atom == 0 )
 {
  MessageBox( 0, "Fail To RegisterClass", "Error", MB_OK);
  return 0;
 }

 hwnd = CreateWindowEx( 0, "first", "Hello", WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, 0, CW_USEDEFAULT,0, 0, 0,
        hInstance, 0);
 ShowWindow( hwnd, nShowCmd);
 UpdateWindow( hwnd );

 while ( GetMessage( &msg, 0, 0, 0) )
 {       
  TranslateMessage(&msg);
  DispatchMessage( &msg);
 }

 return 0;
}


 

Posted by CokeBell
|