void ThemeDrawScrollBar(PDRAW_CONTEXT pcontext, INT nBar, POINT* pt) { SCROLLINFO si; SCROLLBARINFO sbi; BOOL vertical; enum SCROLL_HITTEST htHot = SCROLL_NOWHERE; /* Retrieve scrollbar info */ sbi.cbSize = sizeof(sbi); si.cbSize = sizeof(si); si.fMask = SIF_ALL ; GetScrollInfo(pcontext->hWnd, nBar, &si); GetScrollBarInfo(pcontext->hWnd, SCROLL_getObjectId(nBar), &sbi); vertical = SCROLL_IsVertical(pcontext->hWnd, nBar); if(sbi.rgstate[SCROLL_TOP_ARROW] & STATE_SYSTEM_UNAVAILABLE && sbi.rgstate[SCROLL_BOTTOM_ARROW] & STATE_SYSTEM_UNAVAILABLE ) { sbi.xyThumbTop = 0; } #ifndef ROS_SUCKS /* The scrollbar rect is in screen coordinates */ // OffsetRect(&sbi.rcScrollBar, -pcontext->wi.rcWindow.left, -pcontext->wi.rcWindow.top); #endif if(pt) { ScreenToWindow(pcontext->hWnd, pt); htHot = SCROLL_HitTest(pcontext->hWnd, &sbi, vertical, *pt, FALSE); } if (((nBar == SB_VERT) && !(pcontext->wi.dwStyle & WS_VSCROLL)) || ((nBar == SB_HORZ) && !(pcontext->wi.dwStyle & WS_HSCROLL))) return; /* do not draw if the scrollbar rectangle is empty */ if(IsRectEmpty(&sbi.rcScrollBar)) return; /* Draw the scrollbar */ SCROLL_DrawArrows( pcontext, &sbi, vertical, 0, htHot ); SCROLL_DrawInterior( pcontext, &sbi, sbi.xyThumbTop, vertical, 0, htHot ); }
LRESULT CALLBACK WndProcViewLog( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam ) { //LPNMHDR hdr; //TVITEM tvit; NMLVDISPINFO *lvdi; wchar_t buff[2048]; int buff_r; int buff_g; int buff_b; wchar_t* pos=0; DWORD dwStyle; UINT idButton; SCROLLBARINFO sbi; TBBUTTON tbButton={LOWORD(lParam)-70, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0}; sbi.cbSize=sizeof(SCROLLBARINFO); switch(Msg) { case WM_DESTROY: mLogWnd[hWnd].exit = true; PostQuitMessage(0); break; break; case WM_COMMAND: if ((HWND)lParam==mLogWnd[hWnd].hToolBar) { switch (wParam) { case 123: //find button SendMessage(mLogWnd[hWnd].hFindText,WM_GETTEXT,2048,(LPARAM)buff); mLogWnd[hWnd].Find(buff); break; case 125: if (SendMessage(mLogWnd[hWnd].hToolBar,TB_ISBUTTONCHECKED,125,0)) { SetWindowPos(hWnd,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE); } else { SetWindowPos(hWnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE); } break; } } break; case WM_SIZE: MoveWindow(mLogWnd[hWnd].hListView,0,28,LOWORD(lParam),HIWORD(lParam)-28,TRUE); SetWindowPos(mLogWnd[hWnd].hFindText,0,LOWORD(lParam)-225,2,0,0,SWP_NOZORDER | SWP_NOSIZE); SetWindowPos(mLogWnd[hWnd].hProgressBar,0,LOWORD(lParam)-225,2,0,0,SWP_NOZORDER | SWP_NOSIZE); SendMessage(mLogWnd[hWnd].hToolBar,TB_DELETEBUTTON,0,0); SendMessage(mLogWnd[hWnd].hToolBar,TB_INSERTBUTTON,0,(LPARAM)&tbButton); SendMessage(mLogWnd[hWnd].hToolBar,TB_AUTOSIZE,0,0); LVCOLUMN lcol; lcol.mask = LVCF_WIDTH; dwStyle = (DWORD)GetWindowLong(mLogWnd[hWnd].hListView, GWL_STYLE); if (dwStyle & WS_VSCROLL) { GetScrollBarInfo(mLogWnd[hWnd].hListView,OBJID_VSCROLL,&sbi); lcol.cx = LOWORD(lParam)-sbi.dxyLineButton; } else {lcol.cx = LOWORD(lParam);} ListView_SetColumn(mLogWnd[hWnd].hListView,0,&lcol); break; case WM_NOTIFY: LPNMLISTVIEW pnm; pnm = (LPNMLISTVIEW)lParam; switch (pnm->hdr.code) { case NM_CUSTOMDRAW: NMLVCUSTOMDRAW *nmlvcd; nmlvcd = (NMLVCUSTOMDRAW *)lParam; switch (nmlvcd -> nmcd.dwDrawStage) { case CDDS_PREPAINT: return CDRF_NOTIFYITEMDRAW; break; case CDDS_ITEMPREPAINT: // Determine colors if (mLogWnd[hWnd].vList.size()==0 || nmlvcd -> nmcd.dwItemSpec>mLogWnd[hWnd].vList.size()) { return CDRF_NEWFONT; } if (swscanf_s (mLogWnd[hWnd].vList[nmlvcd -> nmcd.dwItemSpec].c_str(), L"%[a-zA-Z?ÿ??_.]%*[:|]%d,%d,%d",buff,1024,&buff_r,&buff_g,&buff_b )==4) { nmlvcd -> clrTextBk = RGB(buff_r,buff_g,buff_b); } /*if ( nmlvcd -> nmcd.dwItemSpec & 1 ) { nmlvcd -> clrTextBk = RGB(200,200,200); //nmlvcd -> //nmlvcd -> clrText = 0xF0F0F0; SelectObject ( nmlvcd -> nmcd.hdc, GetStockObject (SYSTEM_FONT) ); //return CDRF_NEWFONT; } else { nmlvcd -> clrTextBk = RGB(230,230,230); }*/ return CDRF_NEWFONT; break; } break; case TTN_GETDISPINFO: LPTOOLTIPTEXT lpttt; lpttt = (LPTOOLTIPTEXT) lParam; lpttt->hinst = App.hIns; // Specify the resource identifier of the descriptive // text for the given button. idButton = lpttt->hdr.idFrom; switch (idButton) { case 123: lpttt->lpszText = MAKEINTRESOURCE(IDS_STRING_UFINDBUTTON); break; case 124: lpttt->lpszText = MAKEINTRESOURCE(IDS_STRING_UASCROLL); break; case 125: lpttt->lpszText = MAKEINTRESOURCE(IDS_STRING_UTOP); break; } break; case NM_DBLCLK: DialogBox(App.hIns,MAKEINTRESOURCE(IDD_DIALOGVIEWMSG),mLogWnd[hWnd].hWnd,(DLGPROC)DlgMsgProc); break; case LVN_GETDISPINFO: lvdi = (NMLVDISPINFO*) lParam; if (lvdi->item.mask & LVIF_TEXT) { //while (lvdi->item.pszText=wcscspn(mLogWnd[hWnd].vList[lvdi->item.iItem].c_str(),L":|:")) //wcscpy( buff,const_cast<LPWSTR>(mLogWnd[hWnd].vList[lvdi->item.iItem].c_str())); lvdi->item.pszText = const_cast<LPWSTR>(mLogWnd[hWnd].vList[lvdi->item.iItem].c_str()); // remove "Debug"... //while ((pos=wcsstr(lvdi->item.pszText,L":|:"))!=NULL) //{ // lvdi->item.pszText=pos+3; //} lvdi->item.cchTextMax = 1024; } break; }// switch break; // WM_NOTIFY default: return DefWindowProc(hWnd,Msg,wParam,lParam); } return(0); }
static void SCROLL_HandleScrollEvent( HWND hwnd, INT nBar, UINT msg, POINT pt) { /* Previous mouse position for timer events */ static POINT prevPt; /* Thumb position when tracking started. */ static UINT trackThumbPos; /* Position in the scroll-bar of the last button-down event. */ static INT lastClickPos; /* Position in the scroll-bar of the last mouse event. */ static INT lastMousePos; enum SCROLL_HITTEST hittest; HWND hwndOwner, hwndCtl; BOOL vertical; SCROLLINFO si; SCROLLBARINFO sbi; DRAW_CONTEXT context; si.cbSize = sizeof(si); sbi.cbSize = sizeof(sbi); si.fMask = SIF_ALL; GetScrollInfo(hwnd, nBar, &si); GetScrollBarInfo(hwnd, SCROLL_getObjectId(nBar), &sbi); vertical = SCROLL_IsVertical(hwnd, nBar); if(sbi.rgstate[SCROLL_TOP_ARROW] & STATE_SYSTEM_UNAVAILABLE && sbi.rgstate[SCROLL_BOTTOM_ARROW] & STATE_SYSTEM_UNAVAILABLE ) { return; } ThemeInitDrawContext(&context, hwnd, 0); #ifndef ROS_SUCKS /* The scrollbar rect is in screen coordinates */ // OffsetRect(&sbi.rcScrollBar, -context.wi.rcWindow.left, -context.wi.rcWindow.top); #endif if ((SCROLL_trackHitTest == SCROLL_NOWHERE) && (msg != WM_LBUTTONDOWN)) return; hwndOwner = (nBar == SB_CTL) ? GetParent(hwnd) : hwnd; hwndCtl = (nBar == SB_CTL) ? hwnd : 0; switch(msg) { case WM_LBUTTONDOWN: /* Initialise mouse tracking */ HideCaret(hwnd); /* hide caret while holding down LBUTTON */ SCROLL_trackVertical = vertical; SCROLL_trackHitTest = hittest = SCROLL_HitTest( hwnd, &sbi, vertical, pt, FALSE ); lastClickPos = vertical ? (pt.y - sbi.rcScrollBar.top) : (pt.x - sbi.rcScrollBar.left); lastMousePos = lastClickPos; trackThumbPos = sbi.xyThumbTop; prevPt = pt; SetCapture( hwnd ); break; case WM_MOUSEMOVE: hittest = SCROLL_HitTest( hwnd, &sbi, vertical, pt, TRUE ); prevPt = pt; break; case WM_LBUTTONUP: hittest = SCROLL_NOWHERE; ReleaseCapture(); /* if scrollbar has focus, show back caret */ if (hwnd==GetFocus()) ShowCaret(hwnd); break; case WM_SYSTIMER: pt = prevPt; hittest = SCROLL_HitTest( hwnd, &sbi, vertical, pt, FALSE ); break; default: return; /* Should never happen */ } //TRACE("Event: hwnd=%p bar=%d msg=%s pt=%d,%d hit=%d\n", // hwnd, nBar, SPY_GetMsgName(msg,hwnd), pt.x, pt.y, hittest ); switch(SCROLL_trackHitTest) { case SCROLL_NOWHERE: /* No tracking in progress */ break; case SCROLL_TOP_ARROW: if (hittest == SCROLL_trackHitTest) { SCROLL_DrawArrows( &context, &sbi, vertical, SCROLL_trackHitTest, 0 ); if ((msg == WM_LBUTTONDOWN) || (msg == WM_SYSTIMER)) { SendMessageW( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, SB_LINEUP, (LPARAM)hwndCtl ); } SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ? SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY, NULL ); } else { SCROLL_DrawArrows( &context, &sbi, vertical, 0, 0 ); KillSystemTimer( hwnd, SCROLL_TIMER ); } break; case SCROLL_TOP_RECT: SCROLL_DrawInterior( &context, &sbi, sbi.xyThumbTop, vertical, SCROLL_trackHitTest, 0); if (hittest == SCROLL_trackHitTest) { if ((msg == WM_LBUTTONDOWN) || (msg == WM_SYSTIMER)) { SendMessageW( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, SB_PAGEUP, (LPARAM)hwndCtl ); } SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ? SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY, NULL ); } else KillSystemTimer( hwnd, SCROLL_TIMER ); break; case SCROLL_THUMB: if (msg == WM_LBUTTONDOWN) { SCROLL_TrackingWin = hwnd; SCROLL_TrackingBar = nBar; SCROLL_TrackingPos = trackThumbPos + lastMousePos - lastClickPos; SCROLL_TrackingVal = SCROLL_GetThumbVal( &si, &sbi.rcScrollBar, vertical, SCROLL_TrackingPos ); if (!SCROLL_MovingThumb) SCROLL_DrawMovingThumb(&context, &sbi, vertical); } else if (msg == WM_LBUTTONUP) { if (SCROLL_MovingThumb) SCROLL_DrawMovingThumb(&context, &sbi, vertical); SCROLL_DrawInterior( &context, &sbi, sbi.xyThumbTop, vertical, 0, SCROLL_trackHitTest ); } else /* WM_MOUSEMOVE */ { INT pos; if (!SCROLL_PtInRectEx( &sbi.rcScrollBar, pt, vertical )) pos = lastClickPos; else { pt = SCROLL_ClipPos( &sbi.rcScrollBar, pt ); pos = vertical ? (pt.y - sbi.rcScrollBar.top) : (pt.x - sbi.rcScrollBar.left); } if ( (pos != lastMousePos) || (!SCROLL_MovingThumb) ) { if (SCROLL_MovingThumb) SCROLL_DrawMovingThumb( &context, &sbi, vertical); lastMousePos = pos; SCROLL_TrackingPos = trackThumbPos + pos - lastClickPos; SCROLL_TrackingVal = SCROLL_GetThumbVal( &si, &sbi.rcScrollBar, vertical, SCROLL_TrackingPos ); SendMessageW( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, MAKEWPARAM( SB_THUMBTRACK, SCROLL_TrackingVal), (LPARAM)hwndCtl ); if (!SCROLL_MovingThumb) SCROLL_DrawMovingThumb( &context, &sbi, vertical); } } break; case SCROLL_BOTTOM_RECT: if (hittest == SCROLL_trackHitTest) { SCROLL_DrawInterior( &context, &sbi, sbi.xyThumbTop, vertical, SCROLL_trackHitTest, 0 ); if ((msg == WM_LBUTTONDOWN) || (msg == WM_SYSTIMER)) { SendMessageW( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, SB_PAGEDOWN, (LPARAM)hwndCtl ); } SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ? SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY, NULL ); } else { SCROLL_DrawInterior( &context, &sbi, sbi.xyThumbTop, vertical, 0, 0 ); KillSystemTimer( hwnd, SCROLL_TIMER ); } break; case SCROLL_BOTTOM_ARROW: if (hittest == SCROLL_trackHitTest) { SCROLL_DrawArrows( &context, &sbi, vertical, SCROLL_trackHitTest, 0 ); if ((msg == WM_LBUTTONDOWN) || (msg == WM_SYSTIMER)) { SendMessageW( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, SB_LINEDOWN, (LPARAM)hwndCtl ); } SetSystemTimer( hwnd, SCROLL_TIMER, (msg == WM_LBUTTONDOWN) ? SCROLL_FIRST_DELAY : SCROLL_REPEAT_DELAY, NULL ); } else { SCROLL_DrawArrows( &context, &sbi, vertical, 0, 0 ); KillSystemTimer( hwnd, SCROLL_TIMER ); } break; } if (msg == WM_LBUTTONDOWN) { if (hittest == SCROLL_THUMB) { UINT val = SCROLL_GetThumbVal( &si, &sbi.rcScrollBar, vertical, trackThumbPos + lastMousePos - lastClickPos ); SendMessageW( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, MAKEWPARAM( SB_THUMBTRACK, val ), (LPARAM)hwndCtl ); } } if (msg == WM_LBUTTONUP) { hittest = SCROLL_trackHitTest; SCROLL_trackHitTest = SCROLL_NOWHERE; /* Terminate tracking */ if (hittest == SCROLL_THUMB) { UINT val = SCROLL_GetThumbVal( &si, &sbi.rcScrollBar, vertical, trackThumbPos + lastMousePos - lastClickPos ); SendMessageW( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, MAKEWPARAM( SB_THUMBPOSITION, val ), (LPARAM)hwndCtl ); } /* SB_ENDSCROLL doesn't report thumb position */ SendMessageW( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, SB_ENDSCROLL, (LPARAM)hwndCtl ); /* Terminate tracking */ SCROLL_TrackingWin = 0; } ThemeCleanupDrawContext(&context); }