Created
August 11, 2013 08:55
-
-
Save hirosof/6204056 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//2点のポイントからコントロールを選択する | |
BOOL CHSInternalDataAdmin::SetSelectFrom2Point(POINT in_pt1,POINT in_pt2){ | |
RECT rt; | |
if(!this->lpData) return -1; | |
if(in_pt1.x < in_pt2.x){ | |
rt.left = in_pt1.x; | |
rt.right = in_pt2.x; | |
}else{ | |
rt.left = in_pt2.x; | |
rt.right = in_pt1.x; | |
} | |
if(in_pt1.y < in_pt2.y){ | |
rt.top = in_pt1.y; | |
rt.bottom = in_pt2.y; | |
}else{ | |
rt.top = in_pt2.y; | |
rt.bottom = in_pt1.y; | |
} | |
if((rt.left == rt.right) && (rt.top == rt.bottom)) return FALSE; | |
LPHSInternalData lpClassData = this->lpData; | |
do | |
{ | |
RECT rt_obj; | |
this->GetControlRect(lpClassData->Data.hControl , &rt_obj); | |
//完全に囲まれているかどうかの検証 | |
if((rt.left <= rt_obj.left) && (rt.right >= rt_obj.right)){ | |
if((rt.top <= rt_obj.top) && (rt.bottom >= rt_obj.bottom)){ | |
this->SetSelected(lpClassData->Data.hControl , TRUE); | |
continue; | |
} | |
} | |
//選択範囲の左の辺がオブジェクトの中を通っているかの検証 | |
if((rt_obj.left <= rt.left) && (rt_obj.right >= rt.left)){ | |
if((rt.top <= rt_obj.top) && (rt.bottom >= rt_obj.bottom)){ | |
this->SetSelected(lpClassData->Data.hControl , TRUE); | |
continue; | |
} | |
} | |
//選択範囲の右の辺がオブジェクトの中を通っているかの検証 | |
if((rt_obj.left <= rt.right) && (rt_obj.right >= rt.right)){ | |
if((rt.top <= rt_obj.top) && (rt.bottom >= rt_obj.bottom)){ | |
this->SetSelected(lpClassData->Data.hControl , TRUE); | |
continue; | |
} | |
} | |
//選択範囲の上の辺がオブジェクトの中を通っているかの検証 | |
if ((rt_obj.top <= rt.top) && (rt_obj.bottom >= rt.top)){ | |
if((rt.left <= rt_obj.left) && (rt.right >= rt_obj.right)){ | |
this->SetSelected(lpClassData->Data.hControl , TRUE); | |
continue; | |
} | |
} | |
//選択範囲の下の辺がオブジェクトの中を通っているかの検証 | |
if ((rt_obj.top <= rt.bottom) && (rt_obj.bottom >= rt.bottom)){ | |
if((rt.left <= rt_obj.left) && (rt.right >= rt_obj.right)){ | |
this->SetSelected(lpClassData->Data.hControl , TRUE); | |
continue; | |
} | |
} | |
} while (lpClassData = lpClassData->lpNext); | |
return TRUE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment