コード例 #1
0
ファイル: ExImage.cpp プロジェクト: Danteoriginal/D2Ex2
bool ExImage::isPressed(DWORD Sender, WPARAM wParam)
{
	switch (Sender)
	{
	case WM_LBUTTONDOWN:
		if (*D2Vars.D2CLIENT_MouseX >= cX && *D2Vars.D2CLIENT_MouseX <= cX + cWidth && *D2Vars.D2CLIENT_MouseY <= cY && *D2Vars.D2CLIENT_MouseY >= cY - cHeight)
		{
			bBeingPressed = true;
			return true;
		}
		break;
	case WM_LBUTTONUP:
		if (*D2Vars.D2CLIENT_MouseX >= cX && *D2Vars.D2CLIENT_MouseX <= cX + cWidth && *D2Vars.D2CLIENT_MouseY <= cY && *D2Vars.D2CLIENT_MouseY >= cY - cHeight)
		{
			if (cState == VISIBLE && event_onClick)
				event_onClick(id);
			bBeingPressed = false;
			return true;
		}
		break;
	case WM_MOUSEMOVE:
		if (*D2Vars.D2CLIENT_MouseX >= cX && *D2Vars.D2CLIENT_MouseX <= cX + cWidth && *D2Vars.D2CLIENT_MouseY >= cY - cHeight && *D2Vars.D2CLIENT_MouseY <= cY)
			bBeingSelected = true;
		else
			bBeingSelected = false;
		if (!(Sender == WM_MOUSEMOVE && wParam & (MK_LBUTTON))) break;
		if (*D2Vars.D2CLIENT_MouseX >= cX && *D2Vars.D2CLIENT_MouseX <= cX + cWidth && *D2Vars.D2CLIENT_MouseY <= cY - cHeight && *D2Vars.D2CLIENT_MouseY >= cY)
			bBeingPressed = true;
		else
			bBeingPressed = false;
		break;
	}
	return false;
}
コード例 #2
0
ファイル: ExScrollBar.cpp プロジェクト: jan-kleks/D2Ex2
void ExScrollBar::Update()
{
    int c = sMax - sMin + 1;
    float ts = (float)(GetHeight() - 24) / c;

    int o = Misc::round((*sValue) * ts);

    Slider->SetY(cY + 12 + o);
    Slider->SetHeight(Misc::round(ts) + 5);
    if (event_onClick) event_onClick(id);
}
コード例 #3
0
ファイル: ExTextBox.cpp プロジェクト: tokenok/D2Ex2
bool ExTextBox::isPressed(DWORD Sender, WPARAM wParam)
{
	if (cState == VISIBLE)
	{
		switch (Sender)
		{
		case WM_MOUSEMOVE:
			if (*D2Vars.D2CLIENT_MouseX >= cX && *D2Vars.D2CLIENT_MouseX <= (cX + cWidth) && *D2Vars.D2CLIENT_MouseY <= cY && *D2Vars.D2CLIENT_MouseY >= (cY - cHeight))
			{
				if (event_onClick)
				{
					bBeingSelected = true;
					if (wParam & MK_LBUTTON) bBeingPressed = true;
				}
			}
			else
			{
				if (wParam & MK_LBUTTON && bBeingPressed) bBeingPressed = false;
				bBeingSelected = false;
			}
			break;
		case WM_LBUTTONDOWN:
			if (*D2Vars.D2CLIENT_MouseX >= cX && *D2Vars.D2CLIENT_MouseX <= (cX + cWidth) && *D2Vars.D2CLIENT_MouseY <= cY && *D2Vars.D2CLIENT_MouseY >= (cY - cHeight))
			{
				if (event_onClick)
				{
					D2ASMFuncs::D2CLIENT_PlaySound(ExSounds::STAND_CLICK);
					bBeingPressed = true;
				}
				return true;
			}
			break;
		case WM_LBUTTONUP:
			if (*D2Vars.D2CLIENT_MouseX >= cX && *D2Vars.D2CLIENT_MouseX <= (cX + cWidth) && *D2Vars.D2CLIENT_MouseY <= cY && *D2Vars.D2CLIENT_MouseY >= (cY - cHeight))
			{
				if (event_onClick)
				{
					event_onClick(id);
					bBeingPressed = false;
				}
				return true;
			}
			break;
		}
	}
	return false;
}