extern void HorizontalScroll( WPARAM wparam, LPARAM lparam, HWND wnd ) /********************************************************************/ { int xdel; RECT clrect; POINT offset; RECT scrollrect; wparam = wparam; lparam = lparam; if( !(GetScrollConfig() & SCROLL_HORZ) ) { return; } GetClientRect( GetAppWnd(), &clrect ); scrollrect = GetScrollRect(); xdel = 0; GetOffset( &offset ); switch( LOWORD( wparam ) ) { case SB_BOTTOM: xdel = scrollrect.right - offset.x - clrect.right; break; case SB_LINEDOWN: xdel = LN_SC_AMOUNT; break; case SB_LINEUP: xdel = -LN_SC_AMOUNT; break; case SB_PAGEDOWN: xdel = (long)clrect.right * PG_SC_PERCENT / 100; break; case SB_PAGEUP: xdel = -(long)clrect.right * PG_SC_PERCENT / 100; break; case SB_THUMBPOSITION: //xdel = GET_WM_VSCROLL_POS( wparam, lparam ) - offset.x - clrect.right; xdel = GET_WM_VSCROLL_POS( wparam, lparam ) - offset.x; break; case SB_TOP: xdel = -offset.x; break; default: break; } // make sure we do not expose area's not in the scroll rect if( clrect.right <= scrollrect.right && clrect.left >= scrollrect.left ) { if( xdel ) { if( clrect.right + offset.x + xdel > scrollrect.right ) { xdel = scrollrect.right - clrect.right - offset.x; } } else { if( clrect.left + offset.x + xdel < scrollrect.left ) { xdel = clrect.left + offset.x - scrollrect.left; } } } DoScroll( wnd, xdel, 0, TRUE ); }
extern void VerticalScroll( WPARAM wparam, LPARAM lparam, HWND wnd ) /******************************************************************/ { int ydel; RECT clrect; POINT offset; RECT scrollrect; wparam = wparam; lparam = lparam; if( !(GetScrollConfig() & SCROLL_VERT) ) { return; } GetClientRect( GetAppWnd(), &clrect ); scrollrect = GetScrollRect(); ydel = 0; GetOffset( &offset ); switch( LOWORD( wparam ) ) { case SB_BOTTOM: ydel = scrollrect.bottom - offset.y - clrect.bottom; break; case SB_LINEDOWN: ydel = LN_SC_AMOUNT; break; case SB_LINEUP: ydel = -LN_SC_AMOUNT; break; case SB_PAGEDOWN: ydel = (long)clrect.bottom * PG_SC_PERCENT / 100; break; case SB_PAGEUP: ydel = -((long)clrect.bottom * PG_SC_PERCENT / 100); break; case SB_THUMBPOSITION: //ydel = GET_WM_VSCROLL_POS( wparam, lparam ) - offset.y - clrect.bottom; ydel = GET_WM_VSCROLL_POS( wparam, lparam ) - offset.y; break; case SB_TOP: ydel = -offset.y; break; default: break; } // make sure we do not expose area's not in the scroll rect if( clrect.bottom <= scrollrect.bottom && clrect.top >= scrollrect.top ) { if( ydel ) { if( clrect.bottom + offset.y + ydel > scrollrect.bottom ) { ydel = scrollrect.bottom - clrect.bottom - offset.y; } } else { if( clrect.top + offset.y + ydel < scrollrect.top ) { ydel = clrect.top + offset.y - scrollrect.top; } } } DoScroll( wnd, 0, ydel, TRUE ); }
/*********************************************************************** FUNCTION: WndProc PURPOSE: Processes messages sent to the main window. ***********************************************************************/ LRESULT PrefsDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) { SHINITDLGINFO shidi; SHMENUBARINFO mbi; RECT rcClient; switch( msg ) { case WM_INITDIALOG: shidi.dwMask = SHIDIM_FLAGS; shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN; shidi.hDlg = hwnd; SHInitDialog( &shidi ); //Create the menubar memset( &mbi, 0, sizeof (SHMENUBARINFO) ); mbi.cbSize = sizeof (SHMENUBARINFO); mbi.hwndParent = hwnd; mbi.dwFlags = SHCMBF_EMPTYBAR; mbi.hInstRes = hInst; if( !SHCreateMenuBar(&mbi) ) { MessageBox(hwnd, _T("SHCreateMenuBar Failed"), _T("Error"), MB_OK); //return -1; } hwndCB = mbi.hwndMB; // Get the client area rect to put the panels in GetClientRect(hwnd, &rcClient); /* Create the buttons */ advanced_checkbox = CreateWindow( _T("BUTTON"), _T("Advanced options"), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 5, 10, 15, 15, hwnd, NULL, hInst, NULL ); SendMessage( advanced_checkbox, BM_SETCHECK, BST_UNCHECKED, 0 ); advanced_label = CreateWindow( _T("STATIC"), _T("Advanced options"), WS_CHILD | WS_VISIBLE | SS_LEFT, 5 + 15 + 5, 10, 110, 15, hwnd, NULL, hInst, NULL); if( config_GetInt( p_intf, "advanced" ) ) { SendMessage( advanced_checkbox, BM_SETCHECK, BST_CHECKED, 0 ); /*dummy_event.SetInt(TRUE); OnAdvanced( dummy_event );*/ } reset_button = CreateWindow( _T("BUTTON"), _T("Reset All"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, rcClient.right - 5 - 80, 10 - 3, 80, 15 + 6, hwnd, NULL, hInst, NULL ); /* Create the preferences tree control */ prefs_tree = new PrefsTreeCtrl( p_intf, this, hwnd, hInst ); UpdateWindow( hwnd ); break; case WM_CLOSE: EndDialog( hwnd, LOWORD( wp ) ); break; case WM_SETFOCUS: SHFullScreen( hwnd, SHFS_SHOWSIPBUTTON ); break; case WM_COMMAND: if( LOWORD(wp) == IDOK ) { OnOk(); EndDialog( hwnd, LOWORD( wp ) ); } break; case WM_NOTIFY: if( lp && prefs_tree && ((LPNMHDR)lp)->hwndFrom == prefs_tree->hwndTV && ((LPNMHDR)lp)->code == TVN_SELCHANGED ) { prefs_tree->OnSelectTreeItem( (NM_TREEVIEW FAR *)(LPNMHDR)lp, hwnd, hInst ); } break; case WM_VSCROLL: { TVITEM tvi = {0}; tvi.mask = TVIF_PARAM; tvi.hItem = TreeView_GetSelection( prefs_tree->hwndTV ); if( !tvi.hItem ) break; if( !TreeView_GetItem( prefs_tree->hwndTV, &tvi ) ) break; ConfigTreeData *config_data = prefs_tree->FindModuleConfig( (ConfigTreeData *)tvi.lParam ); if( config_data && hwnd == config_data->panel->config_window ) { int dy; RECT rc; GetWindowRect( hwnd, &rc); int newvalue = config_data->panel->oldvalue; switch ( GET_WM_VSCROLL_CODE(wp,lp) ) { case SB_BOTTOM : newvalue = 0; break; case SB_TOP : newvalue = config_data->panel->maxvalue; break; case SB_LINEDOWN : newvalue += 10; break; case SB_PAGEDOWN : newvalue += rc.bottom - rc.top - 25; break; // wrong! one page is notebook actual length case SB_LINEUP : newvalue -= 10; break; case SB_PAGEUP : newvalue -= rc.bottom - rc.top - 25; break; case SB_THUMBPOSITION: case SB_THUMBTRACK : newvalue = GET_WM_VSCROLL_POS(wp,lp); break; } newvalue = max(0,min(config_data->panel->maxvalue,newvalue)); SetScrollPos( hwnd,SB_VERT,newvalue,TRUE);//SB_CTL si hwnd=hwndScrollBar, SB_VERT si window dy = config_data->panel->oldvalue - newvalue; ScrollWindowEx( hwnd, 0, dy, NULL, NULL, NULL, NULL, SW_SCROLLCHILDREN ); UpdateWindow ( hwnd); config_data->panel->oldvalue = newvalue; } break; } default: break; } return FALSE; }