鼠标滚轮消息(sdk)
编译不能通过!!!是不是win98或者win2000操作系统不支持滚轮鼠标消息?头文件已经包含进去,而且在头文件里面也有定义这些标识的语句,可编译就是不能通过,以下为部分源代码,在接下来是编译中出现的错误
#include <windows.h>
#include "sysmets.h"
#define NUMLINES ((int) (sizeof sysmetrics / sizeof sysmetrics [0]))
struct
{
int iIndex ;
TCHAR * szLabel ;
TCHAR * szDesc ;
}
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
...................................................
}
LRESULT CALLBACK WndProc ( HWND hwnd, UINT message, WPARAM wParam,LPARAM lParam)
{
static int cxChar, cxCaps, cyChar, cxClient, cyClient, iMaxWidth ;
static int iDeltaPerLine, iAccumDelta ; // for mouse wheel logic
HDC hdc ;
int i, x, y, iVertPos, iHorzPos, iPaintBeg, iPaintEnd ;
PAINTSTRUCT ps ;
SCROLLINFO si ;
TCHAR szBuffer[10] ;
TEXTMETRIC tm ;
ULONG ulScrollLines ;
switch (message)
{
case WM_CREATE:
hdc = GetDC (hwnd) ;
GetTextMetrics (hdc, &tm) ;
cxChar = tm.tmAveCharWidth ;
cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2 ;
cyChar = tm.tmHeight + tm.tmExternalLeading ;
ReleaseDC (hwnd, hdc) ;
// Save the width of the three columns
iMaxWidth = 40 * cxChar + 22 * cxCaps ;
// Fall through for mouse wheel information
case WM_SETTINGCHANGE:
SystemParametersInfo (SPI_GETWHEELSCROLLLINES, 0, &ulScrollLines, 0) ;
// ulScrollLines usually equals 3 or 0 (for no scrolling)
// WHEEL_DELTA equals 120, so iDeltaPerLine will be 40
if (ulScrollLines)
iDeltaPerLine = WHEEL_DELTA / ulScrollLines ;
else
iDeltaPerLine = 0 ;
return 0 ;
case WM_SIZE:
..............
return 0 ;
case WM_VSCROLL:
.............
return 0 ;
case WM_HSCROLL;
......
return 0 ;
case WM_KEYDOWN :
......
return 0 ;
case WM_MOUSEWHEEL:
if (iDeltaPerLine == 0)
break ;
iAccumDelta += (short) HIWORD (wParam) ; // 120 or -120
while (iAccumDelta >= iDeltaPerLine)
{
SendMessage (hwnd, WM_VSCROLL, SB_LINEUP, 0) ;
iAccumDelta -= iDeltaPerLine ;
}
while (iAccumDelta <= -iDeltaPerLine)
{
SendMessage (hwnd, WM_VSCROLL, SB_LINEDOWN, 0) ;
iAccumDelta += iDeltaPerLine ;
}
return 0 ;
case WM_PAINT :
hdc = BeginPaint (hwnd, &ps) ;
// Get vertical scroll bar position
si.cbSize = sizeof (si) ;
si.fMask = SIF_POS ;
GetScrollInfo (hwnd, SB_VERT, &si) ;
iVertPos = si.nPos ;
// Get horizontal scroll bar position
GetScrollInfo (hwnd, SB_HORZ, &si) ;
iHorzPos = si.nPos ;
// Find painting limits
iPaintBeg = max (0, iVertPos + ps.rcPaint.top / cyChar) ;
iPaintEnd = min (NUMLINES - 1,
iVertPos + ps.rcPaint.bottom / cyChar) ;
for (i = iPaintBeg ; i <= iPaintEnd ; i++)
{
x = cxChar * (1 - iHorzPos) ;
y = cyChar * (i - iVertPos) ;
TextOut ( hdc, x, y,
sysmetrics[i].szLabel,
lstrlen (sysmetrics[i].szLabel)) ;
TextOut ( hdc, x + 22 * cxCaps, y,
sysmetrics[i].szDesc,
lstrlen (sysmetrics[i].szDesc)) ;
SetTextAlign (hdc, TA_RIGHT | TA_TOP) ;
TextOut (hdc, x + 22 * cxCaps + 40 * cxChar, y, szBuffer,
wsprintf (szBuffer, TEXT ("%5d"),
GetSystemMetrics (sysmetrics[i].iIndex))) ;
SetTextAlign (hdc, TA_LEFT | TA_TOP) ;
}
EndPaint (hwnd, &ps) ;
return 0 ;
case WM_DESTROY :
...... }
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
f:\program\sysmets4\sysmets4.c(152) : error C2065: 'SM_MOUSEWHEELPRESENT' : undeclared identifier
f:\program\sysmets4\sysmets4.c(152) : error C2099: initializer is not a constant
f:\program\sysmets4\sysmets4.c(152) : warning C4047: 'initializing' : 'int ' differs in levels of indirection from 'char [21]'
f:\program\sysmets4\sysmets4.c(154) : error C2065: 'SM_XVIRTUALSCREEN' : undeclared identifier
f:\program\sysmets4\sysmets4.c(154) : error C2099: initializer is not a constant
f:\program\sysmets4\sysmets4.c(155) : warning C4047: 'initializing' : 'int ' differs in levels of indirection from 'char [24]'
f:\program\sysmets4\sysmets4.c(156) : error C2065: 'SM_YVIRTUALSCREEN' : undeclared identifier
f:\program\sysmets4\sysmets4.c(156) : error C2099: initializer is not a constant
f:\program\sysmets4\sysmets4.c(158) : error C2065: 'SM_CXVIRTUALSCREEN' : undeclared identifier
f:\program\sysmets4\sysmets4.c(158) : error C2099: initializer is not a constant
f:\program\sysmets4\sysmets4.c(158) : warning C4047: 'initializing' : 'int ' differs in levels of indirection from 'char [19]'
f:\program\sysmets4\sysmets4.c(160) : error C2065: 'SM_CYVIRTUALSCREEN' : undeclared identifier
f:\program\sysmets4\sysmets4.c(160) : error C2099: initializer is not a constant
f:\program\sysmets4\sysmets4.c(161) : warning C4047: 'initializing' : 'int ' differs in levels of indirection from 'char [22]'
f:\program\sysmets4\sysmets4.c(162) : error C2065: 'SM_CMONITORS' : undeclared identifier
f:\program\sysmets4\sysmets4.c(162) : error C2099: initializer is not a constant
f:\program\sysmets4\sysmets4.c(164) : error C2065: 'SM_SAMEDISPLAYFORMAT' : undeclared identifier
f:\program\sysmets4\sysmets4.c(164) : error C2099: initializer is not a constant
f:\program\sysmets4\sysmets4.c(164) : warning C4047: 'initializing' : 'int ' differs in levels of indirection from 'char [21]'
f:\program\sysmets4\sysmets4.c(241) : error C2065: 'SPI_GETWHEELSCROLLLINES' : undeclared identifier
f:\program\sysmets4\sysmets4.c(247) : error C2065: 'WHEEL_DELTA' : undeclared identifier
f:\program\sysmets4\sysmets4.c(422) : error C2065: 'WM_MOUSEWHEEL' : undeclared identifier
f:\program\sysmets4\sysmets4.c(422) : error C2051: case expression not constant