// Paint //////////////////////////////////////////////////////////////////1.00 // WM_PAINTに応答。 // 無効化されたクライアント領域を取得し、 // 再描画している。 int ClassABrowserView::Paint() { PAINTSTRUCT ps; HDC hDC = BeginPaint(hWnd, &ps); // DC取得 // 表示位置の補正 if (nLineView < 0) nLineView = 0; else if (nLineView > nLineViewMax) nLineView = nLineViewMax; // スクロールバーの情報設定 si.fMask = SIF_DISABLENOSCROLL | SIF_POS; si.nPos = (int)(nLineView / dblScroll); SetScrollInfo(hWnd, SB_VERT, &si, TRUE); // 画面の端ではスクロールバーを使用不可にする EnableScrollBar(hWnd, SB_VERT, ESB_ENABLE_BOTH); if (nLineView == 0) EnableScrollBar(hWnd, SB_VERT, ESB_DISABLE_UP); if (nLineView == nLineViewMax) EnableScrollBar(hWnd, SB_VERT, ESB_DISABLE_DOWN); PaintSub(hDC, ps.rcPaint.top / tm.tmHeight, ps.rcPaint.bottom / tm.tmHeight + 1, TRUE); EndPaint(hWnd, &ps); return 0; }
void CListSide::UpdateScrollBar(int nBottom) { RECT client; GetClientRect(m_hWnd, &client); SCROLLINFO si; si.cbSize = sizeof(SCROLLINFO); si.fMask = SIF_POS; GetScrollInfo(m_hWnd, SB_VERT, &si); si.fMask = SIF_RANGE | SIF_PAGE; si.nMin = 0; si.nPage = client.bottom;// + 1; si.nMax = nBottom + si.nPos; m_dMaxScroll = si.nMax; m_dPage = si.nPage; int add = /*nBottom*/ si.nMax - client.bottom; if (add > 0) { SetScrollInfo(m_hWnd, SB_VERT, &si, 1); EnableScrollBar(m_hWnd, SB_VERT, ESB_ENABLE_BOTH); m_bScrollEnabled = true; } else { EnableScrollBar(m_hWnd, SB_VERT, ESB_DISABLE_BOTH); m_bScrollEnabled = false; } }
void CContainerUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) { if( _tcsicmp(pstrName, _T("inset")) == 0 ) { RECT rcInset = { 0 }; LPTSTR pstr = NULL; rcInset.left = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); rcInset.top = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcInset.right = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcInset.bottom = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); SetInset(rcInset); } else if( _tcsicmp(pstrName, _T("mousechild")) == 0 ) SetMouseChildEnabled(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("vscrollbar")) == 0 ) { EnableScrollBar(_tcsicmp(pstrValue, _T("true")) == 0, GetHorizontalScrollBar() != NULL); } else if( _tcsicmp(pstrName, _T("vscrollbarstyle")) == 0 ) { m_sVerticalScrollBarStyle = pstrValue; EnableScrollBar(TRUE, GetHorizontalScrollBar() != NULL); if( GetVerticalScrollBar() ) { LPCTSTR pStyle = m_pManager->GetStyle(m_sVerticalScrollBarStyle); if( pStyle ) { GetVerticalScrollBar()->ApplyAttributeList(pStyle); } else { GetVerticalScrollBar()->ApplyAttributeList(pstrValue); } } } //else if( _tcsicmp(pstrName, _T("vscrollbarstyle")) == 0 ) { // EnableScrollBar(true, GetHorizontalScrollBar() != NULL); // if( GetVerticalScrollBar() ) GetVerticalScrollBar()->ApplyAttributeList(pstrValue); //} else if( _tcsicmp(pstrName, _T("hscrollbar")) == 0 ) { EnableScrollBar(GetVerticalScrollBar() != NULL, _tcsicmp(pstrValue, _T("true")) == 0); } else if( _tcsicmp(pstrName, _T("hscrollbarstyle")) == 0 ) { m_sHorizontalScrollBarStyle = pstrValue; EnableScrollBar(TRUE, GetHorizontalScrollBar() != NULL); if( GetHorizontalScrollBar() ) { LPCTSTR pStyle = m_pManager->GetStyle(m_sHorizontalScrollBarStyle); if( pStyle ) { GetHorizontalScrollBar()->ApplyAttributeList(pStyle); } else { GetHorizontalScrollBar()->ApplyAttributeList(pstrValue); } } } //else if( _tcsicmp(pstrName, _T("hscrollbarstyle")) == 0 ) { // EnableScrollBar(GetVerticalScrollBar() != NULL, true); // if( GetHorizontalScrollBar() ) GetHorizontalScrollBar()->ApplyAttributeList(pstrValue); //} else if( _tcsicmp(pstrName, _T("childpadding")) == 0 ) SetChildPadding(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("scrollstepsize")) == 0 ) SetScrollStepSize(_ttoi(pstrValue)); else CControlUI::SetAttribute(pstrName, pstrValue); }
static int winCanvasSetDYAttrib(Ihandle* ih, const char *value) { if (ih->data->sb & IUP_SB_VERT) { double posy, ymin, ymax; float dy; int iposy, ipagey; if (!iupStrToFloatDef(value, &dy, 0.1f)) return 1; ymin = iupAttribGetFloat(ih, "YMIN"); ymax = iupAttribGetFloat(ih, "YMAX"); posy = ih->data->posy; iupCanvasCalcScrollIntPos(ymin, ymax, dy, posy, IUP_SB_MIN, IUP_SB_MAX, &ipagey, &iposy); winCanvasSetScrollInfo(ih->handle, IUP_SB_MIN, IUP_SB_MAX, ipagey, SB_VERT, iupAttribGetBoolean(ih, "YAUTOHIDE")); if (dy >= (ymax-ymin)) { if (iupAttribGetBoolean(ih, "YAUTOHIDE")) { iupAttribSet(ih, "YHIDDEN", "YES"); ShowScrollBar(ih->handle, SB_VERT, FALSE); SetScrollPos(ih->handle, SB_VERT, IUP_SB_MIN, FALSE); } else { EnableScrollBar(ih->handle, SB_VERT, ESB_DISABLE_BOTH); SetScrollPos(ih->handle, SB_VERT, IUP_SB_MIN, TRUE); } ih->data->posy = (float)ymin; return 1; } else { if (iupAttribGetBoolean(ih, "YAUTOHIDE")) { iupAttribSet(ih, "YHIDDEN", "NO"); ShowScrollBar(ih->handle, SB_VERT, TRUE); } else EnableScrollBar(ih->handle, SB_VERT, ESB_ENABLE_BOTH); /* also update position because it could have being changed */ iupCanvasCalcScrollRealPos(ymin, ymax, &posy, IUP_SB_MIN, IUP_SB_MAX, ipagey, &iposy); SetScrollPos(ih->handle, SB_VERT, iposy, TRUE); ih->data->posy = (float)posy; } } return 1; }
static int winCanvasSetDXAttrib(Ihandle* ih, const char *value) { if (ih->data->sb & IUP_SB_HORIZ) { double posx, xmin, xmax; float dx; int iposx, ipagex; if (!iupStrToFloatDef(value, &dx, 0.1f)) return 1; xmin = iupAttribGetFloat(ih, "XMIN"); xmax = iupAttribGetFloat(ih, "XMAX"); posx = ih->data->posx; iupCanvasCalcScrollIntPos(xmin, xmax, dx, posx, IUP_SB_MIN, IUP_SB_MAX, &ipagex, &iposx); winCanvasSetScrollInfo(ih->handle, IUP_SB_MIN, IUP_SB_MAX, ipagex, SB_HORZ, iupAttribGetBoolean(ih, "XAUTOHIDE")); if (dx >= (xmax-xmin)) { if (iupAttribGetBoolean(ih, "XAUTOHIDE")) { iupAttribSet(ih, "XHIDDEN", "YES"); ShowScrollBar(ih->handle, SB_HORZ, FALSE); SetScrollPos(ih->handle, SB_HORZ, IUP_SB_MIN, FALSE); } else { EnableScrollBar(ih->handle, SB_HORZ, ESB_DISABLE_BOTH); SetScrollPos(ih->handle, SB_HORZ, IUP_SB_MIN, TRUE); } ih->data->posx = (float)xmin; } else { if (iupAttribGetBoolean(ih, "XAUTOHIDE")) { iupAttribSet(ih, "XHIDDEN", "NO"); ShowScrollBar(ih->handle, SB_HORZ, TRUE); } else EnableScrollBar(ih->handle, SB_HORZ, ESB_ENABLE_BOTH); /* also update position because it could have being changed */ iupCanvasCalcScrollRealPos(xmin, xmax, &posx, IUP_SB_MIN, IUP_SB_MAX, ipagex, &iposx); SetScrollPos(ih->handle, SB_HORZ, iposx, TRUE); ih->data->posx = (float)posx; } } return 1; }
static void test_SetScrollInfo(void) { SCROLLINFO si; HWND mainwnd; BOOL ret; mainwnd = create_main_test_wnd(); ret = IsWindowEnabled(hScroll); ok(ret, "scroll bar disabled\n"); EnableScrollBar(hScroll, SB_CTL, ESB_DISABLE_BOTH); ret = IsWindowEnabled(hScroll); ok(!ret, "scroll bar enabled\n"); memset(&si, 0, sizeof(si)); si.cbSize = sizeof(si); si.fMask = 0xf; ret = GetScrollInfo(hScroll, SB_CTL, &si); ok(ret, "got %d\n", ret); /* SetScrollInfo */ memset(&si, 0, sizeof(si)); si.cbSize = sizeof(si); ret = IsWindowEnabled(hScroll); ok(!ret, "scroll bar enabled\n"); si.fMask = SIF_POS|SIF_RANGE|SIF_PAGE|SIF_DISABLENOSCROLL; si.nMax = 100; si.nMin = 10; si.nPos = 0; si.nPage = 100; SetScrollInfo(hScroll, SB_CTL, &si, TRUE); ret = IsWindowEnabled(hScroll); ok(!ret, "scroll bar enabled\n"); si.fMask = 0xf; ret = GetScrollInfo(hScroll, SB_CTL, &si); ok(ret, "got %d\n", ret); EnableScrollBar(hScroll, SB_CTL, ESB_ENABLE_BOTH); ok(IsWindowEnabled(hScroll), "expected enabled scrollbar\n"); si.fMask = SIF_POS|SIF_RANGE|SIF_PAGE|SIF_DISABLENOSCROLL; si.nMax = 10; si.nMin = 100; si.nPos = 0; si.nPage = 100; SetScrollInfo(hScroll, SB_CTL, &si, TRUE); ret = IsWindowEnabled(hScroll); ok(ret, "scroll bar disabled\n"); DestroyWindow(hScroll); DestroyWindow(mainwnd); }
void CDeviceView::CalcDimensions() { // go through all texts and controls to find the max y coord int max = g_sizeImage.cy - g_iListHeaderHeight; int i = 0; for (; i < GetNumTexts(); i++) { CDeviceViewText *pText = GetText(i); if (!pText) continue; int ty = pText->GetMaxY(); if (ty > max) max = ty; } for (i = 0; i < GetNumControls(); i++) { CDeviceControl *pControl = GetControl(i); if (!pControl) continue; int cy = pControl->GetMaxY(); if (cy > max) max = cy; } // set m_nViewHeight = max; m_nScrollOffset = 0; // enable scrollbar if view height more than window size if (m_nViewHeight > g_sizeImage.cy - g_iListHeaderHeight) EnableScrollBar(); }
BOOL WINAPI CoolSB_EnableScrollBar(HWND hwnd, int wSBflags, UINT wArrows) { SCROLLBAR *sbar; UINT oldstate; BOOL bFailed = FALSE; if (!CoolSB_IsCoolScrollEnabled(hwnd)) return EnableScrollBar(hwnd, wSBflags, wArrows); if ((wSBflags == SB_HORZ || wSBflags == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_HORZ))) { oldstate = sbar->fScrollFlags; //clear any existing state, and OR in the disabled flags sbar->fScrollFlags = (sbar->fScrollFlags & ~ESB_DISABLE_BOTH) | wArrows; if (oldstate == sbar->fScrollFlags) bFailed = TRUE; } if ((wSBflags == SB_VERT || wSBflags == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_VERT))) { oldstate = sbar->fScrollFlags; //clear any existing state, and OR in the disabled flags sbar->fScrollFlags = (sbar->fScrollFlags & ~ESB_DISABLE_BOTH) | wArrows; if (oldstate == sbar->fScrollFlags) bFailed = TRUE; } return !bFailed; }
int main(int argc, char *argv[]) { #ifndef _WIN32 signal(SIGINT, SignalHandleFunction); signal(SIGTERM, SignalHandleFunction); #ifdef SIGBREAK signal(SIGBREAK, SignalHandleFunction); #endif #else SetConsoleCtrlHandler(ConsoleHandlerRoutine, 1); EnableScrollBar(GetConsoleWindow(), SB_BOTH, ESB_DISABLE_BOTH); HANDLE l_handle = GetStdHandle(STD_INPUT_HANDLE); DWORD l_handleMode; GetConsoleMode(l_handle, &l_handleMode); SetConsoleMode(l_handle, l_handleMode & ~ENABLE_QUICK_EDIT_MODE); l_handle = GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_SCREEN_BUFFER_INFO l_sbInfo; GetConsoleScreenBufferInfo(l_handle, &l_sbInfo); l_sbInfo.dwSize.Y = l_sbInfo.srWindow.Bottom + 1; SetConsoleWindowInfo(l_handle, TRUE, &l_sbInfo.srWindow); SetConsoleScreenBufferSize(l_handle, l_sbInfo.dwSize); SetConsoleTitleA("RunOnCoal Server"); #endif ROC::Core *l_core = ROC::Core::Init(); while(!g_quitSetter) l_core->DoPulse(); ROC::Core::Terminate(); return EXIT_SUCCESS; }
void CDropWnd::SetRegex(TSTLSTRING strRegex) { m_strRegex = TEXT("[\\w\\W]*"); m_strRegex.append(strRegex); m_strRegex.append(TEXT("[\\w\\W]*")); Filter(); SetScrollPos(SB_VERT, 0, FALSE); if(m_FilterItemCollection.size() <= 10) EnableScrollBar(SB_VERT, ESB_DISABLE_BOTH); else { EnableScrollBar(SB_VERT, ESB_ENABLE_BOTH); SetScrollRange(SB_VERT, 0, m_FilterItemCollection.size() - 10); } Invalidate(); }
static int winCanvasSetDXAttrib(Ihandle* ih, const char *value) { if (ih->data->sb & IUP_SB_HORIZ) { double posx, xmin, xmax; float dx; int iposx, ipagex; if (!iupStrToFloat(value, &dx)) return 1; xmin = iupAttribGetFloat(ih, "XMIN"); xmax = iupAttribGetFloat(ih, "XMAX"); posx = ih->data->posx; iupCanvasCalcScrollIntPos(xmin, xmax, dx, posx, IUP_SB_MIN, IUP_SB_MAX, &ipagex, &iposx); if (dx >= (xmax-xmin)) { if (iupAttribGetBoolean(ih, "XAUTOHIDE")) ShowScrollBar(ih->handle, SB_HORZ, FALSE); else EnableScrollBar(ih->handle, SB_HORZ, ESB_DISABLE_BOTH); ih->data->posx = (float)xmin; SetScrollPos(ih->handle, SB_HORZ, IUP_SB_MIN, TRUE); return 1; } else { ShowScrollBar(ih->handle, SB_HORZ, TRUE); EnableScrollBar(ih->handle, SB_HORZ, ESB_ENABLE_BOTH); } winCanvasSetScrollInfo(ih->handle, IUP_SB_MIN, IUP_SB_MAX, iposx, ipagex, SB_HORZ); /* update position because it could be corrected */ iupCanvasCalcScrollRealPos(xmin, xmax, &posx, IUP_SB_MIN, IUP_SB_MAX, ipagex, &iposx); ih->data->posx = (float)posx; } return 1; }
void CContainerUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) { if( _tcscmp(pstrName, _T("inset")) == 0 ) SetInset(CSize(_ttoi(pstrValue), _ttoi(pstrValue))); else if( _tcscmp(pstrName, _T("padding")) == 0 ) SetPadding(_ttoi(pstrValue)); else if( _tcscmp(pstrName, _T("width")) == 0 ) SetWidth(_ttoi(pstrValue)); else if( _tcscmp(pstrName, _T("height")) == 0 ) SetHeight(_ttoi(pstrValue)); else if( _tcscmp(pstrName, _T("scrollbar")) == 0 ) EnableScrollBar(_tcscmp(pstrValue, _T("true")) == 0); else CControlUI::SetAttribute(pstrName, pstrValue); }
void CListSide::Create(HWND hParent, RECT rect, HFONT hFont, int nVBarPos, int nLineHeight, bool bEnableLineSel, bool bIsLyrics) { m_bIsLyrics = bIsLyrics; m_bEnableLineSel = bEnableLineSel; rect.bottom--; rect.right--; WNDCLASSA wndclass; if (FALSE == GetClassInfoA(genDll.m_hInstance, TABLECLASS, &wndclass)) { ZeroMemory(&wndclass, sizeof(WNDCLASS)); wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); wndclass.hInstance = genDll.m_hInstance; wndclass.lpfnWndProc = WindowProc; wndclass.lpszClassName = TABLECLASS; wndclass.style = CS_VREDRAW | CS_HREDRAW | CS_CLASSDC; if (FALSE == RegisterClassA(&wndclass)) { DWORD dwError = GetLastError(); char str[20]; sprintf(str, "Error 0x%x", dwError); MessageBoxA(genDll.m_hWinamp, str, "Fatal Error!", MB_ICONERROR); #ifdef _DEBUG DebugBreak(); #endif PostQuitMessage(-1); } } m_hWnd = CreateWindowA(TABLECLASS, 0, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_VSCROLL, rect.left, rect.top, rect.right - rect.left + 1, rect.bottom - rect.top + 1, hParent, NULL, genDll.m_hInstance, NULL); if (m_hWnd == 0) { DWORD dwError = GetLastError(); char str[20]; sprintf(str, "Error 0x%x", dwError); MessageBoxA(genDll.m_hWinamp, str, "Fatal Error!", MB_ICONERROR); #ifdef _DEBUG DebugBreak(); #endif PostQuitMessage(-1); } GetClientRect(m_hWnd, &m_rClient); m_nVBarPos = nVBarPos; SetWindowLongPtrW(m_hWnd, GWL_USERDATA, (LONG_PTR)this); EnableScrollBar(m_hWnd, SB_VERT, ESB_DISABLE_BOTH); m_hFont = hFont; m_nLineHeight = nLineHeight; AddLine(); }
static int winCanvasSetDYAttrib(Ihandle *ih, const char *value) { if (ih->data->sb & IUP_SB_VERT) { double posy, ymin, ymax; float dy; int iposy, ipagey; if (!iupStrToFloat(value, &dy)) return 1; ymin = iupAttribGetFloat(ih, "YMIN"); ymax = iupAttribGetFloat(ih, "YMAX"); posy = ih->data->posy; iupCanvasCalcScrollIntPos(ymin, ymax, dy, posy, IUP_SB_MIN, IUP_SB_MAX, &ipagey, &iposy); if (dy >= (ymax-ymin)) { if (iupAttribGetBoolean(ih, "YAUTOHIDE")) ShowScrollBar(ih->handle, SB_VERT, FALSE); else EnableScrollBar(ih->handle, SB_VERT, ESB_DISABLE_BOTH); return 1; } else { ShowScrollBar(ih->handle, SB_VERT, TRUE); EnableScrollBar(ih->handle, SB_VERT, ESB_ENABLE_BOTH); } winCanvasSetScrollInfo(ih->handle, IUP_SB_MIN, IUP_SB_MAX, iposy, ipagey, SB_VERT); /* update position because it could be corrected */ iupCanvasCalcScrollRealPos(ymin, ymax, &posy, IUP_SB_MIN, IUP_SB_MAX, ipagey, &iposy); ih->data->posy = (float)posy; } return 1; }
void CDropWnd::Show() { Filter(); SetScrollPos(SB_VERT, 0, FALSE); if(m_FilterItemCollection.size() <= 10) EnableScrollBar(SB_VERT, ESB_DISABLE_BOTH); else { EnableScrollBar(SB_VERT, ESB_ENABLE_BOTH); SetScrollRange(SB_VERT, 0, m_FilterItemCollection.size() - 10); } CDropWnd::m_Hook = ::SetWindowsHookEx(WH_MOUSE, (HOOKPROC)HookMouseProc, NULL, GetCurrentThreadId()); CDropWnd::m_pDropWnd = this; TRACE("CDropWnd::Show\n"); CRect rt; m_pComboBoxWnd->GetWindowRect(&rt); SetWindowPos(&wndTopMost, rt.left, rt.top + rt.Height(), 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW|SWP_NOACTIVATE); }
static void scrollbar_test1(void) { BOOL ret; ret = EnableScrollBar( hScroll, SB_CTL, ESB_DISABLE_BOTH ); ok( ret, "The scrollbar should be disabled.\n" ); ok( !IsWindowEnabled( hScroll ), "The scrollbar window should be disabled.\n" ); ret = EnableScrollBar( hScroll, SB_CTL, ESB_ENABLE_BOTH ); ok( ret, "The scrollbar should be enabled.\n" ); ok( IsWindowEnabled( hScroll ), "The scrollbar window should be enabled.\n" ); /* test buttons separately */ ret = EnableScrollBar( hScroll, SB_CTL, ESB_DISABLE_LTUP ); ok( ret, "The scrollbar LTUP button should be disabled.\n" ); ok( IsWindowEnabled( hScroll ), "The scrollbar window should be enabled.\n" ); ret = EnableScrollBar( hScroll, SB_CTL, ESB_ENABLE_BOTH ); ok( ret, "The scrollbar should be enabled.\n" ); ok( IsWindowEnabled( hScroll ), "The scrollbar window should be enabled.\n" ); ret = EnableScrollBar( hScroll, SB_CTL, ESB_DISABLE_RTDN ); ok( ret, "The scrollbar RTDN button should be disabled.\n" ); ok( IsWindowEnabled( hScroll ), "The scrollbar window should be enabled.\n" ); ret = EnableScrollBar( hScroll, SB_CTL, ESB_ENABLE_BOTH ); ok( ret, "The scrollbar should be enabled.\n" ); ok( IsWindowEnabled( hScroll ), "The scrollbar window should be enabled.\n" ); }
HWND CreateRichEdit(HWND hWndOwner, int x, int y, int width, int height) { HINSTANCE hndl = LoadLibrary("riched32.dll"); HWND hWndEdit = CreateWindowEx(WS_EX_LEFT , RICHEDIT_CLASS, "",WS_VSCROLL | WS_VISIBLE | WS_CHILD | ES_READONLY | ES_LEFT| ES_AUTOVSCROLL | ES_MULTILINE, x, y, width, height, hWndOwner, (HMENU)1, GetModuleHandle(NULL), NULL); SendMessage (hWndEdit, EM_SETBKGNDCOLOR, NULL, RGB(0,0,0)); EnableScrollBar(hWndEdit,SB_VERT,true); ShowScrollBar(hWndEdit,SB_VERT,true); return hWndEdit; }
int TranscriptWindow::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate(lpCreateStruct) == -1) return -1; // Turn the vertical scrollbar off EnableScrollBar(SB_VERT,ESB_DISABLE_BOTH); // Control for editing text if (m_edit.Create(ES_MULTILINE|ES_WANTRETURN|WS_CHILD,this,0) == FALSE) return -1; m_edit.SetMargins(theApp.MeasureFont(m_edit.GetFont()).cx/4); return 0; }
void KCanvasWindow::SetScaleColor(int newscale, COLORREF backcolor) { RECT rect; if ((newscale==scale) && (canvas_backcolor==backcolor)) return; if (backcolor) // no black canvas_backcolor = backcolor; // newscale==0 will force repaint if (newscale) scale = newscale; GetClientRect(m_hWnd, &rect); if ((maxx/scale+page_margin*2) < rect.right) ShowScrollBar(m_hWnd, SB_HORZ, FALSE); // no scroll bar needed else { ShowScrollBar(m_hWnd, SB_HORZ, TRUE); EnableScrollBar(m_hWnd, SB_HORZ, ESB_ENABLE_BOTH); SetScrollRange(m_hWnd, SB_HORZ, 0, (maxx/scale+page_margin*2) - rect.right, FALSE); } // always reset scrool bar position, // we need that inf WS_PAINT processing, even if we don't have show scroll bar SetScrollPos(m_hWnd, SB_HORZ, 0, FALSE); if ((maxy/scale+page_margin*2) < rect.bottom) ShowScrollBar(m_hWnd, SB_VERT, FALSE); else { ShowScrollBar(m_hWnd, SB_VERT, TRUE); SetScrollRange(m_hWnd, SB_VERT, 0, (maxy/scale+page_margin*2) - rect.bottom, FALSE); } // always reset scrool bar position, // we need that inf WS_PAINT processing, even if we don't have show scroll bar SetScrollPos(m_hWnd, SB_VERT, 0, FALSE); InvalidateRect(m_hWnd, NULL, TRUE); }
static void test_EnableScrollBar(void) { HWND mainwnd; BOOL ret; mainwnd = create_main_test_wnd(); ret = EnableScrollBar( hScroll, SB_CTL, ESB_DISABLE_BOTH ); ok( ret, "The scrollbar should be disabled.\n" ); ok( !IsWindowEnabled( hScroll ), "The scrollbar window should be disabled.\n" ); ret = EnableScrollBar( hScroll, SB_CTL, ESB_ENABLE_BOTH ); ok( ret, "The scrollbar should be enabled.\n" ); ok( IsWindowEnabled( hScroll ), "The scrollbar window should be enabled.\n" ); /* test buttons separately */ ret = EnableScrollBar( hScroll, SB_CTL, ESB_DISABLE_LTUP ); ok( ret, "The scrollbar LTUP button should be disabled.\n" ); ok( IsWindowEnabled( hScroll ), "The scrollbar window should be enabled.\n" ); ret = EnableScrollBar( hScroll, SB_CTL, ESB_ENABLE_BOTH ); ok( ret, "The scrollbar should be enabled.\n" ); ok( IsWindowEnabled( hScroll ), "The scrollbar window should be enabled.\n" ); ret = EnableScrollBar( hScroll, SB_CTL, ESB_DISABLE_RTDN ); ok( ret, "The scrollbar RTDN button should be disabled.\n" ); ok( IsWindowEnabled( hScroll ), "The scrollbar window should be enabled.\n" ); ret = EnableScrollBar( hScroll, SB_CTL, ESB_ENABLE_BOTH ); ok( ret, "The scrollbar should be enabled.\n" ); ok( IsWindowEnabled( hScroll ), "The scrollbar window should be enabled.\n" ); /* disable window, try to reenable */ ret = EnableWindow( hScroll, FALSE ); ok( !ret, "got %d\n", ret ); ok( !IsWindowEnabled( hScroll ), "The scrollbar window should be disabled.\n" ); ret = EnableScrollBar( hScroll, SB_CTL, ESB_ENABLE_BOTH ); ok( ret, "got %d\n", ret ); ok( IsWindowEnabled( hScroll ), "The scrollbar window should be disabled.\n" ); DestroyWindow(hScroll); DestroyWindow(mainwnd); }
void TranscriptWindow::Layout(void) { CRect clientRect; GetClientRect(clientRect); m_layout.clientSize = clientRect.Size(); m_layout.columnWidth = clientRect.Width()/2; m_layout.font = theApp.GetFont(InformApp::FontDisplay); m_layout.fontSize = theApp.MeasureFont(m_layout.font); m_layout.margin = CSize(m_layout.fontSize.cx,m_layout.fontSize.cy/3); m_layout.centreMargin = m_layout.margin.cx*4; CDC* dc = GetDC(); m_layout.nodes.clear(); Skein::Node* node = m_skeinEndThread; while (node != NULL) { NodeLayout nl; nl.node = node; // Get the text associated with the node const CStringW& transcript = nl.node->GetTranscriptText(); const CStringW& expected = nl.node->GetExpectedText(); // Measure the height of the expected text CRect textRect; textRect.SetRectEmpty(); textRect.right = m_layout.columnWidth-m_layout.margin.cx-m_layout.centreMargin; SizeText(*dc,textRect,expected); nl.height = textRect.Height(); // Measure the height of the transcript text textRect.SetRectEmpty(); textRect.right = m_layout.columnWidth-m_layout.margin.cx-m_layout.centreMargin; SizeText(*dc,textRect,transcript); if (textRect.Height() > nl.height) nl.height = textRect.Height(); // Use the tallest for the height of the node in the transcript if (m_layout.fontSize.cy > nl.height) nl.height = m_layout.fontSize.cy; m_layout.nodes.push_front(nl); node = node->GetParent(); } ReleaseDC(dc); // Compare the height of the transcript with the height of the window int height = GetHeight(); if (height > clientRect.Height()) { // The transcript is taller than the window, so turn the scrollbar on EnableScrollBar(SB_VERT,ESB_ENABLE_BOTH); // Get the current scrollbar settings SCROLLINFO scroll; ::ZeroMemory(&scroll,sizeof scroll); scroll.cbSize = sizeof scroll; GetScrollInfo(SB_VERT,&scroll); // Change the maximum position and the size of the scrollbar scroll.nMin = 0; scroll.nMax = height-1; scroll.nPage = clientRect.Height(); SetScrollInfo(SB_VERT,&scroll); } else { // The transcript is shorter than the window, so turn the scrollbar off EnableScrollBar(SB_VERT,ESB_DISABLE_BOTH); SCROLLINFO scroll; ::ZeroMemory(&scroll,sizeof scroll); scroll.cbSize = sizeof scroll; SetScrollInfo(SB_VERT,&scroll); } }
void HandleMenu(int menuID) { if(menuID == ID_FILE_QUIT) // If the user chose File->Quit { PostQuitMessage(0); // Quit the program } //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// else if(menuID == ID_FILE_OPENUP) // If the user chose File->Open { // Have windows bring up the Open File dialog box and Load the file chosen if(GetOpenFileName(&g_OpenInfo)) g_Map.Load(g_OpenInfo.lpstrFile); } else if(menuID == ID_FILE_SAVEIT) // If the user chose File->Save { // If we have a n valid name for our map already, do a normal save if(strlen(g_Map.GetMapName()) > 3) g_Map.Save(g_Map.GetMapName()); else { // If haven't given our map a name yet, do a "SaveAs" and bring up the save dlg box if(GetSaveFileName(&g_OpenInfo)) g_Map.Save(g_OpenInfo.lpstrFile); } } else if(menuID == ID_FILE_SAVEAS) // If the user chose File->SaveAs { // Bring up the save dlg box and allow the user to type in a new map name and save it if(GetSaveFileName(&g_OpenInfo)) g_Map.Save(g_OpenInfo.lpstrFile); } //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// else if(menuID == ID_FILE_RESET) // If the user chose File->Reset g_Map.SetDefault(); // Destroy all the tiles on the map and start over else if(menuID == ID_TILES_TILES) // If the user chose Tiles->Tiles g_Map.SetCurrentType(TILE_TYPE); // Set the tool bar tile type to tiles else if(menuID == ID_TILES_ITEMS) // If the user chose Tiles->Items g_Map.SetCurrentType(ITEM_TYPE); // Set the tool bar tile type to items else if(menuID == ID_TILES_MONSTERS) // If the user chose Tiles->Monsters g_Map.SetCurrentType(MONSTER_TYPE); // Set the tool bar tile type to monsters else if(menuID == ID_TILES_CITIZENS) // If the user chose Tiles->Citizens g_Map.SetCurrentType(NPC_TYPE); // Set the tool bar tile type to citizens else if(menuID == ID_TILES_EXITS) // If the user chose Tiles->Exits g_Map.SetCurrentType(EXIT_TYPE); // Set the tool bar tile type to exits (no tiles of course) else if(menuID == ID_HELP_ABOUT) // If the user chose Help->About // Instead of creating a help dialog box, we can just use a simple system MessageBox() call MessageBox(g_hWnd, "www.GameTutorials.com Map Editor\n\n" "\t- Choose the desired tile type from the Tiles menu,\n" "\t then click on a tile in the tile window. You can\n" "\t then draw the tiles on the map with the left mouse button.\n\n" "\t- Right click to remove the current cursor tile.\n\n" "\t- To delete a item:monster:citizen:exit, make sure you choose\n" "\t that type from the menu, then right click on the tile.\n\n" "\t- When setting an exit you can hold down shift to place more exits.\n" "\t Once you place an exit without holding the shift key you will be\n" "\t prompted to choose the destination map. Then place one tile for\n" "\t the position where the character will end up.\n\n" "\t- Hit Esc to quit the program.", "About", MB_OK | MB_ICONINFORMATION); // Over assuming that a tile type was changed, reset the scroll bar size. // The -1 is because the tool bar window's title size offsets it a bit (being smaller). g_ScrollInfo.nMax = g_Map.GetCurrentTypeSize() - MAP_HEIGHT - 1; // If there isn't enough (or any) tiles to fill up the tool bar window, disable the scroll bar if(g_ScrollInfo.nMax < 0) { g_ScrollInfo.nMax = 0; EnableScrollBar(g_hWndTool, SB_VERT, ESB_DISABLE_BOTH); } else EnableScrollBar(g_hWndTool, SB_VERT, ESB_ENABLE_BOTH); // Enable the scroll bar if it's needed // Reset the scroll bar info g_scrollBarPosY = 0; g_ScrollInfo.nPage = 0; // Update the current scroll bar information with no need to redraw (FALSE) SetScrollInfo(g_hWndTool, SB_VERT, &g_ScrollInfo, FALSE); ShowScrollBar(g_hWndTool, SB_VERT, TRUE); // If we chose a tile type, put a check box next to it switch(menuID) { case ID_TILES_TILES: case ID_TILES_ITEMS: case ID_TILES_MONSTERS: case ID_TILES_CITIZENS: case ID_TILES_EXITS: g_pCursorTile = NULL; CheckTileType(menuID); break; } }
/* some tests designed to show that Horizontal and Vertical * window scroll bar info are not created independently */ static void scrollbar_test_default( DWORD style) { INT min, max, ret; DWORD winstyle; HWND hwnd; SCROLLINFO si = { sizeof( SCROLLINFO), SIF_TRACKPOS }; hwnd = CreateWindowExA( 0, "static", "", WS_POPUP | style, 0, 0, 10, 10, 0, 0, 0, NULL); assert( hwnd != 0); ret = GetScrollRange( hwnd, SB_VERT, &min, &max); ok( ret || broken( !ret) /* Win 9x/ME */ , "GetScrollRange failed.\n"); /* range is 0,0 if there are no H or V scroll bars. 0,100 otherwise */ if( !( style & ( WS_VSCROLL | WS_HSCROLL))) ok( min == 0 && max == 0, "Scroll bar range is %d,%d. Expected 0,0. Style %08x\n", min, max, style); else todo_wine ok(( min == 0 && max == 100) || broken( min == 0 && max == 0), /* Win 9x/ME */ "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style); ret = GetScrollRange( hwnd, SB_HORZ, &min, &max); ok( ret || broken( !ret) /* Win 9x/ME */ , "GetScrollRange failed.\n"); /* range is 0,0 if there are no H or V scroll bars. 0,100 otherwise */ if( !( style & ( WS_VSCROLL | WS_HSCROLL))) ok( min == 0 && max == 0, "Scroll bar range is %d,%d. Expected 0,0. Style %08x\n", min, max, style); else todo_wine ok(( min == 0 && max == 100) || broken( min == 0 && max == 0), /* Win 9x/ME */ "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style); /* test GetScrollInfo, vist for vertical SB */ ret = GetScrollInfo( hwnd, SB_VERT, &si); /* should fail if no H or V scroll bar styles are present. Succeed otherwise */ if( !( style & ( WS_VSCROLL | WS_HSCROLL))) ok( !ret, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style); else todo_wine ok( ret || broken( !ret), /* Win 9x/ME */ "GetScrollInfo failed unexpectedly. Style is %08x\n", style); /* Same for Horizontal SB */ ret = GetScrollInfo( hwnd, SB_HORZ, &si); /* should fail if no H or V scroll bar styles are present. Succeed otherwise */ if( !( style & ( WS_VSCROLL | WS_HSCROLL))) ok( !ret, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style); else todo_wine ok( ret || broken( !ret), /* Win 9x/ME */ "GetScrollInfo failed unexpectedly. Style is %08x\n", style); /* now set the Vertical Scroll range to something that could be the default value it * already has */; ret = SetScrollRange( hwnd, SB_VERT, 0, 100, FALSE); ok( ret, "SetScrollRange failed.\n"); /* and request the Horizontal range */ ret = GetScrollRange( hwnd, SB_HORZ, &min, &max); ok( ret, "GetScrollRange failed.\n"); /* now the range should be 0,100 in ALL cases */ ok( min == 0 && max == 100, "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style); /* See what is different now for GetScrollRange */ ret = GetScrollInfo( hwnd, SB_HORZ, &si); /* should succeed in ALL cases */ ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style); ret = GetScrollInfo( hwnd, SB_VERT, &si); /* should succeed in ALL cases */ ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style); /* report the windows style */ winstyle = GetWindowLongA( hwnd, GWL_STYLE ); /* WS_VSCROLL added to the window style */ if( !(style & WS_VSCROLL)) { if (bThemeActive || style != WS_HSCROLL) todo_wine ok( (winstyle & (WS_HSCROLL|WS_VSCROLL)) == ( style | WS_VSCROLL), "unexpected style change %8lx expected %8lx\n", (winstyle & (WS_HSCROLL|WS_VSCROLL)), style | WS_VSCROLL); else ok( (winstyle & (WS_HSCROLL|WS_VSCROLL)) == style || broken((winstyle & (WS_HSCROLL|WS_VSCROLL)) == (WS_HSCROLL|WS_VSCROLL)), /* Win 9x/ME */ "unexpected style change %8lx expected %8x\n", (winstyle & (WS_HSCROLL|WS_VSCROLL)), style); } /* do the test again with H and V reversed. * Start with a clean window */ DestroyWindow( hwnd); hwnd = CreateWindowExA( 0, "static", "", WS_POPUP | style, 0, 0, 10, 10, 0, 0, 0, NULL); assert( hwnd != 0); /* Set Horizontal Scroll range to something that could be the default value it * already has */; ret = SetScrollRange( hwnd, SB_HORZ, 0, 100, FALSE); ok( ret, "SetScrollRange failed.\n"); /* and request the Vertical range */ ret = GetScrollRange( hwnd, SB_VERT, &min, &max); ok( ret, "GetScrollRange failed.\n"); /* now the range should be 0,100 in ALL cases */ ok( min == 0 && max == 100, "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style); /* See what is different now for GetScrollRange */ ret = GetScrollInfo( hwnd, SB_HORZ, &si); /* should succeed in ALL cases */ ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style); ret = GetScrollInfo( hwnd, SB_VERT, &si); /* should succeed in ALL cases */ ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style); /* report the windows style */ winstyle = GetWindowLongA( hwnd, GWL_STYLE ); /* WS_HSCROLL added to the window style */ if( !(style & WS_HSCROLL)) { if (bThemeActive || style != WS_VSCROLL) todo_wine ok( (winstyle & (WS_HSCROLL|WS_VSCROLL)) == ( style | WS_HSCROLL), "unexpected style change %8lx expected %8lx\n", (winstyle & (WS_HSCROLL|WS_VSCROLL)), style | WS_HSCROLL); else ok( (winstyle & (WS_HSCROLL|WS_VSCROLL)) == style || broken((winstyle & (WS_HSCROLL|WS_VSCROLL)) == (WS_HSCROLL|WS_VSCROLL)), /* Win 9x/ME */ "unexpected style change %8lx expected %8x\n", (winstyle & (WS_HSCROLL|WS_VSCROLL)), style); } /* Slightly change the test to use SetScrollInfo * Start with a clean window */ DestroyWindow( hwnd); hwnd = CreateWindowExA( 0, "static", "", WS_POPUP | style, 0, 0, 10, 10, 0, 0, 0, NULL); assert( hwnd != 0); /* set Horizontal position with SetScrollInfo */ si.nPos = 0; si.nMin = 11; si.nMax = 22; si.fMask |= SIF_RANGE; ret = SetScrollInfo( hwnd, SB_HORZ, &si, FALSE); ok( ret, "SetScrollInfo failed. Style is %08x\n", style); /* and request the Vertical range */ ret = GetScrollRange( hwnd, SB_VERT, &min, &max); ok( ret, "GetScrollRange failed.\n"); /* now the range should be 0,100 in ALL cases */ ok( min == 0 && max == 100, "Scroll bar range is %d,%d. Expected 0,100. Style %08x\n", min, max, style); /* See what is different now for GetScrollRange */ ret = GetScrollInfo( hwnd, SB_HORZ, &si); /* should succeed in ALL cases */ ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style); ret = GetScrollInfo( hwnd, SB_VERT, &si); /* should succeed in ALL cases */ ok( ret, "GetScrollInfo failed unexpectedly. Style is %08x\n", style); /* also test if the window scroll bars are enabled */ ret = EnableScrollBar( hwnd, SB_VERT, ESB_ENABLE_BOTH); ok( !ret, "Vertical window scroll bar was not enabled\n"); ret = EnableScrollBar( hwnd, SB_HORZ, ESB_ENABLE_BOTH); ok( !ret, "Horizontal window scroll bar was not enabled\n"); DestroyWindow( hwnd); /* finally, check if adding a WS_[HV]SColl style of a window makes the scroll info * available */ if( style & (WS_HSCROLL | WS_VSCROLL)) return;/* only test if not yet set */ /* Start with a clean window */ DestroyWindow( hwnd); hwnd = CreateWindowExA( 0, "static", "", WS_POPUP , 0, 0, 10, 10, 0, 0, 0, NULL); assert( hwnd != 0); ret = GetScrollInfo( hwnd, SB_VERT, &si); /* should fail */ ok( !ret, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style); /* add scroll styles */ winstyle = GetWindowLongA( hwnd, GWL_STYLE ); SetWindowLongW( hwnd, GWL_STYLE, winstyle | WS_VSCROLL | WS_HSCROLL); ret = GetScrollInfo( hwnd, SB_VERT, &si); /* should still fail */ ok( !ret, "GetScrollInfo succeeded unexpectedly. Style is %08x\n", style); /* clean up */ DestroyWindow( hwnd); }
/*********************************************************************** * ScrollBarWndProc */ LRESULT WINAPI ScrollBarWndProc(WNDPROC DefWindowProc, HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam) { #ifdef __ODYSSEY__ // Do this now, remove after Server side is fixed. PWND pWnd; pWnd = ValidateHwnd(Wnd); if (pWnd) { if (!pWnd->fnid) { NtUserSetWindowFNID(Wnd, FNID_SCROLLBAR); } } #endif if (! IsWindow(Wnd)) { return 0; } switch (Msg) { case WM_CREATE: IntScrollCreateScrollBar(Wnd, (LPCREATESTRUCTW) lParam); break; #ifdef __ODYSSEY__ case WM_DESTROY: NtUserSetWindowFNID(Wnd, FNID_DESTROY); return DefWindowProc(Wnd, Msg, wParam, lParam ); #endif //#if 0 /* FIXME */ case WM_ENABLE: { // SCROLLBAR_INFO *infoPtr; // if ((infoPtr = SCROLL_GetScrollBarInfo( hwnd, SB_CTL ))) // { // infoPtr->flags = wParam ? ESB_ENABLE_BOTH : ESB_DISABLE_BOTH; // SCROLL_RefreshScrollBar(hwnd, SB_CTL, TRUE, TRUE); // } HDC hdc; DbgPrint("ScrollBarWndProc WM_ENABLE\n"); NtUserEnableScrollBar(Wnd,SB_CTL,(wParam ? ESB_ENABLE_BOTH : ESB_DISABLE_BOTH)); /* Refresh Scrollbars. */ hdc = GetDCEx( Wnd, 0, DCX_CACHE ); if (!hdc) return 1; IntDrawScrollBar( Wnd, hdc, SB_CTL); ReleaseDC( Wnd, hdc ); } return 0; //#endif case WM_LBUTTONDBLCLK: case WM_LBUTTONDOWN: { POINT Pt; Pt.x = (short)LOWORD(lParam); Pt.y = (short)HIWORD(lParam); ScrollTrackScrollBar(Wnd, SB_CTL, Pt); } break; case WM_LBUTTONUP: case WM_MOUSEMOVE: case WM_SYSTIMER: { POINT Pt; Pt.x = (short)LOWORD(lParam); Pt.y = (short)HIWORD(lParam); IntScrollHandleScrollEvent(Wnd, SB_CTL, Msg, Pt); } break; case WM_KEYDOWN: IntScrollHandleKbdEvent(Wnd, wParam, lParam); break; case WM_KEYUP: ShowCaret(Wnd); break; case WM_SETFOCUS: { /* Create a caret when a ScrollBar get focus */ RECT Rect; int ArrowSize, ThumbSize, ThumbPos, Vertical; Vertical = IntScrollGetScrollBarRect(Wnd, SB_CTL, &Rect, &ArrowSize, &ThumbSize, &ThumbPos); if (! Vertical) { CreateCaret(Wnd, (HBITMAP) 1, ThumbSize - 2, Rect.bottom - Rect.top - 2); SetCaretPos(ThumbPos + 1, Rect.top + 1); } else { CreateCaret(Wnd, (HBITMAP) 1, Rect.right - Rect.left - 2, ThumbSize - 2); SetCaretPos(Rect.top + 1, ThumbPos + 1); } ShowCaret(Wnd); } break; case WM_KILLFOCUS: { RECT Rect; int ArrowSize, ThumbSize, ThumbPos, Vertical; Vertical = IntScrollGetScrollBarRect(Wnd, SB_CTL, &Rect, &ArrowSize, &ThumbSize, &ThumbPos); if (! Vertical) { Rect.left = ThumbPos + 1; Rect.right = Rect.left + ThumbSize; } else { Rect.top = ThumbPos + 1; Rect.bottom = Rect.top + ThumbSize; } HideCaret(Wnd); InvalidateRect(Wnd, &Rect, FALSE); DestroyCaret(); } break; case WM_ERASEBKGND: return 1; case WM_GETDLGCODE: return DLGC_WANTARROWS; /* Windows returns this value */ case WM_PAINT: { PAINTSTRUCT Ps; HDC Dc; Dc = (0 != wParam ? (HDC) wParam : BeginPaint(Wnd, &Ps)); if (GetWindowLongPtrW(Wnd, GWL_STYLE) & SBS_SIZEGRIP) { IntScrollDrawSizeGrip(Wnd, Dc); } else if (0 != (GetWindowLongPtrW(Wnd, GWL_STYLE) & SBS_SIZEBOX)) { RECT Rect; GetClientRect(Wnd, &Rect); FillRect(Dc, &Rect, GetSysColorBrush(COLOR_SCROLLBAR)); } else { IntDrawScrollBar(Wnd, Dc, SB_CTL/*, TRUE, TRUE*/); } if (0 == wParam) { EndPaint(Wnd, &Ps); } } break; case SBM_SETPOS: return SetScrollPos(Wnd, SB_CTL, wParam, (BOOL) lParam); case SBM_GETPOS: return IntScrollGetScrollPos(Wnd, SB_CTL); case SBM_SETRANGEREDRAW: case SBM_SETRANGE: { INT OldPos = IntScrollGetScrollPos(Wnd, SB_CTL); SetScrollRange(Wnd, SB_CTL, wParam, lParam, FALSE); if (Msg == SBM_SETRANGEREDRAW) SCROLL_RefreshScrollBar( Wnd, SB_CTL, TRUE, TRUE ); if (OldPos != IntScrollGetScrollPos(Wnd, SB_CTL)) return OldPos; } return 0; case SBM_GETRANGE: return IntScrollGetScrollRange(Wnd, SB_CTL, (LPINT) wParam, (LPINT) lParam); case SBM_ENABLE_ARROWS: return EnableScrollBar(Wnd, SB_CTL, wParam); case SBM_SETSCROLLINFO: return NtUserSetScrollInfo(Wnd, SB_CTL, (SCROLLINFO *) lParam, wParam); case SBM_GETSCROLLINFO: return NtUserSBGetParms(Wnd, SB_CTL, NULL, (SCROLLINFO *) lParam); case SBM_GETSCROLLBARINFO: ((PSCROLLBARINFO)lParam)->cbSize = sizeof(SCROLLBARINFO); return NtUserGetScrollBarInfo(Wnd, OBJID_CLIENT, (PSCROLLBARINFO)lParam); case 0x00e5: case 0x00e7: case 0x00e8: case 0x00ec: case 0x00ed: case 0x00ee: case 0x00ef: WARN("unknown Win32 msg %04x wp=%08lx lp=%08lx\n", Msg, wParam, lParam ); break; default: if (WM_USER <= Msg) { WARN("unknown msg %04x wp=%04lx lp=%08lx\n", Msg, wParam, lParam); } return DefWindowProc(Wnd, Msg, wParam, lParam ); } return 0; }
DECLSPEC_HIDDEN BOOL WINAPI ITextHostImpl_TxEnableScrollBar(ITextHost *iface, INT fuSBFlags, INT fuArrowflags) { ITextHostImpl *This = impl_from_ITextHost(iface); return EnableScrollBar(This->hWnd, fuSBFlags, fuArrowflags); }
LRESULT CALLBACK FileViewProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HWND hDlg = hWnd; long i=0; short win=0; while( i < NUMFILES ){ if ( hViewWindows[i] == hWnd ){ win = (short)i; break; } i++; } i = 0; //filename = fileview_name[win]; // OutDebugs( "Window %d, filename %s", win, filename ); switch (message) { case WM_PAINT:{ HDC hdc; PAINTSTRUCT ps; RECT rc; GetClientRect(hDlg, &rc); hdc = BeginPaint(hDlg, &ps); FillRect( hdc, &rc, GetSysColorBrush(COLOR_3DFACE) ); EndPaint(hDlg, &ps); UpdateWindow( GetDlgItem(hWnd, IDC_VIEWSCROLL) ); } SetText( IDC_FILEVIEWNAME, fileview_name[win] ); break; case WM_INITDIALOG: lineTooLongMsgLen = mystrlen( lineTooLongMsg ); if ( initWindowIndex >= 0 ){ hViewWindows[ initWindowIndex ] = hWnd; initWindowIndex = -1; } hMenu[win] = LoadMenu( hInst, "FILEVIEW_MENU" ); SetTimer (hWnd, FILEVIEW_TIMER, 300, NULL); // OutDebugs( "Init Dialog: Window %d, filename %s", win, fileview_name[win] ); SetText( IDC_FILEVIEWNAME, fileview_name[win] ); EnableScrollBar( GetDlgItem(hWnd, IDC_VIEWSCROLL), SB_CTL,ESB_ENABLE_BOTH ); OutDebug( fileview_name[win] ); InitWindowStats( &winStats[win] ); SetScale( fileview_name[win], 0, win, hDlg ); SetScrollRange( GetDlgItem(hWnd, IDC_VIEWSCROLL), SB_CTL, 0, winStats[win].scrollScale, 1 ); ShowScrollBar( GetDlgItem(hWnd, IDC_VIEWSCROLL), SB_CTL, 1 ); ListView_SetExtendedListViewStyleEx( GetDlgItem(hWnd, IDC_FILEVIEW), LVS_EX_FULLROWSELECT , LVS_EX_FULLROWSELECT ); { long numlines, pos = winStats[win].scrollScale+1; numlines = GetLinestoFit( hWnd, win ); winStats[win].linesInWin = numlines; i = 0; while( i < numlines-1 ){ i += UpdateFileView( hDlg, win, pos-- ); if ( pos < 0 ) break; } SetScrollPos( GetDlgItem(hDlg, IDC_VIEWSCROLL), SB_CTL, pos, 1 ); } SetFocus( GetDlgItem(hDlg, IDC_FILEVIEW) ); break; case WM_TIMER: if (wParam == FILEVIEW_TIMER ){ char title[350]; /* long x = GetScrollPos( GetDlgItem(hWnd, IDC_VIEWSCROLL), SB_CTL ); long startPos, endPos; startPos = (long)((winStats[win].fileLen/(double)winStats[win].averageLineLen) * (x/(double)winStats[win].scrollScale)); endPos = startPos + winStats[win].linesInWin; sprintf( title, "Viewing - %s (at approx. lines %d - %d)", fileview_name[win], startPos, endPos );*/ sprintf( title, "View - %s", fileview_name[win] ); SetWindowText( hWnd, title ); CheckFileViewStatus( hWnd, win ); } break; case WM_RBUTTONDOWN: // RightClick in windows client area... { POINT pnt; pnt.x = LOWORD(lParam); pnt.y = HIWORD(lParam); ClientToScreen(hWnd, (LPPOINT) &pnt); // This is where you would determine the appropriate 'context' // menu to bring up. Since this app has no real functionality, // we will just bring up the 'Help' menu: //hMenu = GetSubMenu (GetMenu (hWnd), 0); if (hMenu[win]) { TrackPopupMenu (GetSubMenu (hMenu[win], 0), 0, pnt.x, pnt.y, 0, hWnd, NULL); } } break; case WM_CLOSE: if ( hMenu[win] ) DestroyMenu( hMenu[win] ); hViewWindows[win] = 0; EndDialog(hWnd, TRUE); return (TRUE); break; case WM_DESTROY: KillTimer (hWnd, FILEVIEW_TIMER); break; case WM_NOTIFY: switch( wParam ) { case IDC_FILEVIEW: return FileViewNotifyHandler(hWnd, message, wParam, lParam, win ); } break; case WM_VSCROLL: { long x; long nScrollCode = (int) LOWORD(wParam); // scroll bar value long nPos = (short int) HIWORD(wParam); // scroll box position HWND hwndScrollBar = (HWND) lParam; // handle to scroll bar x = GetScrollPos( GetDlgItem(hWnd, IDC_VIEWSCROLL), SB_CTL ); //OutDebugs( "nPos: %d, x: %d, linesInWin: %d, scale: %d", nPos, x, winStats[win].linesInWin, winStats[win].scrollScale ); switch( nScrollCode ){ case SB_LINEDOWN: nPos = x+1; break; case SB_PAGEDOWN: nPos = x+winStats[win].linesInWin/2; break; case SB_LINEUP: nPos = x-1; break; case SB_PAGEUP: nPos = x-winStats[win].linesInWin/2; break; case SB_ENDSCROLL: return 1; } //SetScale( filename, 0, win, hDlg ); if( nPos > winStats[win].scrollScale ) nPos = winStats[win].scrollScale; if( nPos < 0 ) nPos = 0; //OutDebugs( "pos=%d", nPos ); UpdateFileView( hWnd, win,nPos ); //if ( nScrollCode == SB_THUMBTRACK ) SetScrollPos( GetDlgItem(hWnd, IDC_VIEWSCROLL), SB_CTL, nPos, 1 ); return 0; } break; case WM_SIZE: SetWinSize( hWnd, LOWORD(lParam)-40, HIWORD(lParam)-37 ); { long nPos = GetScrollPos( GetDlgItem(hWnd, IDC_VIEWSCROLL), SB_CTL ); UpdateFileView( hWnd, win, nPos ); } break; case WM_SIZING: { RECT *lprc = (LPRECT) lParam; long w,h, x,y; w = lprc->right - lprc->left; h = lprc->bottom - lprc->top; x = lprc->left; y = lprc->top; w = w -48; h = h -64; SetWinSize( hWnd, w, h ); } break; case WM_COPY: EditCopy(hWnd); break; case WM_COMMAND: switch (LOWORD(wParam) ) { case IDM_FM_COPY: EditCopy(hWnd); break; } break; //default: // return (DefWindowProc(hWnd, message, wParam, lParam)); } return FALSE; }
LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { static int nDspLines; static int nNumItems = 0; static int nCurPos = 0; static char szBuf[10]; switch( uMsg ) { case WM_CREATE : ShowScrollBar( hWnd, SB_VERT, TRUE ); break; // Every time the window is sized, re-calculate the number of lines // the client area can display and set the scroll bar accordingly. //................................................................ case WM_SIZE : { RECT rect; GetClientRect( hWnd, &rect ); nDspLines = rect.bottom / 20; if ( nDspLines < nNumItems ) { EnableScrollBar( hWnd, SB_VERT, ESB_ENABLE_BOTH ); SetScrollRange( hWnd, SB_VERT, 0, nNumItems-nDspLines, FALSE ); SetScrollPos( hWnd, SB_VERT, nCurPos, FALSE ); } else EnableScrollBar( hWnd, SB_VERT, ESB_DISABLE_BOTH ); } break; case WM_PAINT : { PAINTSTRUCT ps; int i,j; int nNumPaint; nNumPaint = min( nCurPos+nDspLines, nNumItems ); BeginPaint( hWnd, &ps ); for ( j=0,i=nCurPos; i<nNumPaint; i++,j++ ) { itoa( i, szBuf, 10 ); TextOut( ps.hdc, 10, j*20, "Line of Text:", 13 ); TextOut( ps.hdc, 90, j*20, szBuf, strlen( szBuf ) ); } EndPaint( hWnd, &ps ); } break; case WM_COMMAND : switch( LOWORD( wParam ) ) { case IDM_TEST : if ( nDspLines == nNumItems ) EnableScrollBar( hWnd, SB_VERT, ESB_ENABLE_BOTH ); nNumItems++; if ( nDspLines < nNumItems ) SetScrollRange( hWnd, SB_VERT, 0, nNumItems-nDspLines, TRUE ); InvalidateRect( hWnd, NULL, FALSE ); break; case IDM_ABOUT : DialogBox( hInst, "AboutBox", hWnd, (DLGPROC)About ); break; case IDM_EXIT : DestroyWindow( hWnd ); break; } break; case WM_DESTROY : PostQuitMessage(0); break; default : return( DefWindowProc( hWnd, uMsg, wParam, lParam ) ); } return( 0L ); }
void CSampleDialogScrollHelper::EnableScrollBars(bool bEnable) { EnableScrollBar(SB_HORZ, bEnable); EnableScrollBar(SB_VERT, bEnable); }
/*********************************************************************** * FlatSB_EnableScrollBar (COMCTL32.@) * * See EnableScrollBar. */ BOOL WINAPI FlatSB_EnableScrollBar(HWND hwnd, int nBar, UINT flags) { return EnableScrollBar(hwnd, nBar, flags); }
VOID CRenoBuffer::OnPaint() { CPaintDC dc(this); CRect clipRect; dc.GetClipBox(clipRect); CRect clientRect; GetClientRect(clientRect); // Start doublebuffering HDC hCompatibleDC = CreateCompatibleDC(dc.GetSafeHdc()); HBITMAP hBackbuffer = CreateCompatibleBitmap(dc.GetSafeHdc(),clientRect.Width(),clientRect.Height()); HBITMAP hOldBitmap = (HBITMAP)SelectObject(hCompatibleDC,hBackbuffer); SetBoundsRect(hCompatibleDC,clipRect,NULL); FillRect(hCompatibleDC,clientRect,(HBRUSH)CBrush(BACKGROUND_COLOR).GetSafeHandle()); HGDIOBJ hOldFont = SelectObject(hCompatibleDC,theApp.GetFont()); SetBkMode(hCompatibleDC,TRANSPARENT); CRect boundsRect; GetClientRect(boundsRect); boundsRect.DeflateRect(RENO_BUFFER_MARGIN_HORIZONTAL,RENO_BUFFER_MARGIN_VERTICAL); COLORREF colorDefault = GetTextColor(hCompatibleDC); COLORREF colorSystem = RGB(44,88,222); SIZE size; TEXTMETRIC textmetrics; for(LONG i = m_BufferScrollLine; i < m_Buffer.GetCount(); ++i) { if(!m_Buffer[i].GetLength()) { GetTextExtentPoint32(hCompatibleDC,TEXT(" "),1,&size); boundsRect.bottom -= size.cy; continue; } // Currently only color system messages if(m_Buffer[i].GetAt(0) == TEXT('*')) SetTextColor(hCompatibleDC,colorSystem); else SetTextColor(hCompatibleDC,colorDefault); // Set a fixed stack size ULONG stack[32]; ULONG stackTop = 0; // Put the default font at the bottom of the stack stack[stackTop++] = RENO_FONT_NORMAL; LONG x = boundsRect.left; LONG index = 0; while(index < m_Buffer[i].GetLength()) { LONG control = -1; // Find a control character for(LONG j = index + 1; j < m_Buffer[i].GetLength(); ++j) { if(m_Buffer[i].GetAt(j) == IRC_CONTROL_BOLD || m_Buffer[i].GetAt(j) == IRC_CONTROL_UNDERLINE || m_Buffer[i].GetAt(j) == IRC_CONTROL_ITALIC || m_Buffer[i].GetAt(j) == IRC_CONTROL_NORMAL) { // Found one control = j; break; } } if(control == -1) { // We are going to the end of the line control = m_Buffer[i].GetLength(); } // Colors // "black" : "\x0301", // "dark blue" : "\x0302", // "dark green" : "\x0303", // "green" : "\x0303", // "red" : "\x0304", // "light red" : "\x0304", // "dark red" : "\x0305", // "purple" : "\x0306", // "brown" : "\x0307", // On some clients this is orange, others it is brown // "orange" : "\x0307", // "yellow" : "\x0308", // "light green" : "\x0309", // "aqua" : "\x0310", // "light blue" : "\x0311", // "blue" : "\x0312", // "violet" : "\x0313", // "grey" : "\x0314", // "gray" : "\x0314", // "light grey" : "\x0315", // "light gray" : "\x0315", // "white" : "\x0316", // Other formatting // "normal" : "\x0F", // "bold" : "\x02", // "reverse" : "\x16", // "underline" : "\x1F", switch(m_Buffer[i].GetAt(index)) { case IRC_CONTROL_BOLD: if(stack[stackTop-1] == RENO_FONT_BOLD) --stackTop; // Pop the top else stack[stackTop++] = RENO_FONT_BOLD; // Push ++index; // Skip the control character break; case IRC_CONTROL_ITALIC: if(stack[stackTop-1] ==RENO_FONT_ITALIC) --stackTop; // Pop the top else stack[stackTop++] = RENO_FONT_ITALIC; // Push ++index; // Skip the control character break; case IRC_CONTROL_UNDERLINE: if(stack[stackTop-1] == RENO_FONT_UNDERLINE) --stackTop; // Pop the top else stack[stackTop++] = RENO_FONT_UNDERLINE; // Push ++index; // Skip the control character break; case IRC_CONTROL_NORMAL: if(stack[stackTop-1] == RENO_FONT_NORMAL && stackTop > 1) --stackTop; // Pop the top else stack[stackTop++] = RENO_FONT_NORMAL; // Push ++index; // Skip the control character break; } if(control - index) { SelectObject(hCompatibleDC,theApp.GetFont(stack[stackTop-1])); GetTextExtentPoint32(hCompatibleDC,m_Buffer[i].GetBuffer() + index,control - index,&size); TextOut(hCompatibleDC,x,boundsRect.bottom - size.cy,m_Buffer[i].GetBuffer() + index,control - index); x += size.cx; // Retrieve the overhang value from the TEXTMETRIC structure and subtract it from the x-increment (This is only necessary for non-TrueType raster fonts) GetTextMetrics(hCompatibleDC,&textmetrics); x -= textmetrics.tmOverhang; } index = control; } GetTextExtentPoint32(hCompatibleDC,TEXT(" "),1,&size); // TODO Maybe not necessary, the size struct will already be set from some above call boundsRect.bottom -= size.cy; if(boundsRect.bottom < -size.cy) break; // No point in painting further cause everything would get clipped } // Update the scrollbar if(m_Buffer.GetCount() > 1) { SelectObject(hCompatibleDC,theApp.GetFont()); GetTextMetrics(hCompatibleDC,&textmetrics); SCROLLINFO info; info.cbSize = sizeof(info); info.fMask = SIF_ALL; info.nMin = 0; info.nMax = m_Buffer.GetCount()-1 + clientRect.Height()/textmetrics.tmHeight-1; info.nPos = m_Buffer.GetCount()-1 - m_BufferScrollLine; info.nPage = clientRect.Height()/textmetrics.tmHeight; SetScrollInfo(SB_VERT,&info); EnableScrollBar(SB_VERT,ESB_ENABLE_BOTH); } else { EnableScrollBar(SB_VERT,ESB_DISABLE_BOTH); } SelectObject(hCompatibleDC,hOldFont); // End doublebuffering BitBlt(dc.GetSafeHdc(),0,0,clientRect.Width(),clientRect.Height(),hCompatibleDC,0,0,SRCCOPY); SelectObject(hCompatibleDC,hOldBitmap); DeleteObject(hBackbuffer); DeleteDC(hCompatibleDC); }