LRESULT SkinButton::OnLButtonUpMsg(WPARAM wParam, LPARAM lParam) { POINT pt; pt.x = LOWORD(lParam); pt.y = HIWORD(lParam); RECT r; GetClientRect(&r); BOOL inside = PtInRect(&r, pt); if(region != NULL) inside &= PtInRegion(region, pt.x, pt.y); if(inside) { ReleaseCapture(); Invalidate(); HWND hWnd = m_hWnd; if(idCommand != 0) GetParent()->SendMessage(WM_COMMAND, idCommand, 0); else if(buttonMask) theApp.skinButtons = 0; else if(menu != -1) { HMENU m = GetSubMenu(theApp.menu, menu); pt.x = r.left; pt.y = r.bottom; ClientToScreen(&pt); theApp.m_pMainWnd->SendMessage(WM_INITMENUPOPUP, (WPARAM)m, menu); TrackPopupMenu(m, 0, pt.x, pt.y, 0, *theApp.m_pMainWnd, NULL); } return ::DefWindowProc(hWnd, WM_LBUTTONUP, wParam, lParam); } return GetParent()->SendMessage(WM_LBUTTONUP, wParam, lParam); }
LRESULT SkinButton::OnMouseMoveMsg(WPARAM wParam, LPARAM lParam) { if(wParam & MK_LBUTTON && !mouseOver) return Default(); if(GetCapture() != this) { SetCapture(); } POINT pt; pt.x = LOWORD(lParam); pt.y = HIWORD(lParam); // ClientToScreen(getHandle(), &p); RECT r; GetClientRect(&r); BOOL inside = PtInRect(&r, pt); if(region != NULL) inside &= PtInRegion(region, pt.x, pt.y); if(!inside) { // HWND h = WindowFromPoint(p); // if(h != getHandle()) { if(mouseOver) { mouseOver = false; Invalidate(); } if(!(wParam & MK_LBUTTON)) ReleaseCapture(); } else { if(!mouseOver) { mouseOver = true; Invalidate(); } } return Default(); }
//DrawPixel of DC object,specify a color. VOID DrawPixel(HANDLE hDC,int x,int y,__COLOR clr) { __DC* pDC = (__DC*)hDC; __WINDOW* pWindow = NULL; int ax = x; int ay = y; if(NULL == pDC) //Invalid parameter. { return; } pWindow = (__WINDOW*)pDC->hWindow; if(pWindow) //Window existing,calculate actual position of x and y. { if(pDC->dwDCType & DC_TYPE_CLIENT) //Window client's DC. { ax += pWindow->xclient; ay += pWindow->yclient; } if(pDC->dwDCType & DC_TYPE_WINDOW) //Window's DC. { ax += pWindow->x; ay += pWindow->y; } } if(pDC->dwDCType & DC_TYPE_SCREEN) //Text out to screen. { if(PtInRegion(pDC->pRegion,ax,ay)) //Should draw this pixel. { pDC->pVideo->DrawPixel(pDC->pVideo,ax,ay,clr); } } }
void CSkinButton::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default HRGN hRgn = CreateRectRgn(0, 0, 0, 0); GetWindowRgn(hRgn); if ( PtInRegion( hRgn, point.x, point.y )) { if ( !m_bMouseIn) { m_bMouseIn = TRUE; //GetRegion(); Invalidate(); UpdateWindow(); SetCapture(); } } else { if ( m_bMouseIn) { m_bMouseIn = FALSE; //GetRegion(); Invalidate(); UpdateWindow(); if ( !m_bDown ) ReleaseCapture(); } } DeleteObject(hRgn); }
void CDrawCheckbox::OnMouseMove(WPARAM wParam, LPARAM lParam) { // 按钮可用 if(m_nCtrlState != STATE_DISABLE) { POINT pt = {}; GetCursorPos(&pt); ScreenToClient(m_hWnd, &pt); if(PtInRegion(m_hCtrlRgn, pt.x, pt.y)) // 鼠标在控件区域内 { // 鼠标没有跟踪 if(!m_fTrackMouse) { // 跟踪鼠标离开,触发MouseLeave消息 TRACKMOUSEEVENT MouseEvent = {sizeof(TRACKMOUSEEVENT)}; MouseEvent.dwFlags = TME_LEAVE; MouseEvent.hwndTrack = m_hWnd; MouseEvent.dwHoverTime = 1000; TrackMouseEvent(&MouseEvent); // 设置鼠标被跟踪 m_fTrackMouse = TRUE; } // 按钮没有按下,则设置按钮状态为焦点 if(m_nCtrlState != STATE_DOWN) m_nCtrlState = STATE_FOCUS; } else // 移动到区域外,均直接处理为鼠标弹起 { m_nCtrlState = STATE_UP; } InvalidataCtrl(); } }
void CDrawCheckbox::OnLbuttonUp(WPARAM wParam, LPARAM lParam) { if(m_nCtrlState == STATE_DISABLE) { return; } //ReleaseCapture(); POINT pt = {}; GetCursorPos(&pt); ScreenToClient(m_hWnd, &pt); if(PtInRegion(m_hCtrlRgn, pt.x, pt.y)) { // 控件区域内,设置鼠标跟踪并设置按钮为焦点状态 // 发送给父窗口点击消息 m_fTrackMouse = TRUE; m_nCtrlState = STATE_FOCUS; } else { // 控件移动区域外,取消鼠标跟踪并设置按钮为弹起状态 m_fTrackMouse = FALSE; m_nCtrlState = STATE_UP; } InvalidataCtrl(); }
// Return true if region contains point FXbool FXRegion::contains(FXint x,FXint y) const { #ifdef WIN32 return region && PtInRegion((HRGN)region,x,y); #else return XPointInRegion((Region)region,x,y); #endif }
LRESULT OnMouseMove(HWND hWnd, UINT nFlags, CPoint point ) { HRGN hRgn = CreateRectRgn( 0, 0, 0, 0 ); GetWindowRgn( hWnd,hRgn ); BOOL ret = PtInRegion( hRgn, point.x, point.y ); if( ret ) { if( m_State == bsDown) return TRUE; if( m_State != bsHot ) { m_State = bsHot; InvalidateRect(hWnd,NULL,TRUE); UpdateWindow(hWnd); SetCapture(hWnd); } } else { m_State = bsNormal; InvalidateRect(hWnd,NULL,TRUE); ReleaseCapture(); } DeleteObject( hRgn ); return TRUE; }
/***************************************************************************** * GdipIsVisibleRegionPoint [GDIPLUS.@] */ GpStatus WINGDIPAPI GdipIsVisibleRegionPoint(GpRegion* region, REAL x, REAL y, GpGraphics *graphics, BOOL *res) { HRGN hrgn; GpStatus stat; TRACE("(%p, %.2f, %.2f, %p, %p)\n", region, x, y, graphics, res); if(!region || !res) return InvalidParameter; if((stat = GdipGetRegionHRgn(region, NULL, &hrgn)) != Ok) return stat; /* infinite */ if(!hrgn){ *res = TRUE; return Ok; } *res = PtInRegion(hrgn, gdip_round(x), gdip_round(y)); DeleteObject(hrgn); return Ok; }
/*********************************************************************** * PtVisible (GDI32.@) */ BOOL WINAPI PtVisible( HDC hdc, INT x, INT y ) { POINT pt; BOOL ret; HRGN clip; DC *dc = DC_GetDCUpdate( hdc ); TRACE("%p %d,%d\n", hdc, x, y ); if (!dc) return FALSE; pt.x = x; pt.y = y; LPtoDP( hdc, &pt, 1 ); ret = PtInRegion( dc->hVisRgn, pt.x, pt.y ); if (ret && (clip = get_clip_region(dc))) ret = PtInRegion( clip, pt.x, pt.y ); GDI_ReleaseObj( hdc ); return ret; }
bool CDayPlanSlider::OnSetCursor(POINT pt) { POINT cPt = ScreenToComponentPt(pt); if(PtInRegion(m_hRegion, cPt.x, cPt.y)) { SetCursor(GetDefaultCursor()); return true; } return false; }
/** @return true if native window exists underneath the coordinates */ bool FWindowsWindow::IsPointInWindow( int32 X, int32 Y ) const { bool Result = false; HRGN Region = MakeWindowRegionObject(); Result = !!PtInRegion( Region, X, Y ); DeleteObject( Region ); return Result; }
static void hugsprim_PtInRegion_14(HugsStackPtr hugs_root) { HsPtr arg1; HsInt arg2; HsInt arg3; HsBool res1; arg1 = hugs->getPtr(); arg2 = hugs->getInt(); arg3 = hugs->getInt(); res1 = PtInRegion(arg1, arg2, arg3); hugs->putBool(res1); hugs->returnIO(hugs_root,1); }
pbody* simulator::BodyAtPos(float x, float y) { for (bap = bodies.rbegin(); bap < bodies.rend(); bap++) { if (x < ((*bap)->bbox.left) || x > ((*bap)->bbox.right) || y < ((*bap)->bbox.top) || y > ((*bap)->bbox.bottom)) continue; if (PtInRegion((*bap)->pol, int(x*100.0),int(y*100.0))) { (*bap)->ishighlited = true; return (*bap); } } return NULL; }
LRESULT ControlMediaPlayer::Evento_Mouse_Movimiento(const int cX, const int cY, const UINT wParam) { UltimoMovimiento = GetTickCount(); if (EstaEnPantallaCompleta() == true) { DWL::SO::DWLMouse::Visible(TRUE); RECT Recta; POINT MousePos; DWL::SO::DWLMouse::ObtenerPosicion(&MousePos); HRGN RMP = CreateRectRgn(0, 0, 0, 0); GetWindowRgn(Sistema.App.ControlesMP.hWnd(), RMP); GetWindowRect(_hWnd, &Recta); int x; if (Recta.left > 0) x = ((Recta.right - Recta.left) - CONTROLESMP_ANCHO) / 2; else x = (((Recta.right + Recta.left) + CONTROLESMP_ANCHO) / 2) - CONTROLESMP_ANCHO; if (ControlesMP_Abajo == true) { int y = (Recta.bottom - Recta.top) - CONTROLESMP_ALTO; int r = OffsetRgn(RMP, x, y); if (PtInRegion(RMP, MousePos.x, MousePos.y) == TRUE) { Sistema.App.ControlesMP.Mostrar(_hWnd, ControlesMP_Abajo); } else { Sistema.App.ControlesMP.Ocultar(hWnd()); } } else { OffsetRgn(RMP, x, 0); if (PtInRegion(RMP, MousePos.x, MousePos.y) == TRUE) { Sistema.App.ControlesMP.Mostrar(_hWnd, ControlesMP_Abajo); } else { Sistema.App.ControlesMP.Ocultar(hWnd()); } } DeleteObject(RMP); } return 0; }
void CDrawCheckbox::OnLbuttonDBClick(WPARAM wParam, LPARAM lParam) { // 鼠标左键双击转化为本控件的鼠标单击消息 if(m_nCtrlState == STATE_DISABLE) { return; } POINT pt = {}; GetCursorPos(&pt); ScreenToClient(m_hWnd, &pt); if(PtInRegion(m_hCtrlRgn, pt.x, pt.y)) { SendMessage(m_hWnd, WM_LBUTTONDOWN, NULL, NULL); } }
static int button_msg_proc (skin_item_t* item, int message, WPARAM wparam, LPARAM lparam) { /* assert (item != NULL) */ switch (message) { case SKIN_MSG_LBUTTONDOWN: /* click-down event */ //RAISE_EVENT ( SIE_LBUTTONDOWN, NULL ); /*item msg not defined*/ /* default operation */ skin_set_check_status ( item->hostskin, item->id, TRUE ); /*button down*/ break; case SKIN_MSG_LBUTTONUP: /* click-up event */ //RAISE_EVENT ( SIE_LBUTTONUP, NULL ); /*item msg not defined*/ /* default operation */ skin_set_check_status ( item->hostskin, item->id, FALSE ); /*button up*/ break; case SKIN_MSG_CLICK: /* CLICK event */ RAISE_EVENT ( SIE_BUTTON_CLICKED, NULL ); /* default operation */ skin_set_check_status ( item->hostskin, item->id, FALSE ); /* button up */ break; case SKIN_MSG_MOUSEDRAG: //RAISE_EVENT ( SIE_MOUSEDRAG, NULL ); /* default operation */ if ( PtInRegion (&item->region, (int)wparam, (int)lparam) ){ /* if mouse moves in, click-down item */ if (!skin_get_check_status(item->hostskin, item->id)) skin_set_check_status ( item->hostskin, item->id, TRUE); /*button down*/ } else{ /* if mouse moves out, click-up item */ if (skin_get_check_status(item->hostskin, item->id)) skin_set_check_status ( item->hostskin, item->id, FALSE); /*button up*/ } break; case SKIN_MSG_SETFOCUS: RAISE_EVENT ( SIE_GAIN_FOCUS, NULL ); break; case SKIN_MSG_KILLFOCUS: RAISE_EVENT ( SIE_LOST_FOCUS, NULL ); break; } return 1; }
LRESULT SkinButton::OnLButtonDownMsg(WPARAM wParam, LPARAM lParam) { if(idCommand != 0) return Default(); POINT pt; pt.x = LOWORD(lParam); pt.y = HIWORD(lParam); RECT r; GetClientRect(&r); BOOL inside = PtInRect(&r, pt); if(region != NULL) inside &= PtInRegion(region, pt.x, pt.y); if(inside) { if(buttonMask) theApp.skinButtons = buttonMask; return Default(); } return GetParent()->SendMessage(WM_LBUTTONDOWN, wParam, lParam); }
/*********************************************************************** * PtVisible (GDI32.@) */ BOOL WINAPI PtVisible( HDC hdc, INT x, INT y ) { POINT pt; RECT visrect; BOOL ret; DC *dc = get_dc_ptr( hdc ); TRACE("%p %d,%d\n", hdc, x, y ); if (!dc) return FALSE; pt.x = x; pt.y = y; lp_to_dp( dc, &pt, 1 ); update_dc( dc ); ret = (!get_dc_device_rect( dc, &visrect ) || (pt.x >= visrect.left && pt.x < visrect.right && pt.y >= visrect.top && pt.y < visrect.bottom)); if (ret && get_dc_region( dc )) ret = PtInRegion( get_dc_region( dc ), pt.x, pt.y ); release_dc_ptr( dc ); return ret; }
void CDrawCheckbox::OnLbuttonDown(WPARAM wParam, LPARAM lParam) { if(m_nCtrlState == STATE_DISABLE) { return; } POINT pt = {}; GetCursorPos(&pt); ScreenToClient(m_hWnd, &pt); if(PtInRegion(m_hCtrlRgn, pt.x, pt.y)) { // 设置控件是否被选中状态以及控件处于焦点状态 m_bCheck = !m_bCheck; //SetCapture(m_hWnd); SetCheck(m_bCheck); m_nCtrlState = STATE_FOCUS; SendMessage(GetParent(m_hWnd), WM_CHECKBOXCLICKED, GetDlgCtrlID(m_hWnd), m_bCheck); // SendMessage(GetParent(m_hWnd), WM_COMMAND,\ // MAKEWPARAM(GetDlgCtrlID(m_hWnd), BN_CLICKED), m_bCheck/*(LPARAM)m_hWnd*/); } }
void CDlgShowControl::OnMouseMove(UINT nFlags, CPoint point) { // TODO: 在此添加消息处理程序代码和/或调用默认值 HRGN hRgn = CreateRectRgn(0, 0, 0, 0); GetWindowRgn(hRgn); if (PtInRegion( hRgn, point.x, point.y )) { ::SetCursor(AfxGetApp()->LoadCursor(IDC_MY_HAND)); if (!m_bMouseIn) { m_bMouseIn = TRUE; Invalidate(); UpdateWindow(); SetCapture(); } } else { if (m_bMouseIn) { m_bMouseIn = FALSE; Invalidate(); UpdateWindow(); if (!m_bDown ) ReleaseCapture(); } } DeleteObject(hRgn); CDialog::OnMouseMove(nFlags, point); }
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) //switch语句开始 { case WM_COMMAND: switch (wParam) { case ID_40001: HaveBoss = 0; break; case ID_40002: HaveBoss = 1; break; } break; case WM_TIMER: //定时器消息 //Game_Fight(hwnd); //调用Game_Paint()函数进行窗口绘图; //g_iX + 217; picorder++; if (picorder == 4) picorder = 0; timeflag++; /*timeorder++; if (timeorder == 8) timeorder = 0;*/ if (timeflag == 5){ timeflag = 0; timeorder++; } //g_iNum++; //if (g_iNum == 7){ //g_iNum = 0; //skillflag = 0; //} break; case WM_KEYDOWN: //按键消息 switch (wParam){ case VK_ESCAPE: DestroyWindow(hwnd); PostQuitMessage(0); break; case VK_UP: if (PtInRegion(canavailable, g_iX, g_iY - 10) && !PtInRegion(cannotavailable1, g_iX, g_iY - 10) && !PtInRegion(cannotavailable2, g_iX, g_iY - 10) && !PtInRegion(cannotavailable3, g_iX, g_iY - 10)) g_iY -= 10; g_iDirection = 3; if (g_iY < 0) g_iY = 0; break; case VK_RIGHT: if (PtInRegion(canavailable, g_iX + 10, g_iY) && !PtInRegion(cannotavailable1, g_iX + 10, g_iY - 10) && !PtInRegion(cannotavailable2, g_iX + 10, g_iY) && !PtInRegion(cannotavailable3, g_iX + 10, g_iY)) g_iX += 10; g_iDirection = 2; /*if (g_iX > WINDOW_WIDTH - 75) g_iX = WINDOW_WIDTH - 75;*/ break; case VK_DOWN: if (PtInRegion(canavailable, g_iX, g_iY + 10) && !PtInRegion(cannotavailable1, g_iX, g_iY + 10) && !PtInRegion(cannotavailable2, g_iX, g_iY + 10) && !PtInRegion(cannotavailable3, g_iX, g_iY + 10)) g_iY += 10; g_iDirection = 0; /*if (g_iY > WINDOW_HEIGHT - 135) g_iY = WINDOW_HEIGHT - 135;*/ break; case VK_LEFT: if (PtInRegion(canavailable, g_iX - 10, g_iY) && !PtInRegion(cannotavailable1, g_iX - 10, g_iY) && !PtInRegion(cannotavailable2, g_iX - 10, g_iY) && !PtInRegion(cannotavailable3, g_iX - 10, g_iY)) g_iX -= 10; g_iDirection = 1; if (g_iX < 0) g_iX = 0; break; } g_mv = GetTickCount(); break; case WM_LBUTTONDOWN: //鼠标左键消息 if (!g_bCanAttack) { int x = LOWORD(lParam); //X坐标 int y = HIWORD(lParam); //Y坐标 //在这修改点击哪个技能栏 if (x >= 530 && x <= 570 && y >= 420 && y <= 470) { g_bCanAttack = true; HeroActionType = ACTION_TYPE_MAGIC; } if (x >= 0 && x <= 300 && y >= 0 && y <= 300) { g_bCanAttack = true; HeroActionType = ACTION_TYPE_NORMAL; } if (x >= 700 && x <= 760 && y >= 200 && y <= 226) { g_bCanAttack = true; HeroActionType = ACTION_TYPE_MAGIC; } if (x >= 650 && x <= 700 && y >= 420 && y <= 470) { g_bCanAttack = true; HeroActionType = ACTION_TYPE_RECOVER; } } break; case WM_DESTROY: //若是窗口销毁消息 Game_ShutDown(hwnd); //调用自定义的资源清理函数Game_ShutDown()进行退出前的资源清理 PostQuitMessage(0); //向系统表明有个线程有终止请求。用来响应WM_DESTROY消息 break; //跳出该switch语句 default: //若上述case条件都不符合,则执行该default语句 return DefWindowProc(hwnd, message, wParam, lParam); //调用缺省的窗口过程 } return 0; //正常退出 }
bool Win32Graphics::hit( int x, int y ) const { return PtInRegion( m_mask, x, y ) != 0; }
bool CDayPlanSlider::contains(POINT pt) { pt = ParentToComponentPt(pt); return PtInRegion(m_hRegion, pt.x, pt.y)?true:false; }
void CWndShadow::MakeShadow(UINT32 *pShadBits, HWND hParent, RECT *rcParent) { // The shadow algorithm: // Get the region of parent window, // Apply morphologic erosion to shrink it into the size (ShadowWndSize - Sharpness) // Apply modified (with blur effect) morphologic dilation to make the blurred border // The algorithm is optimized by assuming parent window is just "one piece" and without "wholes" on it // Get the region of parent window, HRGN hParentRgn = CreateRectRgn(0, 0, 0, 0); GetWindowRgn(hParent, hParentRgn); // Determine the Start and end point of each horizontal scan line SIZE szParent = { rcParent->right - rcParent->left, rcParent->bottom - rcParent->top }; SIZE szShadow = { szParent.cx + 2 * m_nSize, szParent.cy + 2 * m_nSize }; // Extra 2 lines (set to be empty) in ptAnchors are used in dilation int nAnchors = max(szParent.cy, szShadow.cy); // # of anchor points pares int(*ptAnchors)[2] = new int[nAnchors + 2][2]; int(*ptAnchorsOri)[2] = new int[szParent.cy][2]; // anchor points, will not modify during erosion ptAnchors[0][0] = szParent.cx; ptAnchors[0][1] = 0; ptAnchors[nAnchors + 1][0] = szParent.cx; ptAnchors[nAnchors + 1][1] = 0; if (m_nSize > 0) { // Put the parent window anchors at the center for (int i = 0; i < m_nSize; i++) { ptAnchors[i + 1][0] = szParent.cx; ptAnchors[i + 1][1] = 0; ptAnchors[szShadow.cy - i][0] = szParent.cx; ptAnchors[szShadow.cy - i][1] = 0; } ptAnchors += m_nSize; } for (int i = 0; i < szParent.cy; i++) { // find start point int j; for (j = 0; j < szParent.cx; j++) { if (PtInRegion(hParentRgn, j, i)) { ptAnchors[i + 1][0] = j + m_nSize; ptAnchorsOri[i][0] = j; break; } } if (j >= szParent.cx) // Start point not found { ptAnchors[i + 1][0] = szParent.cx; ptAnchorsOri[i][1] = 0; ptAnchors[i + 1][0] = szParent.cx; ptAnchorsOri[i][1] = 0; } else { // find end point for (j = szParent.cx - 1; j >= ptAnchors[i + 1][0]; j--) { if (PtInRegion(hParentRgn, j, i)) { ptAnchors[i + 1][1] = j + 1 + m_nSize; ptAnchorsOri[i][1] = j + 1; break; } } } } if (m_nSize > 0) ptAnchors -= m_nSize; // Restore pos of ptAnchors for erosion int(*ptAnchorsTmp)[2] = new int[nAnchors + 2][2]; // Store the result of erosion // First and last line should be empty ptAnchorsTmp[0][0] = szParent.cx; ptAnchorsTmp[0][1] = 0; ptAnchorsTmp[nAnchors + 1][0] = szParent.cx; ptAnchorsTmp[nAnchors + 1][1] = 0; int nEroTimes = 0; // morphologic erosion for (int i = 0; i < m_nSharpness - m_nSize; i++) { nEroTimes++; //ptAnchorsTmp[1][0] = szParent.cx; //ptAnchorsTmp[1][1] = 0; //ptAnchorsTmp[szParent.cy + 1][0] = szParent.cx; //ptAnchorsTmp[szParent.cy + 1][1] = 0; for (int j = 1; j < nAnchors + 1; j++) { ptAnchorsTmp[j][0] = max(ptAnchors[j - 1][0], max(ptAnchors[j][0], ptAnchors[j + 1][0])) + 1; ptAnchorsTmp[j][1] = min(ptAnchors[j - 1][1], min(ptAnchors[j][1], ptAnchors[j + 1][1])) - 1; } // Exchange ptAnchors and ptAnchorsTmp; int(*ptAnchorsXange)[2] = ptAnchorsTmp; ptAnchorsTmp = ptAnchors; ptAnchors = ptAnchorsXange; } // morphologic dilation ptAnchors += (m_nSize < 0 ? -m_nSize : 0) + 1; // now coordinates in ptAnchors are same as in shadow window // Generate the kernel int nKernelSize = m_nSize > m_nSharpness ? m_nSize : m_nSharpness; int nCenterSize = m_nSize > m_nSharpness ? (m_nSize - m_nSharpness) : 0; UINT32 *pKernel = new UINT32[(2 * nKernelSize + 1) * (2 * nKernelSize + 1)]; UINT32 *pKernelIter = pKernel; for (int i = 0; i <= 2 * nKernelSize; i++) { for (int j = 0; j <= 2 * nKernelSize; j++) { double dLength = sqrt((i - nKernelSize) * (i - nKernelSize) + (j - nKernelSize) * (double)(j - nKernelSize)); if (dLength < nCenterSize) *pKernelIter = m_nDarkness << 24 | PreMultiply(m_Color, m_nDarkness); else if (dLength <= nKernelSize) { UINT32 nFactor = ((UINT32)((1 - (dLength - nCenterSize) / (m_nSharpness + 1)) * m_nDarkness)); *pKernelIter = nFactor << 24 | PreMultiply(m_Color, nFactor); } else *pKernelIter = 0; //TRACE("%d ", *pKernelIter >> 24); pKernelIter++; } //TRACE("\n"); } // Generate blurred border for (int i = nKernelSize; i < szShadow.cy - nKernelSize; i++) { int j; if (ptAnchors[i][0] < ptAnchors[i][1]) { // Start of line for (j = ptAnchors[i][0];j < min(max(ptAnchors[i - 1][0], ptAnchors[i + 1][0]) + 1, ptAnchors[i][1]);j++) { for (int k = 0; k <= 2 * nKernelSize; k++) { UINT32 *pPixel = pShadBits + (szShadow.cy - i - 1 + nKernelSize - k) * szShadow.cx + j - nKernelSize; UINT32 *pKernelPixel = pKernel + k * (2 * nKernelSize + 1); for (int l = 0; l <= 2 * nKernelSize; l++) { if (*pPixel < *pKernelPixel) *pPixel = *pKernelPixel; pPixel++; pKernelPixel++; } } } // for() start of line // End of line for (j = max(j, min(ptAnchors[i - 1][1], ptAnchors[i + 1][1]) - 1);j < ptAnchors[i][1];j++) { for (int k = 0; k <= 2 * nKernelSize; k++) { UINT32 *pPixel = pShadBits +(szShadow.cy - i - 1 + nKernelSize - k) * szShadow.cx + j - nKernelSize; UINT32 *pKernelPixel = pKernel + k * (2 * nKernelSize + 1); for (int l = 0; l <= 2 * nKernelSize; l++) { if (*pPixel < *pKernelPixel) *pPixel = *pKernelPixel; pPixel++; pKernelPixel++; } } } // for() end of line } } // for() Generate blurred border // Erase unwanted parts and complement missing UINT32 clCenter = m_nDarkness << 24 | PreMultiply(m_Color, m_nDarkness); for (int i = min(nKernelSize, max(m_nSize - m_nyOffset, 0));i < max(szShadow.cy - nKernelSize, min(szParent.cy + m_nSize - m_nyOffset, szParent.cy + 2 * m_nSize));i++) { UINT32 *pLine = pShadBits + (szShadow.cy - i - 1) * szShadow.cx; if (i - m_nSize + m_nyOffset < 0 || i - m_nSize + m_nyOffset >= szParent.cy) // Line is not covered by parent window { for (int j = ptAnchors[i][0]; j < ptAnchors[i][1]; j++) { *(pLine + j) = clCenter; } } else { for (int j = ptAnchors[i][0];j < min(ptAnchorsOri[i - m_nSize + m_nyOffset][0] + m_nSize - m_nxOffset, ptAnchors[i][1]);j++) *(pLine + j) = clCenter; for (int j = max(ptAnchorsOri[i - m_nSize + m_nyOffset][0] + m_nSize - m_nxOffset, 0);j < min(ptAnchorsOri[i - m_nSize + m_nyOffset][1] + m_nSize - m_nxOffset, szShadow.cx);j++) *(pLine + j) = 0; for (int j = max(ptAnchorsOri[i - m_nSize + m_nyOffset][1] + m_nSize - m_nxOffset, ptAnchors[i][0]);j < ptAnchors[i][1];j++) *(pLine + j) = clCenter; } } // Delete used resources delete[](ptAnchors - (m_nSize < 0 ? -m_nSize : 0) - 1); delete[] ptAnchorsTmp; delete[] ptAnchorsOri; delete[] pKernel; DeleteObject(hParentRgn); }
LRESULT CALLBACK MinesweeperWndProc(HWND hWnd, UINT msg, UINT wParam, LONG lParam) { HDC hDC, hMemDC; static HRGN *hRgn; static HBITMAP hBitmap, hOldBitmap; static BITMAP Bitmap; static int *iTableMatrix; static int cxClient, cyClient, iRgnCount=0; int i, j, ixCursor, iyCursor, iMineNumber; PAINTSTRUCT PaintStruct; BOOLEAN boolPlaying = TRUE; switch(msg) { case WM_CREATE: srand(time(0)); hRgn = (HRGN*)malloc(SCREEN_X_TILES * SCREEN_Y_TILES * sizeof(HRGN)); iTableMatrix = (int*)malloc(SCREEN_X_TILES * SCREEN_Y_TILES * sizeof(int)); if(!(hBitmap = (HBITMAP)LoadImage(NULL, "Minesweeper1.bmp", IMAGE_BITMAP, 0,0, LR_LOADFROMFILE))) { MessageBox(NULL, "Файл графики не прочитан", "Ошибка", MB_OK); return 0; } for(j = 0; j < SCREEN_Y_TILES; j++) for(i = 0; i < SCREEN_X_TILES; i++) { *(hRgn + j * SCREEN_X_TILES + i) = CreateRectRgn(i * 20, j * 20, (i * 20)+20, (j *20) + 20); iRgnCount++; //FillRgn(hDC, *(hRgn + (j/20) * SCREEN_X_TILES + (i/20)), (HBRUSH)GetStockObject(DKGRAY_BRUSH)); } if( hRgn == NULL ) MessageBox(hWnd, "Создать регион не удалось", "Ошибка", MB_OK); iMineNumber = MINE_NUMBER; boolPlaying = TRUE; while(iMineNumber > 0) { int ixRandom = rand() % SCREEN_X_TILES; int iyRandom = rand() % SCREEN_Y_TILES; if(*(iTableMatrix + (iyRandom * SCREEN_X_TILES + ixRandom)) != 9) { *(iTableMatrix + (iyRandom * SCREEN_X_TILES + ixRandom)) = 9; iMineNumber--; } } //-------------iTableMatrix values----------- // 0 - Clear // 1..8 - Number of mines around // 9 - Mine // 10 - Opened Clear // 11..18 - Opened Number of mines around // 19 - Opened Mine // 20 - Flagged Clear // 21..28 - Flagged Number of mines around // 29 - Flagged Mine for(j = 0; j < SCREEN_Y_TILES; j++) for(i = 0; i < SCREEN_X_TILES; i++) { if(*(iTableMatrix + j * SCREEN_X_TILES + i) != 9) *(iTableMatrix + j * SCREEN_X_TILES + i) = 0; } for(j = 0; j < SCREEN_Y_TILES; j++) for(i = 0; i < SCREEN_X_TILES; i++) if(*(iTableMatrix + j * SCREEN_X_TILES + i) == 9) { if((*(iTableMatrix + (j - 1) * SCREEN_X_TILES + (i - 1))) != 9 && j > 0 && i > 0 ) (*(iTableMatrix + (j - 1) * SCREEN_X_TILES + (i - 1)))++; if((*(iTableMatrix + (j - 1) * SCREEN_X_TILES + (i ))) != 9 && j > 0 ) (*(iTableMatrix + (j - 1) * SCREEN_X_TILES + (i )))++; if((*(iTableMatrix + (j - 1) * SCREEN_X_TILES + (i + 1))) != 9 && j > 0 && i < (SCREEN_X_TILES - 1)) (*(iTableMatrix + (j - 1) * SCREEN_X_TILES + (i + 1)))++; if((*(iTableMatrix + (j ) * SCREEN_X_TILES + (i - 1))) != 9 && i > 0 ) (*(iTableMatrix + (j ) * SCREEN_X_TILES + (i - 1)))++; if((*(iTableMatrix + (j ) * SCREEN_X_TILES + (i + 1))) != 9 && i < (SCREEN_X_TILES - 1)) (*(iTableMatrix + (j ) * SCREEN_X_TILES + (i + 1)))++; if((*(iTableMatrix + (j + 1) * SCREEN_X_TILES + (i - 1))) != 9 && j < (SCREEN_Y_TILES - 1) && i > 0 ) (*(iTableMatrix + (j + 1) * SCREEN_X_TILES + (i - 1)))++; if((*(iTableMatrix + (j + 1) * SCREEN_X_TILES + (i ))) != 9 && j < (SCREEN_Y_TILES - 1) ) (*(iTableMatrix + (j + 1) * SCREEN_X_TILES + (i )))++; if((*(iTableMatrix + (j + 1) * SCREEN_X_TILES + (i + 1))) != 9 && j < (SCREEN_Y_TILES - 1) && i < (SCREEN_X_TILES - 1)) (*(iTableMatrix + (j + 1) * SCREEN_X_TILES + (i + 1)))++; } InvalidateRect(hWnd, NULL, TRUE); return 0; case WM_PAINT: hDC=BeginPaint(hWnd,&PaintStruct); hMemDC=CreateCompatibleDC(hDC); SelectObject(hMemDC, hBitmap); hOldBitmap = (HBITMAP)SelectObject(hMemDC,hBitmap); for(j = 0; j < SCREEN_Y_TILES; j++) for(i = 0; i < SCREEN_X_TILES; i++) { if(boolPlaying) { if((*(iTableMatrix + j * SCREEN_X_TILES + i)) < 10) BitBlt(hDC, i * 20, j * 20, 20, 20, hMemDC, 20, 0, SRCCOPY); else switch(*(iTableMatrix + j * SCREEN_X_TILES + i)) { case 10: BitBlt(hDC, i * 20, j * 20, 20, 20, hMemDC, 60, 0, SRCCOPY); break; case 19: BitBlt(hDC, i * 20, j * 20, 20, 20, hMemDC, 0, 0, SRCCOPY); break; default: if((*(iTableMatrix + j * SCREEN_X_TILES + i)) < 20) BitBlt(hDC, i * 20, j * 20, 20, 20, hMemDC, 60+(((*(iTableMatrix + j * SCREEN_X_TILES + i))-10)*20), 0, SRCCOPY); else if((*(iTableMatrix + j * SCREEN_X_TILES + i)) < 30) BitBlt(hDC, i * 20, j * 20, 20, 20, hMemDC, 40, 0, SRCCOPY); break; } } else { if((*(iTableMatrix + j * SCREEN_X_TILES + i)) < 10) (*(iTableMatrix + j * SCREEN_X_TILES + i)) += 10; switch(*(iTableMatrix + j * SCREEN_X_TILES + i)) { case 10: BitBlt(hDC, i * 20, j * 20, 20, 20, hMemDC, 60, 0, SRCCOPY); break; case 19: BitBlt(hDC, i * 20, j * 20, 20, 20, hMemDC, 0, 0, SRCCOPY); break; default: if((*(iTableMatrix + j * SCREEN_X_TILES + i)) < 20) BitBlt(hDC, i * 20, j * 20, 20, 20, hMemDC, 60+(((*(iTableMatrix + j * SCREEN_X_TILES + i))-10)*20), 0, SRCCOPY); else if((*(iTableMatrix + j * SCREEN_X_TILES + i)) < 29) BitBlt(hDC, i * 20, j * 20, 20, 20, hMemDC, 260, 0, SRCCOPY); else if((*(iTableMatrix + j * SCREEN_X_TILES + i)) == 29) BitBlt(hDC, i * 20, j * 20, 20, 20, hMemDC, 40, 0, SRCCOPY); break; } } /*if(*(iTableMatrix + j * SCREEN_X_TILES + i) == 9) FillRgn(hDC, *(hRgn + j * SCREEN_X_TILES + i), (HBRUSH)GetStockObject(DKGRAY_BRUSH));*/ } SelectObject(hMemDC, hOldBitmap); DeleteDC(hMemDC); EndPaint(hWnd,&PaintStruct); return 0; case WM_SIZE: //hDC = GetDC(hWnd); cxClient = LOWORD(lParam); cyClient = HIWORD(lParam); /*for(j = 0; j < SCREEN_Y_TILES; j++) for(i = 0; i < SCREEN_X_TILES; i++) { if(*(iTableMatrix + j * SCREEN_X_TILES + i) == 9) FillRgn(hDC, *(hRgn + j * SCREEN_X_TILES + i), (HBRUSH)GetStockObject(DKGRAY_BRUSH)); }*/ return 0; case WM_LBUTTONUP: if(!boolPlaying) return 0; ixCursor = LOWORD(lParam); iyCursor = HIWORD(lParam); hDC = GetDC(hWnd); hMemDC=CreateCompatibleDC(hDC); SelectObject(hMemDC, hBitmap); for(j = 0; j < SCREEN_Y_TILES; j++) for(i = 0; i < SCREEN_X_TILES; i++) if(PtInRegion(*(hRgn + j * SCREEN_X_TILES + i), ixCursor, iyCursor)) if((*(iTableMatrix + j * SCREEN_X_TILES + i)) <= 9) switch(*(iTableMatrix + j * SCREEN_X_TILES + i)) { case 0: BitBlt(hDC, i * 20, j * 20, 20, 20, hMemDC, 60, 0, SRCCOPY); //OpenEmptyTiles(hWnd, iTableMatrix, i, j, hBitmap); (*(iTableMatrix + j * SCREEN_X_TILES + i)) = 10; break; case 9: BitBlt(hDC, i * 20, j * 20, 20, 20, hMemDC, 0, 0, SRCCOPY); (*(iTableMatrix + j * SCREEN_X_TILES + i)) = 19; if(MessageBox(hWnd, "Вы умерли. Начать заново?", "R.I.P.", MB_YESNO || MB_APPLMODAL) == IDYES) { SendMessage(hWnd, WM_CREATE, NULL, NULL); } else { boolPlaying = FALSE; InvalidateRect(hWnd, NULL, TRUE); //SendMessage(hWnd, WM_DESTROY, NULL, NULL); } break; default: if((*(iTableMatrix + j * SCREEN_X_TILES + i)) < 20) { BitBlt(hDC, i * 20, j * 20, 20, 20, hMemDC, 60+((*(iTableMatrix + j * SCREEN_X_TILES + i))*20), 0, SRCCOPY); (*(iTableMatrix + j * SCREEN_X_TILES + i)) += 10; } break; } DeleteDC(hMemDC); return 0; case WM_RBUTTONUP: if(!boolPlaying) return 0; ixCursor = LOWORD(lParam); iyCursor = HIWORD(lParam); hDC = GetDC(hWnd); hMemDC=CreateCompatibleDC(hDC); SelectObject(hMemDC, hBitmap); for(j = 0; j < SCREEN_Y_TILES; j++) for(i = 0; i < SCREEN_X_TILES; i++) if(PtInRegion(*(hRgn + j * SCREEN_X_TILES + i), ixCursor, iyCursor)) if((*(iTableMatrix + j * SCREEN_X_TILES + i)) < 20) { BitBlt(hDC, i * 20, j * 20, 20, 20, hMemDC, 40, 0, SRCCOPY); (*(iTableMatrix + j * SCREEN_X_TILES + i)) += 20; break; } else if((*(iTableMatrix + j * SCREEN_X_TILES + i)) >= 20) { BitBlt(hDC, i * 20, j * 20, 20, 20, hMemDC, 20, 0, SRCCOPY); (*(iTableMatrix + j * SCREEN_X_TILES + i)) -= 20; break; } DeleteDC(hMemDC); return 0; case WM_DESTROY: PostQuitMessage(0); free(hRgn); free(iTableMatrix); return 0; } return DefWindowProc(hWnd, msg, wParam, lParam); }
int GetWindowVisibleState(HWND hWnd, int iStepX, int iStepY) { RECT rc = { 0 }; POINT pt = { 0 }; register int i = 0, j = 0, width = 0, height = 0, iCountedDots = 0, iNotCoveredDots = 0; HWND hAux = 0; if (hWnd == NULL) { SetLastError(0x00000006); //Wrong handle return -1; } //Some defaults now. The routine is designed for thin and tall windows. if (iStepX <= 0) iStepX = 8; if (iStepY <= 0) iStepY = 16; HWND hwndFocused = GetFocus(); if (IsIconic(hWnd) || !IsWindowVisible(hWnd)) return GWVS_HIDDEN; else if ( ModernGetSettingByte(NULL,"CList","OnDesktop",SETTING_ONDESKTOP_DEFAULT) || !ModernGetSettingByte(NULL, "CList", "BringToFront", SETTING_BRINGTOFRONT_DEFAULT) ) return GWVS_VISIBLE; else if ( hwndFocused == pcli->hwndContactList || GetParent(hwndFocused) == pcli->hwndContactList ) return GWVS_VISIBLE; else { int hstep,vstep; BITMAP bmp; HBITMAP WindowImage; int maxx=0; int maxy=0; int wx=0; int dx,dy; BYTE *ptr=NULL; HRGN rgn=NULL; WindowImage=g_CluiData.fLayered?ske_GetCurrentWindowImage():0; if (WindowImage&&g_CluiData.fLayered) { GetObject(WindowImage,sizeof(BITMAP),&bmp); ptr=(BYTE*)bmp.bmBits; maxx=bmp.bmWidth; maxy=bmp.bmHeight; wx=bmp.bmWidthBytes; } else { RECT rc; int i=0; rgn=CreateRectRgn(0,0,1,1); GetWindowRect(hWnd,&rc); GetWindowRgn(hWnd,rgn); OffsetRgn(rgn,rc.left,rc.top); GetRgnBox(rgn,&rc); i=i; //maxx=rc.right; //maxy=rc.bottom; } GetWindowRect(hWnd, &rc); { RECT rcMonitor={0}; Docking_GetMonitorRectFromWindow(hWnd,&rcMonitor); rc.top=rc.top<rcMonitor.top?rcMonitor.top:rc.top; rc.left=rc.left<rcMonitor.left?rcMonitor.left:rc.left; rc.bottom=rc.bottom>rcMonitor.bottom?rcMonitor.bottom:rc.bottom; rc.right=rc.right>rcMonitor.right?rcMonitor.right:rc.right; } width = rc.right - rc.left; height = rc.bottom- rc.top; dx=-rc.left; dy=-rc.top; hstep=width/iStepX; vstep=height/iStepY; hstep=hstep>0?hstep:1; vstep=vstep>0?vstep:1; for (i = rc.top; i < rc.bottom; i+=vstep) { pt.y = i; for (j = rc.left; j < rc.right; j+=hstep) { BOOL po=FALSE; pt.x = j; if (rgn) po=PtInRegion(rgn,j,i); else { DWORD a=(GetDIBPixelColor(j+dx,i+dy,maxx,maxy,wx,ptr)&0xFF000000)>>24; a=((a*g_CluiData.bCurrentAlpha)>>8); po=(a>16); } if (po||(!rgn&&ptr==0)) { BOOL hWndFound=FALSE; HWND hAuxOld=NULL; hAux = WindowFromPoint(pt); do { if (hAux==hWnd) { hWndFound=TRUE; break; } //hAux = GetParent(hAux); hAuxOld=hAux; hAux = fnGetAncestor(hAux,GA_ROOTOWNER); if (hAuxOld==hAux) { TCHAR buf[255]; GetClassName(hAux,buf,SIZEOF(buf)); if (!lstrcmp(buf,CLUIFrameSubContainerClassName)) { hWndFound=TRUE; break; } } }while(hAux!= NULL &&hAuxOld!=hAux); if (hWndFound) //There's window! iNotCoveredDots++; //Let's count the not covered dots. iCountedDots++; //Let's keep track of how many dots we checked. } } } if (rgn) DeleteObject(rgn); if ( iCountedDots - iNotCoveredDots<2) //Every dot was not covered: the window is visible. return GWVS_VISIBLE; else if (iNotCoveredDots == 0) //They're all covered! return GWVS_COVERED; else //There are dots which are visible, but they are not as many as the ones we counted: it's partially covered. return GWVS_PARTIALLY_COVERED; } }
void KMyCanvas::OnDraw(HDC hDC, const RECT * rcPaint) { if ( m_lastlimit>= m_limit ) return; TCHAR title [MAX_PATH]; sprintf(title, "Mandelbrot Set (%f %f) zoom %d:%d unit %f", m_x, m_y, m_zoommul, m_zoomdiv, m_unit); SetWindowText(GetParent(m_hWnd), title); int tick = GetTickCount(); if ( rcPaint ) m_lastlimit = 0; RECT rect; GetClientRect(m_hWnd, & rect); int x0 = GetScrollPos(m_hWnd, SB_HORZ); int y0 = GetScrollPos(m_hWnd, SB_VERT); // ClearBuffer(rect.right, rect.bottom, x0, y0); HRGN hRgn = CreateRectRgn(0, 0, 1, 1); { GetRandomRgn(hDC, hRgn, SYSRGN); POINT p0; GetDCOrgEx(hDC, & p0); // change region to be relative to DC, NT only // if ( HIWORD(hDC) ) OffsetRgn(hRgn, - p0.x, - p0.y); } m_lastlimit += 16; for (int y=0; y<rect.bottom; y++) { COLORREF lastc = 0xFFFFFFFF; int count = 0; for (int x=0; x<rect.right; x++) // if ( Buffer[y][x]==0 ) if ( PtInRegion(hRgn, x, y) ) { int count = MandelCount(NULL, x+x0, y+y0, m_limit); COLORREF c = 0; if ( count==0 ) // don't know c = RGB(64, 78, 170); // Red else if ( count>0 ) // yes c = In[count]; // green else if ( count< -3 ) c = Out[-count]; // Buffer[y][x] = count; if ( c ) SetPixel(hDC, x+x0, y+y0, c); } } tick = GetTickCount() - tick; wsprintf(title, "tick %d", tick); m_pStatus->SetText(1, title); }
void CInfoDisplay::OnPaint() { CPaintDC dc(this); // device context for painting CFont *pFont = GetFont(); dc.SelectObject(pFont); // First, we compute the maximum line width, and set the rectangle wide enough to // hold this. Then we use DrawText/DT_CALCRECT to compute the height CSecString text; GetWindowText(text); CSize box = CSize(0, 0); // First replace all "\r\n" by"\n" then any remaining "\r" to "\n" text.Replace(L"\r\n", L"\n"); text.Replace(L'\r', L'\n'); TEXTMETRIC tm; dc.GetTextMetrics(&tm); int inf; // inflation factor { /* compute box size */ CSecString s = text; while(TRUE) { /* scan string */ CSecString line; int p = s.Find(L"\n"); if (p < 0) line = s; else { /* one line */ line = s.Left(p); s = s.Mid(p + 1); } /* one line */ CSize sz = dc.GetTextExtent(line); box.cx = max(box.cx, sz.cx); box.cy += tm.tmHeight + tm.tmInternalLeading; if (p < 0) break; } /* scan string */ // Having computed the width, allow for the borders and extra space for margins inf = 4 * ::GetSystemMetrics(SM_CXBORDER); box.cx += 2 * inf; box.cy += 2 * inf; CRect rc(0, 0, 0, 0); rc.right = box.cx; rc.bottom = box.cy; bool bMoveWindow(false); int x = 0, y = 0; // Get area of potentially multiple monitors! - defined in DboxMain.cpp as extern // if use_current_monitor was set in constructor, we'll check only screen where mouse is located HRGN hrgn; POINT mouse_pt; GetCursorPos(&mouse_pt); if (m_use_current_monitor){ MONITORINFO mi; mi.cbSize = sizeof(mi); GetMonitorInfo(MonitorFromPoint(mouse_pt, MONITOR_DEFAULTTONEAREST), &mi); hrgn = CreateRectRgn(mi.rcWork.left, mi.rcWork.top, mi.rcWork.right, mi.rcWork.bottom); } else hrgn = GetWorkAreaRegion(); if (hrgn != NULL) { // Test that all tip window is visible in the desktop rectangle. CRect rs(rc); // Convert to screen co-ordinates ClientToScreen(rs); if (!PtInRegion(hrgn, rs.right, rs.bottom) || !PtInRegion(hrgn, rs.left, rs.top)) { // Not in region - move Window RECT hr; if (GetRgnBox(hrgn, &hr)){ if (rs.right > hr.right) { if (mouse_pt.x - rs.Width() - 1 >= hr.left) // can flip left? x = mouse_pt.x - rs.Width() - 1; else if (hr.right - rs.Width() >= hr.left) // can shift left and fit width? x = hr.right - rs.Width(); else // press to left border x = hr.left; } else // no need to move x = rs.left; if (rs.bottom > hr.bottom) { if (mouse_pt.y - rs.Height() - 1 >= hr.top) // can flip up? y = mouse_pt.y - rs.Height() - 1; else if (hr.bottom - rs.Height() >= hr.top) // can shift up and fit height? y = hr.bottom - rs.Height(); else // press to top border y = hr.top; } else // no need to move y = rs.top; bMoveWindow = true; // Check that mouse pointer isn't on infowindow: when it is, window isn't displayed (treated somewhere as focus/mouse move?) if ((mouse_pt.x >= x) && (mouse_pt.x <= x + rs.Width()) && (mouse_pt.y >= y) && (mouse_pt.y <= y + rs.Height())) { if (mouse_pt.y == y) y++; else if (mouse_pt.y == y + rs.Height()) y--; else if (mouse_pt.x == x) x++; else if (mouse_pt.x == x + rs.Width()) x--; else if ((mouse_pt.y >= y) && (mouse_pt.y <= y + rs.Height())) // show top part of the message and trim/split bottom y = mouse_pt.y + 1; } } } DeleteObject(hrgn); } // Set the window size SetWindowPos(NULL, x, y, rc.Width(), rc.Height(), (bMoveWindow ? 0: SWP_NOMOVE) | SWP_NOZORDER | SWP_NOACTIVATE); } /* compute box size */ CRect r; GetClientRect(&r); r.InflateRect(-inf, -inf); dc.SetBkMode(TRANSPARENT); CSecString s = text; int y = r.top; while(TRUE) { /* scan string */ CSecString line; int p = s.Find(L"\n"); if (p < 0) { line = s; } else { /* one line */ line = s.Left(p); s = s.Mid(p + 1); } /* one line */ dc.TextOut(r.left, y, line); y += tm.tmHeight + tm.tmInternalLeading; if (p < 0) break; } /* scan string */ // Do not call CWnd::OnPaint() for painting messages }