★初心者にVisual C++を教えるスレ★ Part14
■ このスレッドは過去ログ倉庫に格納されています
0100デフォルトの名無しさん
NGNGそんなに難しい事かな?
以下のコードで出来るよ(確認済み)。
static POINT BoxPos;
static POINT OldCurPos;
static BOOL DrgFlag;
POINT CurPos;
GetCursorPos(&CurPos);
ScreenToClient(hWnd, &CurPos);
if(GetKeyState(VK_LBUTTON) & 0x80){
if(!DrgFlag){
if(CurPos.x >= BoxPos.x && CurPos.x <= BoxPos.x + 64 &&
CurPos.y >= BoxPos.y && CurPos.y <= BoxPos.y + 64){
DrgFlag = TRUE;
OldCurPos.x = CurPos.x - BoxPos.x;
OldCurPos.y = CurPos.y - BoxPos.y;
}
}
}else{
DrgFlag = FALSE;
}
if(DrgFlag){
BoxPos.x = CurPos.x - OldCurPos.x;
BoxPos.y = CurPos.y - OldCurPos.y;
}
■ このスレッドは過去ログ倉庫に格納されています