A warning in the scoll bar

In the main.cpp file, I want to create the Scoll bars, as following:
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
31
32
33
34
case WM_VSCROLL:
		switch(LOWORD(wParam))
		{ case SB_LINEUP:
		   iVscrollPos-=1;
		   break;
		case SB_LINEDOWN:
			iVscrollPos+=1;
			break;
		case SB_PAGEUP:
			iVscrollPos+=1;
			break;
		case SB_PAGEDOWN:
			iVscrollPos+=1;
			break;
		case SB_THUMBPOSITION:
			iVscrollPos=HIWORD(wParam);
			break;
		default:
			break;
		}
		if(iVscrollPos != GetScrollPos(hWnd, SB_VERT))
{
    SetScrollPos(hWnd, SB_VERT, iVscrollPos, TRUE);
    InvalidateRect(hWnd, NULL, TRUE);
}
break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}

I want to add the line:
iVscrollPos = max(0, min(iVscrollPos, NUMLINES-1));
but when I declare the function int max(int a,int b), it shows the warning.How to handle this?
declare the function int max(int a,int b)
What warning it shows? I believe this is because there is std::max() template.
Depending of what are you doing, #define _NOMINMAX before anything else can help you.
I wrote :
1
2
3
4
#define max(a,b) ( ((a) > (b)) ? (a) : (b) )




is that wrong? I don't know how to fix it.
a) #define _NOMINMAX as modoran suggest
b) use std::max() function. Really. Try to not use defines at all.
c) rename your macro
Topic archived. No new replies allowed.