Sun Jan 2 12:38:53 1994 David Metcalfe <david@prism.demon.co.uk> * [windows/class.c] Implemented GetClassName and GetClassInfo. * [windows/caret.c] Various improvements to text caret code. Fri Dec 31 15:22:22 1993 John Brezak <brezak@apollo.hp.com> * [misc/comm.c] Patches to work with NetBSD. Thu Dec 30 12:11:55 1993 John Richardson <jrichard@cs.uml.edu> * [objects/bitblt.c] Added StretchBlt(). Tue Jan 4 05:22:07 1994 julliard@di.epfl.ch (Alexandre Julliard) * [misc/user.c] Added creation of system message queue. * [objects/bitmap.c] [objects/dcvalues.c] [windows/dc.c] Added DC size fields into DC structure. * [objects/clipping.c] Bug fix in CLIPPING_IntersectRect(). * [windows/class.c] Allocate a DCE instead of a DC for CS_CLASSDC classes. * [windows/clipping.c] Fixed GetUpdateRect() and GetUpdateRgn() to clip to the client area. * [windows/dce.c] Implemented GetDCEx() and GetWindowDC(). * [windows/defwnd.c] Implemented WM_WINDOWPOSCHANGED handling. * [windows/event.c] Preliminary support for Xlib event handling instead of Xt callbacks. Changed MSG_AddMsg() calls to hardware_event() or PostMessage(). * [windows/message.c] Preliminary support for multiple message queues. Implemented hardware_event() to store messages into the system queue. Implemented Get/SetTaskQueue(). Better WM_PAINT and WM_TIMER handling. Changes to use Xlib instead of Xt for events. * [windows/painting.c] Use GetDCEx() to retrieve the DC, to get a correct visible region. * [windows/timer.c] Moved the timer procedure callback into DispatchMessage(). Changed implementation to get rid of Xt timeouts. Timer checking is now done inside GetMessage(). * [windows/win.c] Allocate a DCE instead of a DC for CS_OWNDC windows. Replaced Xt calls with Xlib calls. Moved window positioning functions into windows/winpos.c * [windows/winpos.c] (New file) Rewritten most of the window positioning functions. Implemented SetWindowPos() and MapWindowPoints(). Jan 3, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) * [if1632/user.spec] Bad arguments description for function SetDlgItemText. * [objects/text.c] Function DrawText now handle DT_CALCRECT request. * [misc/message.c] Message boxes now use DrawText with DT_CALCRECT. * [windows/graphics.c] Bug fix in function FrameRect, (it was using PEN instead of BRUSH). * [windows/win.c] Bug fix for flags in function ShowWindow. More accurate WM_SIZE generated by function ShowWindow. * [controls/listbox.c] More code for LBS_MULTIPLESEL. More code for LBS_MULTICOLUMN. * [include/windows.h] Bad define for MF_SEPARATOR. * [controls/menu.c] New functions: PopMenuWndProc() with 'glues', CreatePopupMenu(), AppendMenu(), InsertMenu(), RemoveMenu(), DeleteMenu(), ModifyMenu(), TrackPopupMenu(). Code in stubs: CreateMenu(), DestroyMenu(). Sat Jan 1 10:22:43 1994 Bob Amstadt (bob@pooh) * loader/wine.c: Added support for relocation types 5 and 6. Mon Dec 27 11:06:03 1993 Erik Bos (erik@trashcan.hacktic.nl) * [misc/comm.c] new functions: BuildCommDCB(), OpenComm(), CloseComm(), SetCommBreak(), ClearCommBreak(), EscapeCommFunction(), FlushComm(), GetCommError(), SetCommEventMask(), GetCommEventMask(), SetCommState(), GetCommState(), TransmitCommChar(), ReadComm(), WriteComm(). Wed Dec 22 13:00:15 1993 David Metcalfe <david@prism.demon.co.uk> * [windows/caret.c] Implemented text caret functions. Tue Dec 21 06:13:58 1993 julliard@di.epfl.ch (Alexandre Julliard) * [loader/wine.c] Bug fix in LoadImage(). * [objects/bitblt.c] [objects/clipping.c] [objects/text.c] [windows/dc.c] [windows/dce.c] [windows/graphics.c] Modified graphics calls to take into account the DC origin. * [windows/defwnd.c] Added preliminary WM_NCCALCSIZE handling. * [windows/event.c] Send WM_NCCALCSIZE message on resize event. * [windows/win.c] Send WM_NCCALCSIZE message in CreateWindow(). Realize widgets at creation time (should prevent problems with unrealized widgets). Dec 19, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) * [controls/static.c] Send mouse & keyboard message received to its parent. * [controls/scroll.c] Send keyboard message received to its parent. * [controls/listbox.c] Add Navigation keys . ListBox now use VSCROLL & HSCROLL instead of children. Alpha version of LBS_MULTIPLESEL. Alpha version of LBS_MULTICOLUMN. * [controls/combo.c] Add Navigation keys on closed ComboBox. Remove useless 'COMBOBOX_CreateComboBox' function. Mon Dec 19 20:39:34 1993 Erik Bos (erik@trashcan.hacktic.nl) * [loader/wine. LoadImage() modified to use FindFile(). * [misc/file.c] SetErrorMode added * [misc/dos_fs.c] bug fixes. Dec 13, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) * [memory/global.c] bug fix in GlobalGetFreeSegment : good ptr in 'g_prev'. * [sysres.dll] preliminary version of a 'glass of wine' bitmap * [windows/event.c] New function 'GetCapture'. * [controls/scroll.c] Remove useless 'SCROLLBAR_CreateScrollBar' function. * [controls/listbox.c] Remove useless 'LISTBOX_CreateListBox' function. Mon Dec 13 13:51:00 1993 David Metcalfe <david@prism.demon.co.uk> * [objects/font.c] Corrected bugs in GetCharWidth(). * [windows/event.c] Modified EVENT_key to send Windows virtual key codes for WM_KEYDOWN and WM_KEYUP messages, and a WM_CHAR message for printable characters. Wed Dec 08 19:20:00 1993 Karl Guenter Wuensch (hn324wu@unidui.uni-duisburg.de) * [windows/graphics.c] Added Polyline and Polygon Mon Dec 13 14:51:54 1993 Erik Bos (erik@trashcan.hacktic.nl) * [controls/listbox.c] ListBoxDirectory() modified to use dos_fs.c's functions to access files&|drives. Sat Dec 04 17:04:23 1993 Erik Bos (erik@trashcan.hacktic.nl) * [misc/dos_fs.c] Added FindFile() to search a file in a dos/unix style path. * [misc/file.c] New Win31 functions: OpenFile, _lcreate, _llseek, GetTempDrive, GetTempFileName, GetWindowsDirectory, GetSystemDirectory, GetDriveType. * [misc/int21.c] Modified. Wed Dec 1 16:20:45 1993 Miguel de Icaza (miguel@roxanne.nuclecu.unam.mx) * [misc/profile.c] The Profile functions now return the correct values. They now implement all the features described in the SDK. Tue Nov 30 13:55:27 1993 Bob Amstadt (bob at amscons) * [loader/selector.c] Rewrote selector aliasing routines to use System V IPC routine to alias memory segments. Nov 28, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) * [controls/listbox.c] More consistency in functions using wIndexes * [controls/scroll.c] New function : ShowScrollBar(). * [loader/cursor.c] ... New file Move cursor functions from [loader/resource.c]. New function : ClipCursor(). New function : GetClipCursor(). New function : CreateCursor(). SetCursor() now working using gloabal variable 'winHasCursor'. *[object/palette.c] New stub only : SelectPalette(). New stub only : RealizePalette(). *[win/event.c] New function : EVENT_enter_notify(), update 'winHasCursor' and send WM_SETCURSOR. *[win/defwnd.c] Add processing of WM_SETCURSOR message. *[win/win.c] New members in WND structure : hCursor, hWndVScroll & hWndHScroll. CreateWindowEx() now create children for WM_HSCROLL & WM_VSCROLL. New function ClientToScreen(). New function ScreenToClient(). Mon Nov 25 18:25:40 1993 Erik Bos (erik@trashcan.hacktic.nl) * [files.h / regfunc.h / misc/dos.c] Removed. * [misc/dos_fs.c] Added support for loading dosdrive cfg from wine.ini. * [misc/int21.c] Modified. Wed Nov 24 11:37:33 1993 julliard@disuns2.epfl.ch (Alexandre Julliard) * [include/atom.h] [memory/atom.c] Implemented atoms. * [windows/class.c] Modified RegisterClass() to use atoms. Implemented CS_GLOBALCLASS style. * [windows/message.c] Implemented RegisterWindowMessage(). * [loader/resource.c] Bug fix in LoadResource(). * [windows/dialog.c] Modified CreateDialogParam() to use Find/LoadResource().
437 lines
12 KiB
C
437 lines
12 KiB
C
/*
|
|
* Interface code to SCROLLBAR widget
|
|
*
|
|
* Copyright Martin Ayotte, 1993
|
|
*
|
|
*/
|
|
|
|
/*
|
|
#define DEBUG_SCROLL
|
|
*/
|
|
|
|
static char Copyright[] = "Copyright Martin Ayotte, 1993";
|
|
|
|
#include <X11/Intrinsic.h>
|
|
#include <X11/StringDefs.h>
|
|
#include "windows.h"
|
|
#include "scroll.h"
|
|
#include "heap.h"
|
|
#include "win.h"
|
|
#include <sys/types.h>
|
|
#include <dirent.h>
|
|
#include <sys/stat.h>
|
|
|
|
LPHEADSCROLL ScrollBarGetWindowAndStorage(HWND hwnd, WND **wndPtr);
|
|
LPHEADSCROLL ScrollBarGetStorageHeader(HWND hwnd);
|
|
void StdDrawScrollBar(HWND hwnd);
|
|
int CreateScrollBarStruct(HWND hwnd);
|
|
|
|
|
|
/***********************************************************************
|
|
* WIDGETS_ScrollBarWndProc
|
|
*/
|
|
LONG ScrollBarWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
|
|
{
|
|
WORD wRet;
|
|
short x, y;
|
|
WND *wndPtr;
|
|
LPHEADSCROLL lphs;
|
|
RECT rect;
|
|
static RECT rectsel;
|
|
switch(message)
|
|
{
|
|
case WM_CREATE:
|
|
CreateScrollBarStruct(hwnd);
|
|
#ifdef DEBUG_SCROLL
|
|
printf("ScrollBar Creation up=%X down=%X!\n", lphs->hWndUp, lphs->hWndDown);
|
|
#endif
|
|
return 0;
|
|
case WM_DESTROY:
|
|
lphs = ScrollBarGetWindowAndStorage(hwnd, &wndPtr);
|
|
if (lphs == 0) return 0;
|
|
#ifdef DEBUG_SCROLL
|
|
printf("ScrollBar WM_DESTROY %lX !\n", lphs);
|
|
#endif
|
|
DestroyWindow(lphs->hWndUp);
|
|
DestroyWindow(lphs->hWndDown);
|
|
free(lphs);
|
|
*((LPHEADSCROLL *)&wndPtr->wExtra[1]) = 0;
|
|
return 0;
|
|
|
|
case WM_COMMAND:
|
|
#ifdef DEBUG_SCROLL
|
|
printf("ScrollBar WM_COMMAND wParam=%X lParam=%lX !\n", wParam, lParam);
|
|
#endif
|
|
lphs = ScrollBarGetWindowAndStorage(hwnd, &wndPtr);
|
|
if (HIWORD(lParam) != BN_CLICKED) return 0;
|
|
if (LOWORD(lParam) == lphs->hWndUp)
|
|
SendMessage(wndPtr->hwndParent, lphs->Direction,
|
|
SB_LINEUP, MAKELONG(0, hwnd));
|
|
if (LOWORD(lParam) == lphs->hWndDown)
|
|
SendMessage(wndPtr->hwndParent, lphs->Direction,
|
|
SB_LINEDOWN, MAKELONG(0, hwnd));
|
|
/*
|
|
SetFocus(hwnd);
|
|
*/
|
|
return 0;
|
|
|
|
case WM_LBUTTONDOWN:
|
|
lphs = ScrollBarGetWindowAndStorage(hwnd, &wndPtr);
|
|
/*
|
|
SetFocus(hwnd);
|
|
*/
|
|
SetCapture(hwnd);
|
|
GetClientRect(hwnd, &rect);
|
|
if (lphs->Direction == WM_VSCROLL) {
|
|
y = HIWORD(lParam);
|
|
#ifdef DEBUG_SCROLL
|
|
printf("WM_LBUTTONDOWN y=%d cur+right=%d %d\n",
|
|
y, lphs->CurPix + rect.right, lphs->CurPix + (rect.right << 1));
|
|
#endif
|
|
if (y < (lphs->CurPix + rect.right))
|
|
SendMessage(wndPtr->hwndParent, lphs->Direction,
|
|
SB_PAGEUP, MAKELONG(0, hwnd));
|
|
if (y > (lphs->CurPix + (rect.right << 1)))
|
|
SendMessage(wndPtr->hwndParent, lphs->Direction,
|
|
SB_PAGEDOWN, MAKELONG(0, hwnd));
|
|
if ((y > (lphs->CurPix + rect.right)) &&
|
|
(y < (lphs->CurPix + (rect.right << 1)))) {
|
|
lphs->ThumbActive = TRUE;
|
|
#ifdef DEBUG_SCROLL
|
|
printf("THUMB DOWN !\n");
|
|
#endif
|
|
}
|
|
}
|
|
else {
|
|
x = LOWORD(lParam);
|
|
#ifdef DEBUG_SCROLL
|
|
printf("WM_LBUTTONDOWN x=%d Cur+bottom=%d %d\n",
|
|
x, lphs->CurPix + rect.bottom, lphs->CurPix + (rect.bottom << 1));
|
|
#endif
|
|
if (x < (lphs->CurPix + rect.bottom))
|
|
SendMessage(wndPtr->hwndParent, lphs->Direction,
|
|
SB_PAGEUP, MAKELONG(0, hwnd));
|
|
if (x > (lphs->CurPix + (rect.bottom << 1)))
|
|
SendMessage(wndPtr->hwndParent, lphs->Direction,
|
|
SB_PAGEDOWN, MAKELONG(0, hwnd));
|
|
if ((x > (lphs->CurPix + rect.bottom)) &&
|
|
(x < (lphs->CurPix + (rect.bottom << 1)))) {
|
|
lphs->ThumbActive = TRUE;
|
|
#ifdef DEBUG_SCROLL
|
|
printf("THUMB DOWN !\n");
|
|
#endif
|
|
}
|
|
}
|
|
break;
|
|
case WM_LBUTTONUP:
|
|
lphs = ScrollBarGetStorageHeader(hwnd);
|
|
lphs->ThumbActive = FALSE;
|
|
ReleaseCapture();
|
|
break;
|
|
|
|
case WM_KEYDOWN:
|
|
case WM_KEYUP:
|
|
case WM_CHAR:
|
|
lphs = ScrollBarGetWindowAndStorage(hwnd, &wndPtr);
|
|
return(SendMessage(wndPtr->hwndParent, message, wParam, lParam));
|
|
|
|
case WM_PAINT:
|
|
StdDrawScrollBar(hwnd);
|
|
break;
|
|
case WM_MOUSEMOVE:
|
|
if ((wParam & MK_LBUTTON) != 0) {
|
|
lphs = ScrollBarGetWindowAndStorage(hwnd, &wndPtr);
|
|
if (lphs->ThumbActive == 0) break;
|
|
GetClientRect(hwnd, &rect);
|
|
if (lphs->Direction == WM_VSCROLL)
|
|
y = HIWORD(lParam) - rect.right - (rect.right >> 1);
|
|
else
|
|
y = LOWORD(lParam) - rect.bottom - (rect.bottom >> 1);
|
|
x = (y * (lphs->MaxVal - lphs->MinVal) /
|
|
lphs->MaxPix) + lphs->MinVal;
|
|
#ifdef DEBUG_SCROLL
|
|
printf("WM_MOUSEMOVE val=%d pix=%d\n", x, y);
|
|
#endif
|
|
SendMessage(wndPtr->hwndParent, lphs->Direction,
|
|
SB_THUMBTRACK, MAKELONG(x, hwnd));
|
|
}
|
|
break;
|
|
default:
|
|
return DefWindowProc( hwnd, message, wParam, lParam );
|
|
}
|
|
return(0);
|
|
}
|
|
|
|
|
|
|
|
LPHEADSCROLL ScrollBarGetWindowAndStorage(HWND hwnd, WND **wndPtr)
|
|
{
|
|
WND *Ptr;
|
|
LPHEADSCROLL lphs;
|
|
*(wndPtr) = Ptr = WIN_FindWndPtr(hwnd);
|
|
if (Ptr == 0) {
|
|
printf("Bad Window handle on ScrollBar !\n");
|
|
return 0;
|
|
}
|
|
lphs = *((LPHEADSCROLL *)&Ptr->wExtra[1]);
|
|
return lphs;
|
|
}
|
|
|
|
|
|
LPHEADSCROLL ScrollBarGetStorageHeader(HWND hwnd)
|
|
{
|
|
WND *wndPtr;
|
|
LPHEADSCROLL lphs;
|
|
wndPtr = WIN_FindWndPtr(hwnd);
|
|
if (wndPtr == 0) {
|
|
printf("Bad Window handle on ScrollBar !\n");
|
|
return 0;
|
|
}
|
|
lphs = *((LPHEADSCROLL *)&wndPtr->wExtra[1]);
|
|
return lphs;
|
|
}
|
|
|
|
|
|
void StdDrawScrollBar(HWND hwnd)
|
|
{
|
|
LPHEADSCROLL lphs;
|
|
PAINTSTRUCT ps;
|
|
HBRUSH hBrush;
|
|
HDC hdc;
|
|
RECT rect;
|
|
UINT i, w, h, siz;
|
|
char C[128];
|
|
hdc = BeginPaint( hwnd, &ps );
|
|
if (!IsWindowVisible(hwnd)) {
|
|
EndPaint( hwnd, &ps );
|
|
return;
|
|
}
|
|
hBrush = SendMessage(GetParent(hwnd), WM_CTLCOLOR, (WORD)hdc,
|
|
MAKELONG(hwnd, CTLCOLOR_SCROLLBAR));
|
|
if (hBrush == (HBRUSH)NULL) hBrush = GetStockObject(LTGRAY_BRUSH);
|
|
lphs = ScrollBarGetStorageHeader(hwnd);
|
|
if (lphs == NULL) goto EndOfPaint;
|
|
GetClientRect(hwnd, &rect);
|
|
w = rect.right - rect.left;
|
|
h = rect.bottom - rect.top;
|
|
if (lphs->Direction == WM_VSCROLL) {
|
|
rect.top += w;
|
|
rect.bottom -= w;
|
|
}
|
|
else {
|
|
rect.left += h;
|
|
rect.right -= h;
|
|
}
|
|
FillRect(hdc, &rect, hBrush);
|
|
if (lphs->Direction == WM_VSCROLL)
|
|
SetRect(&rect, 0, lphs->CurPix + w, w, lphs->CurPix + (w << 1));
|
|
else
|
|
SetRect(&rect, lphs->CurPix + h, 0, lphs->CurPix + (h << 1), h);
|
|
FrameRect(hdc, &rect, GetStockObject(BLACK_BRUSH));
|
|
InflateRect(&rect, -1, -1);
|
|
FillRect(hdc, &rect, GetStockObject(LTGRAY_BRUSH));
|
|
DrawReliefRect(hdc, rect, 2, 0);
|
|
InflateRect(&rect, -3, -3);
|
|
DrawReliefRect(hdc, rect, 1, 1);
|
|
if (!lphs->ThumbActive) {
|
|
InvalidateRect(lphs->hWndUp, NULL, TRUE);
|
|
UpdateWindow(lphs->hWndUp);
|
|
InvalidateRect(lphs->hWndDown, NULL, TRUE);
|
|
UpdateWindow(lphs->hWndDown);
|
|
}
|
|
EndOfPaint:
|
|
EndPaint( hwnd, &ps );
|
|
}
|
|
|
|
|
|
|
|
int CreateScrollBarStruct(HWND hwnd)
|
|
{
|
|
RECT rect;
|
|
int width, height;
|
|
WND *wndPtr;
|
|
LPHEADSCROLL lphs;
|
|
wndPtr = WIN_FindWndPtr(hwnd);
|
|
lphs = (LPHEADSCROLL)malloc(sizeof(HEADSCROLL));
|
|
if (lphs == 0) {
|
|
printf("Bad Memory Alloc on ScrollBar !\n");
|
|
return 0;
|
|
}
|
|
|
|
#ifdef DEBUG_SCROLL
|
|
printf("CreateScrollBarStruct %lX !\n", lphs);
|
|
#endif
|
|
*((LPHEADSCROLL *)&wndPtr->wExtra[1]) = lphs;
|
|
lphs->ThumbActive = FALSE;
|
|
lphs->MinVal = 0;
|
|
lphs->MaxVal = 100;
|
|
lphs->CurVal = 0;
|
|
lphs->CurPix = 0;
|
|
width = wndPtr->rectClient.right - wndPtr->rectClient.left;
|
|
height = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
|
|
if (width <= height)
|
|
{
|
|
lphs->MaxPix = height - 3 * width;
|
|
lphs->Direction = WM_VSCROLL;
|
|
lphs->hWndUp = CreateWindow("BUTTON", "",
|
|
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
|
0, 0, width, width, hwnd, 1, wndPtr->hInstance, 0L);
|
|
lphs->hWndDown = CreateWindow("BUTTON", "",
|
|
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
|
0, height - width, width, width, hwnd, 2,
|
|
wndPtr->hInstance, 0L);
|
|
}
|
|
else
|
|
{
|
|
lphs->MaxPix = width - 3 * height;
|
|
lphs->Direction = WM_HSCROLL;
|
|
lphs->hWndUp = CreateWindow("BUTTON", "",
|
|
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
|
0, 0, height, height, hwnd, 0, wndPtr->hInstance, 0L);
|
|
lphs->hWndDown = CreateWindow("BUTTON", "",
|
|
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
|
|
width - height, 0, height, height, hwnd, 0,
|
|
wndPtr->hInstance, 0L);
|
|
}
|
|
if (lphs->MaxPix < 1) lphs->MaxPix = 1;
|
|
if (wndPtr->hCursor == (HCURSOR)NULL)
|
|
wndPtr->hCursor = LoadCursor((HINSTANCE)NULL, IDC_ARROW);
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
/*************************************************************************
|
|
* GetScrollWindowHandle
|
|
*/
|
|
HWND GetScrollWindowHandle(HWND hWnd, int nBar)
|
|
{
|
|
WND *wndPtr;
|
|
if (nBar != SB_CTL) {
|
|
wndPtr = WIN_FindWndPtr(hWnd);
|
|
if (nBar == SB_VERT) return wndPtr->hWndVScroll;
|
|
if (nBar == SB_HORZ) return wndPtr->hWndHScroll;
|
|
return (HWND)NULL;
|
|
}
|
|
return hWnd;
|
|
}
|
|
|
|
|
|
/*************************************************************************
|
|
* SetScrollPos [USER.62]
|
|
*/
|
|
int SetScrollPos(HWND hwnd, int nBar, int nPos, BOOL bRedraw)
|
|
{
|
|
int nRet;
|
|
LPHEADSCROLL lphs;
|
|
hwnd = GetScrollWindowHandle(hwnd, nBar);
|
|
lphs = ScrollBarGetStorageHeader(hwnd);
|
|
if (lphs == NULL) return 0;
|
|
nRet = lphs->CurVal;
|
|
lphs->CurVal = (short)nPos;
|
|
if (lphs->MaxVal != lphs->MinVal)
|
|
lphs->CurPix = lphs->MaxPix * (abs((short)nPos) - abs(lphs->MinVal)) /
|
|
(abs(lphs->MaxVal) - abs(lphs->MinVal));
|
|
if (lphs->CurPix > lphs->MaxPix) lphs->CurPix = lphs->MaxPix;
|
|
#ifdef DEBUG_SCROLL
|
|
printf("SetScrollPos val=%d pixval=%d pixmax%d\n",
|
|
(short)nPos, lphs->CurPix, lphs->MaxPix);
|
|
printf("SetScrollPos min=%d max=%d\n",
|
|
lphs->MinVal, lphs->MaxVal);
|
|
#endif
|
|
if ((bRedraw) && (IsWindowVisible(hwnd))) {
|
|
InvalidateRect(hwnd, NULL, TRUE);
|
|
UpdateWindow(hwnd);
|
|
}
|
|
return nRet;
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
* GetScrollPos [USER.63]
|
|
*/
|
|
int GetScrollPos(HWND hwnd, int nBar)
|
|
{
|
|
LPHEADSCROLL lphs;
|
|
hwnd = GetScrollWindowHandle(hwnd, nBar);
|
|
lphs = ScrollBarGetStorageHeader(hwnd);
|
|
if (lphs == NULL) return 0;
|
|
return lphs->CurVal;
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
* SetScrollRange [USER.64]
|
|
*/
|
|
void SetScrollRange(HWND hwnd, int nBar, int MinPos, int MaxPos, BOOL bRedraw)
|
|
{
|
|
LPHEADSCROLL lphs;
|
|
hwnd = GetScrollWindowHandle(hwnd, nBar);
|
|
lphs = ScrollBarGetStorageHeader(hwnd);
|
|
if (lphs == NULL) return;
|
|
lphs->MinVal = (short)MinPos;
|
|
lphs->MaxVal = (short)MaxPos;
|
|
if (lphs->MaxVal != lphs->MinVal)
|
|
lphs->CurPix = abs(lphs->MaxVal) *
|
|
(abs(lphs->CurVal) - abs(lphs->MinVal)) /
|
|
(abs(lphs->MaxVal) - abs(lphs->MinVal));
|
|
if (lphs->CurPix > lphs->MaxPix) lphs->CurPix = lphs->MaxPix;
|
|
#ifdef DEBUG_SCROLL
|
|
printf("SetScrollRange min=%d max=%d\n", lphs->MinVal, lphs->MaxVal);
|
|
#endif
|
|
if ((bRedraw) && (IsWindowVisible(hwnd))) {
|
|
InvalidateRect(hwnd, NULL, TRUE);
|
|
UpdateWindow(hwnd);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
* GetScrollRange [USER.65]
|
|
*/
|
|
void GetScrollRange(HWND hwnd, int nBar, LPINT lpMin, LPINT lpMax)
|
|
{
|
|
LPHEADSCROLL lphs;
|
|
hwnd = GetScrollWindowHandle(hwnd, nBar);
|
|
lphs = ScrollBarGetStorageHeader(hwnd);
|
|
if (lphs == NULL) return;
|
|
*lpMin = lphs->MinVal;
|
|
*lpMax = lphs->MaxVal;
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
* ShowScrollBar [USER.267]
|
|
*/
|
|
void ShowScrollBar(HWND hWnd, WORD wBar, BOOL bFlag)
|
|
{
|
|
WND *wndPtr;
|
|
#ifdef DEBUG_SCROLL
|
|
printf("ShowScrollBar hWnd=%04X wBar=%d bFlag=%d\n", hWnd, wBar, bFlag);
|
|
#endif
|
|
if (wBar == SB_CTL) {
|
|
if (bFlag)
|
|
ShowWindow(hWnd, SW_SHOW);
|
|
else
|
|
ShowWindow(hWnd, SW_HIDE);
|
|
return;
|
|
}
|
|
wndPtr = WIN_FindWndPtr(hWnd);
|
|
if ((wBar == SB_VERT) || (wBar == SB_BOTH)) {
|
|
if (bFlag)
|
|
ShowWindow(wndPtr->hWndVScroll, SW_SHOW);
|
|
else
|
|
ShowWindow(wndPtr->hWndVScroll, SW_HIDE);
|
|
}
|
|
if ((wBar == SB_HORZ) || (wBar == SB_BOTH)) {
|
|
if (bFlag)
|
|
ShowWindow(wndPtr->hWndHScroll, SW_SHOW);
|
|
else
|
|
ShowWindow(wndPtr->hWndHScroll, SW_HIDE);
|
|
}
|
|
}
|
|
|
|
|