208 cr.cpMin = lCurPos; 209 cr.cpMax = lCurPos; 210 EditSetSel(cr); 211 } 212 213 /* 214 * Cleanup the state variables when left mouse button is released. 215 * These state variables are designed to reflect the selection state 216 * while the left mouse button is pressed and be set to -1 otherwise. 217 */ 218 SetStartSelectionPos(-1); 219 SetEndSelectionPos(-1); 220 SetLastSelectionPos(-1); 221 222 delete msg; 223 return mrConsume; 224 } else if (msg->message == WM_MOUSEMOVE && (msg->wParam & MK_LBUTTON)) { 225 226 /* 227 * We consume WM_MOUSEMOVE while the left mouse button is pressed, 228 * so we have to simulate autoscrolling when mouse is moved outside 229 * of the client area. 230 */ 231 POINT p; 232 RECT r; 233 BOOL bScrollLeft = FALSE; 234 BOOL bScrollRight = FALSE; 235 BOOL bScrollUp = FALSE; 236 BOOL bScrollDown = FALSE; 237 238 p.x = msg->pt.x; 239 p.y = msg->pt.y; 240 VERIFY(::GetClientRect(GetHWnd(), &r)); 241 242 if (p.x < 0) { 243 bScrollLeft = TRUE; 244 p.x = 0; 245 } else if (p.x > r.right) { 246 bScrollRight = TRUE; 247 p.x = r.right - 1; 248 } 249 if (p.y < 0) { 250 bScrollUp = TRUE; 251 p.y = 0; 252 } else if (p.y > r.bottom) { 253 bScrollDown = TRUE; 254 p.y = r.bottom - 1; 255 } 256 257 LONG lCurPos = EditGetCharFromPos(p); 258 259 if (GetStartSelectionPos() != -1 && 260 GetEndSelectionPos() != -1 && 261 lCurPos != GetLastSelectionPos()) { 262 263 CHARRANGE cr; 264 265 SetLastSelectionPos(lCurPos); 266 267 cr.cpMin = GetStartSelectionPos(); 268 cr.cpMax = GetLastSelectionPos(); 269 270 EditSetSel(cr); 271 } 272 273 if (bScrollLeft == TRUE || bScrollRight == TRUE) { 274 SCROLLINFO si; 275 memset(&si, 0, sizeof(si)); 276 si.cbSize = sizeof(si); 277 si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE; 278 279 VERIFY(::GetScrollInfo(GetHWnd(), SB_HORZ, &si)); 280 if (bScrollLeft == TRUE) { 281 si.nPos = si.nPos - si.nPage / 2; 282 si.nPos = max(si.nMin, si.nPos); 283 } else if (bScrollRight == TRUE) { 284 si.nPos = si.nPos + si.nPage / 2; 285 si.nPos = min(si.nPos, si.nMax); 286 } 287 /* 288 * Okay to use 16-bit position since RichEdit control adjusts 289 * its scrollbars so that their range is always 16-bit. 290 */ 291 DASSERT(abs(si.nPos) < 0x8000); 292 SendMessage(WM_HSCROLL, 293 MAKEWPARAM(SB_THUMBPOSITION, LOWORD(si.nPos))); 294 } 295 if (bScrollUp == TRUE) { 296 SendMessage(EM_LINESCROLL, 0, -1); 297 } else if (bScrollDown == TRUE) { 298 SendMessage(EM_LINESCROLL, 0, 1); 299 } 300 delete msg; 301 return mrConsume; 302 } else if (msg->message == WM_MOUSEWHEEL) { 303 // 4417236: If there is an old version of RichEd32.dll which 304 // does not provide the mouse wheel scrolling we have to 305 // interpret WM_MOUSEWHEEL as a sequence of scroll messages. 306 // kdm@sparc.spb.su 307 UINT platfScrollLines = 3; 308 // Retrieve a number of scroll lines. 309 ::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, 310 &platfScrollLines, 0); 311 312 if (platfScrollLines > 0) { 313 HWND hWnd = GetHWnd(); 314 LONG styles = ::GetWindowLong(hWnd, GWL_STYLE); 315 316 RECT rect; 317 // rect.left and rect.top are zero. | 208 cr.cpMin = lCurPos; 209 cr.cpMax = lCurPos; 210 EditSetSel(cr); 211 } 212 213 /* 214 * Cleanup the state variables when left mouse button is released. 215 * These state variables are designed to reflect the selection state 216 * while the left mouse button is pressed and be set to -1 otherwise. 217 */ 218 SetStartSelectionPos(-1); 219 SetEndSelectionPos(-1); 220 SetLastSelectionPos(-1); 221 222 delete msg; 223 return mrConsume; 224 } else if (msg->message == WM_MOUSEMOVE && (msg->wParam & MK_LBUTTON)) { 225 226 /* 227 * We consume WM_MOUSEMOVE while the left mouse button is pressed, 228 * so we have to simulate selection autoscrolling when mouse is moved 229 * outside of the client area. 230 */ 231 POINT p; 232 RECT r; 233 BOOL bScrollDown = FALSE; 234 235 p.x = msg->pt.x; 236 p.y = msg->pt.y; 237 VERIFY(::GetClientRect(GetHWnd(), &r)); 238 239 if (p.y > r.bottom) { 240 bScrollDown = TRUE; 241 p.y = r.bottom - 1; 242 } 243 244 LONG lCurPos = EditGetCharFromPos(p); 245 246 if (GetStartSelectionPos() != -1 && 247 GetEndSelectionPos() != -1 && 248 lCurPos != GetLastSelectionPos()) { 249 250 CHARRANGE cr; 251 252 SetLastSelectionPos(lCurPos); 253 254 cr.cpMin = GetStartSelectionPos(); 255 cr.cpMax = GetLastSelectionPos(); 256 257 EditSetSel(cr); 258 } 259 if (bScrollDown == TRUE) { 260 SendMessage(EM_LINESCROLL, 0, 1); 261 } 262 delete msg; 263 return mrConsume; 264 } else if (msg->message == WM_MOUSEWHEEL) { 265 // 4417236: If there is an old version of RichEd32.dll which 266 // does not provide the mouse wheel scrolling we have to 267 // interpret WM_MOUSEWHEEL as a sequence of scroll messages. 268 // kdm@sparc.spb.su 269 UINT platfScrollLines = 3; 270 // Retrieve a number of scroll lines. 271 ::SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, 272 &platfScrollLines, 0); 273 274 if (platfScrollLines > 0) { 275 HWND hWnd = GetHWnd(); 276 LONG styles = ::GetWindowLong(hWnd, GWL_STYLE); 277 278 RECT rect; 279 // rect.left and rect.top are zero. |