Release 940201
Tue Feb 1 21:14:47 1994 Bob Amstadt (bob@pooh)
* [loader/selector.c]
Added function CreateNewSegments(). Modified IPCCopySelector
to allow aliasing to any arbitrary memory space.
* [memory/global.c]
Fixed potential bug in GlobalGetFreeSegments().
* [memory/linear.c]
Created functions GlobalLinearLock() and GlobalLinearUnlock().
Tue Feb 1 05:51:43 1994 julliard@di.epfl.ch (Alexandre Julliard)
* [controls/widgets.c]
Removed CAPTION window class.
* [loader/cursor.c]
Bug fix in LoadCursor(): don't allocate memory every time for
built-in cursors.
* [windows/clipping.c]
Invalidate child windows in InvalidateRgn().
* [windows/defwnd.c]
Added repaint of the caption when changing window text.
* [windows/event.c]
Modified SetCapture() to allow keyboard events while capturing.
* [windows/message.c]
New function MSG_GetHardwareMessage(), to do mouse tracking
without returning control to the Windows program.
* [windows/nonclient.c]
A couple of changes in frame drawing for DLGMODALFRAME windows.
Rewritten window moving code, to use MSG_GetHardwareMessage()
instead of non-client mouse events (this is the way Windows
does it), and to send WM_ENTERSIZEMOVE messages.
Removed WM_NCBUTTONUP and WM_NCMOUSEMOVE handlers.
* [windows/win.c]
Allocate temporary structures on the USER heap instead of
using GlobalAlloc().
* [windows/winpos.c]
Added function WINPOS_GetMinMaxInfo() to get sizing informations.
Jan 31, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)
* [windows/nonclient.c]
Call to StdDrawScrollBar() during NC's drawing.
Call to NC_ScrollBarButtonDown() on NC mouse events WM_LBUTTONDOWN.
Call to NC_ScrollBarButtonUp() on NC mouse events WM_LBUTTONUP.
Call to NC_ScrollBarMouseMove() on NC mouse events WM_MOUSEMOVE.
* [controls/menu.c]
New GetSubMenu() function.
Move GetMenu() & SetMenu() functions from 'windows/win.c'.
* [controls/listbox.c]
Start changes to satisfy recent changes in scrollbars/windows.
* [loader/resource.c]
Put some code in LoadAccelerators() stub.
New TranslateAccelerator() function.
* [windows/win.c]
Remove GetMenu() & SetMenu() functions.
Call to NC_CreateScrollBars() if required by CreateWindow().
Mon Jan 24 10:40:10 EST 1994 John Richardson (jrichard@cs.uml.edu)
* [window/win.c]
Added functions EnumWindows, EnumChildWindows, and helper
WIN_EnumChildWin. EnumWindows won't list all wine windows
because GetDesktopWindow isn't complete. However, the code
is in place for it to work correctly and only needs
GetDesktopWindow to do so.
Tue Jan 25 05:51:47 1994 julliard@di.epfl.ch (Alexandre Julliard)
* [windows/defwnd.c]
Added handling of activation messages (WM_ACTIVATE,
WM_NCACTIVATE, WM_MOUSEACTIVATE)
* [windows/event.c]
De-activate the window when losing input focus.
* [windows/focus.c]
Bug fix in SetFocus().
* [windows/message.c]
Added activation of the window on mouse-clicks.
* [windows/nonclient.c]
Changed non-client area painting to use the correct colors
depending upon the activation state.
Added WM_NCACTIVATE message handling.
Fixed a couple of bugs in window moving and resizing.
* [windows/winpos.c]
Implemented Get/SetActiveWindow().
Implemented SWP_NOACTIVATE flag in SetWindowPos().
Jan 17, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)
* [misc/message.c]
MessageBox has a CaptionBar for his title except for
MB_SYSTEMMODAL with MB_ICONHAND.
* [windows/nonclient.c]
Call to NC_TrackSysMenu on SysMenu button mouse click.
* [windows/defwnd.c]
Call to NC_TrackSysMenu on Alt key (VK_MENU).
* [controls/menu.c]
New GetSystemMenu() function.
New CopySystemMenu() internal function.
New NC_TrackSysMenu() internal function.
* [include/windows.h]
New WM_INITMENU, WM_INITMENUPOPUP, WM_MENUSELECT & WM_MENUCHAR defines.
diff --git a/controls/scroll.c b/controls/scroll.c
index 47da5bf..0f2aa84 100644
--- a/controls/scroll.c
+++ b/controls/scroll.c
@@ -8,12 +8,12 @@
/*
#define DEBUG_SCROLL
*/
-
static char Copyright[] = "Copyright Martin Ayotte, 1993";
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include "windows.h"
+#include "sysmetrics.h"
#include "scroll.h"
#include "heap.h"
#include "win.h"
@@ -30,33 +30,39 @@
HBITMAP hLfArrowD = 0;
HBITMAP hRgArrowD = 0;
-LPHEADSCROLL ScrollBarGetWindowAndStorage(HWND hwnd, WND **wndPtr);
-LPHEADSCROLL ScrollBarGetStorageHeader(HWND hwnd);
-void StdDrawScrollBar(HWND hwnd);
-int CreateScrollBarStruct(HWND hwnd);
+LPHEADSCROLL ScrollBarGetWindowAndStorage(HWND hWnd, WND **wndPtr);
+LPHEADSCROLL ScrollBarGetStorageHeader(HWND hWnd);
+LPHEADSCROLL GetScrollObjectHandle(HWND hWnd, int nBar);
+void ScrollBarButtonDown(HWND hWnd, int nBar, int x, int y);
+void ScrollBarButtonUp(HWND hWnd, int nBar, int x, int y);
+void ScrollBarMouseMove(HWND hWnd, int nBar, WORD wParam, int x, int y);
+void StdDrawScrollBar(HWND hWnd, HDC hDC, int nBar, LPRECT lprect, LPHEADSCROLL lphs);
+int CreateScrollBarStruct(HWND hWnd);
+void NC_CreateScrollBars(HWND hWnd);
+LPHEADSCROLL AllocScrollBar(DWORD dwStyle, int width, int height);
/***********************************************************************
* WIDGETS_ScrollBarWndProc
*/
-LONG ScrollBarWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
+LONG ScrollBarWndProc( HWND hWnd, WORD message, WORD wParam, LONG lParam )
{
WORD wRet;
short x, y;
short width, height;
WND *wndPtr;
LPHEADSCROLL lphs;
- LPDRAWITEMSTRUCT lpdis;
- HDC hMemDC;
+ PAINTSTRUCT ps;
+ HDC hDC;
BITMAP bm;
- RECT rect;
+ RECT rect, rect2;
static RECT rectsel;
switch(message)
{
case WM_CREATE:
- CreateScrollBarStruct(hwnd);
+ CreateScrollBarStruct(hWnd);
#ifdef DEBUG_SCROLL
- printf("ScrollBar Creation up=%X down=%X!\n", lphs->hWndUp, lphs->hWndDown);
+ printf("ScrollBar Creation !\n");
#endif
if (hUpArrow == (HBITMAP)NULL)
hUpArrow = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_UPARROWI));
@@ -76,197 +82,271 @@
hRgArrowD = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_RGARROWD));
return 0;
case WM_DESTROY:
- lphs = ScrollBarGetWindowAndStorage(hwnd, &wndPtr);
+ 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
- }
- }
+ SetCapture(hWnd);
+ ScrollBarButtonDown(hWnd, SB_CTL, LOWORD(lParam), HIWORD(lParam));
break;
case WM_LBUTTONUP:
- lphs = ScrollBarGetStorageHeader(hwnd);
- lphs->ThumbActive = FALSE;
ReleaseCapture();
+ ScrollBarButtonUp(hWnd, SB_CTL, LOWORD(lParam), HIWORD(lParam));
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("Scroll WM_MOUSEMOVE val=%d pix=%d\n", x, y);
-#endif
- SendMessage(wndPtr->hwndParent, lphs->Direction,
- SB_THUMBTRACK, MAKELONG(x, hwnd));
- }
+ ScrollBarMouseMove(hWnd, SB_CTL, wParam, LOWORD(lParam), HIWORD(lParam));
break;
case WM_KEYDOWN:
case WM_KEYUP:
case WM_CHAR:
- lphs = ScrollBarGetWindowAndStorage(hwnd, &wndPtr);
+ lphs = ScrollBarGetWindowAndStorage(hWnd, &wndPtr);
return(SendMessage(wndPtr->hwndParent, message, wParam, lParam));
- case WM_SIZE:
- lphs = ScrollBarGetWindowAndStorage(hwnd, &wndPtr);
- width = LOWORD(lParam);
- height = HIWORD(lParam);
- if (lphs->Direction == WM_VSCROLL) {
- MoveWindow(lphs->hWndUp, 0, 0, width, width, TRUE);
- MoveWindow(lphs->hWndDown, 0, height - width, width, width, TRUE);
- }
- else {
- MoveWindow(lphs->hWndUp, 0, 0, height, height, TRUE);
- MoveWindow(lphs->hWndDown, width - height, 0, height, height, TRUE);
- }
- break;
- case WM_DRAWITEM:
+ case WM_TIMER:
#ifdef DEBUG_SCROLL
- printf("Scroll WM_DRAWITEM w=%04X l=%08X\n", wParam, lParam);
+ printf("ScrollBar WM_TIMER wParam=%X lParam=%lX !\n", wParam, lParam);
#endif
- lpdis = (LPDRAWITEMSTRUCT)lParam;
- if (lpdis->CtlType == ODT_BUTTON && lpdis->itemAction == ODA_DRAWENTIRE) {
- hMemDC = CreateCompatibleDC(lpdis->hDC);
- if (lpdis->CtlID == 1) {
- GetObject(hUpArrow, sizeof(BITMAP), (LPSTR)&bm);
- SelectObject(hMemDC, hUpArrow);
-/* BitBlt(lpdis->hDC, 0, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); */
- StretchBlt(lpdis->hDC, 0, 0, lpdis->rcItem.right, lpdis->rcItem.right,
- hMemDC, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
- }
- if (lpdis->CtlID == 2) {
- GetObject(hDnArrow, sizeof(BITMAP), (LPSTR)&bm);
- SelectObject(hMemDC, hDnArrow);
- BitBlt(lpdis->hDC, 0, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
- }
- if (lpdis->CtlID == 3) {
- GetObject(hLfArrow, sizeof(BITMAP), (LPSTR)&bm);
- SelectObject(hMemDC, hLfArrow);
- BitBlt(lpdis->hDC, 0, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
- }
- if (lpdis->CtlID == 4) {
- GetObject(hRgArrow, sizeof(BITMAP), (LPSTR)&bm);
- SelectObject(hMemDC, hRgArrow);
- BitBlt(lpdis->hDC, 0, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
- }
- DeleteDC(hMemDC);
+ lphs = ScrollBarGetWindowAndStorage(hWnd, &wndPtr);
+ KillTimer(hWnd, wParam);
+ switch(lphs->ButtonDown) {
+ case 0:
+ lphs->TimerPending = FALSE;
+ return 0;
+ case 1:
+ case 3:
+ SendMessage(wndPtr->hwndParent, lphs->Direction,
+ SB_LINEUP, MAKELONG(0, hWnd));
+ break;
+ case 2:
+ case 4:
+ SendMessage(wndPtr->hwndParent, lphs->Direction,
+ SB_LINEDOWN, MAKELONG(0, hWnd));
+ break;
+ case 5:
+ SendMessage(wndPtr->hwndParent, lphs->Direction,
+ SB_PAGEUP, MAKELONG(0, hWnd));
+ break;
+ case 6:
+ SendMessage(wndPtr->hwndParent, lphs->Direction,
+ SB_PAGEDOWN, MAKELONG(0, hWnd));
+ break;
}
- if (lpdis->CtlType == ODT_BUTTON && lpdis->itemAction == ODA_SELECT) {
- hMemDC = CreateCompatibleDC(lpdis->hDC);
- if (lpdis->CtlID == 1) {
- GetObject(hUpArrowD, sizeof(BITMAP), (LPSTR)&bm);
- SelectObject(hMemDC, hUpArrowD);
- BitBlt(lpdis->hDC, 0, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
- }
- if (lpdis->CtlID == 2) {
- GetObject(hDnArrowD, sizeof(BITMAP), (LPSTR)&bm);
- SelectObject(hMemDC, hDnArrowD);
- BitBlt(lpdis->hDC, 0, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
- }
- if (lpdis->CtlID == 3) {
- GetObject(hLfArrowD, sizeof(BITMAP), (LPSTR)&bm);
- SelectObject(hMemDC, hLfArrowD);
- BitBlt(lpdis->hDC, 0, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
- }
- if (lpdis->CtlID == 4) {
- GetObject(hRgArrowD, sizeof(BITMAP), (LPSTR)&bm);
- SelectObject(hMemDC, hRgArrowD);
- BitBlt(lpdis->hDC, 0, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
- }
- DeleteDC(hMemDC);
- }
- break;
+ SetTimer(hWnd, 1, 100, NULL);
+ return 0;
+
case WM_PAINT:
- StdDrawScrollBar(hwnd);
+ hDC = BeginPaint(hWnd, &ps);
+ lphs = ScrollBarGetStorageHeader(hWnd);
+ if (lphs != NULL) {
+ GetClientRect(hWnd, &rect);
+ StdDrawScrollBar(hWnd, hDC, SB_CTL, &rect, lphs);
+ }
+ EndPaint(hWnd, &ps);
break;
default:
- return DefWindowProc( hwnd, message, wParam, lParam );
+ return DefWindowProc( hWnd, message, wParam, lParam );
}
return(0);
}
-LPHEADSCROLL ScrollBarGetWindowAndStorage(HWND hwnd, WND **wndPtr)
+void ScrollBarButtonDown(HWND hWnd, int nBar, int x, int y)
+{
+ LPHEADSCROLL lphs;
+ HWND hWndParent;
+ RECT rect, rect2;
+ int width, height;
+ LONG dwOwner;
+ lphs = GetScrollObjectHandle(hWnd, nBar);
+ printf("ScrollBarButtonDown // x=%d y=%d\n", x, y);
+#ifdef DEBUG_SCROLL
+ printf("ScrollBarButtonDown // x=%d y=%d\n", x, y);
+#endif
+ if (nBar == SB_CTL) {
+ hWndParent = GetParent(hWnd);
+ dwOwner = MAKELONG(0, lphs->hWndOwner);
+ }
+ else {
+ hWndParent = hWnd;
+ dwOwner = 0L;
+ }
+/*
+ SetFocus(lphs->hWndOwner);
+*/
+ if (nBar != SB_CTL) {
+ GetWindowRect(lphs->hWndOwner, &rect);
+ x -= rect.left;
+ y -= rect.top;
+ }
+ CopyRect(&rect, &lphs->rect);
+ printf("ScrollDown / x=%d y=%d left=%d top=%d right=%d bottom=%d \n",
+ x, y, rect.left, rect.top, rect.right, rect.bottom);
+ if (lphs->Direction == WM_VSCROLL) {
+ y -= rect.top;
+ width = rect.right - rect.left;
+ if (y < (lphs->CurPix + width)) {
+ if (y < width) {
+ lphs->ButtonDown = 1;
+ CopyRect(&rect2, &rect);
+ rect2.bottom = rect2.top + width;
+ InvalidateRect(lphs->hWndOwner, &rect2, TRUE);
+ printf("ScrollBarButtonDown // SB_LINEUP \n");
+ SendMessage(hWndParent, lphs->Direction,
+ SB_LINEUP, dwOwner);
+ }
+ else {
+ lphs->ButtonDown = 5;
+ printf("ScrollBarButtonDown // SB_PAGEUP \n");
+ SendMessage(hWndParent, lphs->Direction,
+ SB_PAGEUP, dwOwner);
+ }
+ }
+ if (y > (lphs->CurPix + (width << 1))) {
+ if (y > (rect.bottom - width)) {
+ lphs->ButtonDown = 2;
+ CopyRect(&rect2, &rect);
+ rect2.top = rect2.bottom - width;
+ InvalidateRect(lphs->hWndOwner, &rect2, TRUE);
+ printf("ScrollBarButtonDown // SB_LINEDOWN \n");
+ SendMessage(hWndParent, lphs->Direction,
+ SB_LINEDOWN, dwOwner);
+ }
+ else {
+ lphs->ButtonDown = 6;
+ printf("ScrollBarButtonDown // SB_PAGEDOWN \n");
+ SendMessage(hWndParent, lphs->Direction,
+ SB_PAGEDOWN, dwOwner);
+ }
+ }
+ if ((y > (lphs->CurPix + width)) &&
+ (y < (lphs->CurPix + (width << 1)))) {
+ lphs->ThumbActive = TRUE;
+#ifdef DEBUG_SCROLL
+ printf("THUMB DOWN !\n");
+#endif
+ }
+ }
+ else {
+ x -= rect.left;
+ height = rect.bottom - rect.top;
+ if (x < (lphs->CurPix + height)) {
+ if (x < height) {
+ lphs->ButtonDown = 3;
+ CopyRect(&rect2, &rect);
+ rect2.right = rect2.left + height;
+ InvalidateRect(lphs->hWndOwner, &rect2, TRUE);
+ SendMessage(hWndParent, lphs->Direction,
+ SB_LINEUP, dwOwner);
+ }
+ else {
+ lphs->ButtonDown = 5;
+ SendMessage(hWndParent, lphs->Direction,
+ SB_PAGEUP, dwOwner);
+ }
+ }
+ if (x > (lphs->CurPix + (height << 1))) {
+ if (x > (rect.right - rect.left - height)) {
+ lphs->ButtonDown = 4;
+ CopyRect(&rect2, &rect);
+ rect2.left = rect2.right - height;
+ InvalidateRect(lphs->hWndOwner, &rect2, TRUE);
+ SendMessage(hWndParent, lphs->Direction,
+ SB_LINEDOWN, dwOwner);
+ }
+ else {
+ lphs->ButtonDown = 6;
+ SendMessage(hWndParent, lphs->Direction,
+ SB_PAGEDOWN, dwOwner);
+ }
+ }
+ if ((x > (lphs->CurPix + height)) &&
+ (x < (lphs->CurPix + (height << 1)))) {
+ lphs->ThumbActive = TRUE;
+#ifdef DEBUG_SCROLL
+ printf("THUMB DOWN !\n");
+#endif
+ }
+ }
+ if (lphs->ButtonDown != 0) {
+ UpdateWindow(lphs->hWndOwner);
+ if (!lphs->TimerPending && nBar == SB_CTL) {
+ lphs->TimerPending = TRUE;
+ SetTimer(lphs->hWndOwner, 1, 500, NULL);
+ }
+ }
+}
+
+
+void ScrollBarButtonUp(HWND hWnd, int nBar, int x, int y)
+{
+ LPHEADSCROLL lphs;
+ RECT rect, rect2;
+ printf("ScrollBarButtonUp // x=%d y=%d\n", x, y);
+#ifdef DEBUG_SCROLL
+ printf("ScrollBarButtonUp // x=%d y=%d\n", x, y);
+#endif
+ lphs = GetScrollObjectHandle(hWnd, nBar);
+ lphs->ThumbActive = FALSE;
+ if (lphs->ButtonDown != 0) {
+ lphs->ButtonDown = 0;
+ GetClientRect(lphs->hWndOwner, &rect);
+ InvalidateRect(lphs->hWndOwner, &rect, TRUE);
+ UpdateWindow(lphs->hWndOwner);
+ }
+}
+
+
+void ScrollBarMouseMove(HWND hWnd, int nBar, WORD wParam, int x, int y)
+{
+ LPHEADSCROLL lphs;
+ HWND hWndParent;
+ HWND hWndOwner;
+ LONG dwOwner;
+ if ((wParam & MK_LBUTTON) == 0) return;
+#ifdef DEBUG_SCROLL
+ printf("ScrollBarButtonMove // w=%04X x=%d y=%d \n", wParam, x, y);
+#endif
+ lphs = GetScrollObjectHandle(hWnd, nBar);
+ if (lphs->ThumbActive == 0) return;
+ if (nBar == SB_CTL) {
+ hWndParent = GetParent(hWnd);
+ hWndOwner = lphs->hWndOwner;
+ }
+ else {
+ hWndParent = hWnd;
+ hWndOwner = 0;
+ }
+ if (lphs->Direction == WM_VSCROLL) {
+ int butsiz = lphs->rect.right - lphs->rect.left;
+ y = y - butsiz - (butsiz >> 1);
+ }
+ else {
+ int butsiz = lphs->rect.bottom - lphs->rect.top;
+ y = x - butsiz - (butsiz >> 1);
+ }
+ x = (y * (lphs->MaxVal - lphs->MinVal) /
+ lphs->MaxPix) + lphs->MinVal;
+#ifdef DEBUG_SCROLL
+ printf("Scroll WM_MOUSEMOVE val=%d pix=%d\n", x, y);
+#endif
+ SendMessage(hWndParent, lphs->Direction,
+ SB_THUMBTRACK, MAKELONG(x, hWndOwner));
+}
+
+
+LPHEADSCROLL ScrollBarGetWindowAndStorage(HWND hWnd, WND **wndPtr)
{
WND *Ptr;
LPHEADSCROLL lphs;
- *(wndPtr) = Ptr = WIN_FindWndPtr(hwnd);
+ *(wndPtr) = Ptr = WIN_FindWndPtr(hWnd);
if (Ptr == 0) {
printf("Bad Window handle on ScrollBar !\n");
return 0;
@@ -276,11 +356,11 @@
}
-LPHEADSCROLL ScrollBarGetStorageHeader(HWND hwnd)
+LPHEADSCROLL ScrollBarGetStorageHeader(HWND hWnd)
{
WND *wndPtr;
LPHEADSCROLL lphs;
- wndPtr = WIN_FindWndPtr(hwnd);
+ wndPtr = WIN_FindWndPtr(hWnd);
if (wndPtr == 0) {
printf("Bad Window handle on ScrollBar !\n");
return 0;
@@ -290,106 +370,138 @@
}
-void StdDrawScrollBar(HWND hwnd)
+void StdDrawScrollBar(HWND hWnd, HDC hDC, int nBar, LPRECT lprect, LPHEADSCROLL lphs)
{
- LPHEADSCROLL lphs;
- PAINTSTRUCT ps;
- HBRUSH hBrush;
- HDC hdc;
- RECT rect;
- UINT i, w, h, siz;
+ HWND hWndParent;
+ HBRUSH hBrush;
+ HDC hMemDC;
+ BITMAP bm;
+ 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 (lphs == NULL) return;
+#ifdef DEBUG_SCROLL
+ if (lphs->Direction == WM_VSCROLL)
+ printf("StdDrawScrollBar Vertical left=%d top=%d right=%d bottom=%d !\n",
+ lprect->left, lprect->top, lprect->right, lprect->bottom);
+ else
+ printf("StdDrawScrollBar Horizontal left=%d top=%d right=%d bottom=%d !\n",
+ lprect->left, lprect->top, lprect->right, lprect->bottom);
+#endif
+ if (nBar == SB_CTL)
+ hWndParent = GetParent(hWnd);
+ else
+ hWndParent = lphs->hWndOwner;
+ hBrush = SendMessage(hWndParent, 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);
+ CopyRect(&lphs->rect, lprect);
+ CopyRect(&rect, lprect);
w = rect.right - rect.left;
h = rect.bottom - rect.top;
+ hMemDC = CreateCompatibleDC(hDC);
if (lphs->Direction == WM_VSCROLL) {
+ GetObject(hUpArrow, sizeof(BITMAP), (LPSTR)&bm);
+ if (lphs->ButtonDown == 1)
+ SelectObject(hMemDC, hUpArrowD);
+ else
+ SelectObject(hMemDC, hUpArrow);
+ BitBlt(hDC, rect.left, rect.top,
+ bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
+/*
+ StretchBlt(hDC, 0, 0, lpdis->rcItem.right, lpdis->rcItem.right,
+ hMemDC, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
+*/
+ GetObject(hDnArrow, sizeof(BITMAP), (LPSTR)&bm);
+ if (lphs->ButtonDown == 2)
+ SelectObject(hMemDC, hDnArrowD);
+ else
+ SelectObject(hMemDC, hDnArrow);
+ BitBlt(hDC, rect.left, rect.bottom - bm.bmHeight,
+ bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
rect.top += w;
rect.bottom -= w;
}
else {
+ GetObject(hLfArrow, sizeof(BITMAP), (LPSTR)&bm);
+ if (lphs->ButtonDown == 3)
+ SelectObject(hMemDC, hLfArrowD);
+ else
+ SelectObject(hMemDC, hLfArrow);
+ BitBlt(hDC, rect.left, rect.top,
+ bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
+ GetObject(hRgArrow, sizeof(BITMAP), (LPSTR)&bm);
+ if (lphs->ButtonDown == 4)
+ SelectObject(hMemDC, hRgArrowD);
+ else
+ SelectObject(hMemDC, hRgArrow);
+ BitBlt(hDC, rect.right - bm.bmWidth, rect.top,
+ bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
rect.left += h;
rect.right -= h;
}
- FillRect(hdc, &rect, hBrush);
+ DeleteDC(hMemDC);
+ FillRect(hDC, &rect, hBrush);
if (lphs->Direction == WM_VSCROLL)
- SetRect(&rect, 0, lphs->CurPix + w, w, lphs->CurPix + (w << 1));
+ SetRect(&rect, rect.left, rect.top + lphs->CurPix,
+ rect.left + w, rect.top + lphs->CurPix + w);
else
- SetRect(&rect, lphs->CurPix + h, 0, lphs->CurPix + (h << 1), h);
- FrameRect(hdc, &rect, GetStockObject(BLACK_BRUSH));
+ SetRect(&rect, rect.left + lphs->CurPix, rect.top,
+ rect.left + lphs->CurPix + h, rect.top + h);
+/*
+ if (lphs->Direction == WM_VSCROLL)
+ SetRect(&rect, rect.left, rect.top + lphs->CurPix + w,
+ rect.left + w, rect.top + lphs->CurPix + (w << 1));
+ else
+ SetRect(&rect, rect.left + lphs->CurPix + h, rect.top,
+ rect.left + lphs->CurPix + (h << 1), rect.top + h);
+*/
+ FrameRect(hDC, &rect, GetStockObject(BLACK_BRUSH));
InflateRect(&rect, -1, -1);
- FillRect(hdc, &rect, GetStockObject(LTGRAY_BRUSH));
- DrawReliefRect(hdc, rect, 2, 0);
+ 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 );
+ DrawReliefRect(hDC, rect, 1, 1);
}
-int CreateScrollBarStruct(HWND hwnd)
+int CreateScrollBarStruct(HWND hWnd)
{
RECT rect;
int width, height;
WND *wndPtr;
LPHEADSCROLL lphs;
- wndPtr = WIN_FindWndPtr(hwnd);
+ 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->hWndOwner = hWnd;
lphs->ThumbActive = FALSE;
+ lphs->TimerPending = FALSE;
+ lphs->ButtonDown = 0;
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;
+ CopyRect(&lphs->rect, &wndPtr->rectClient);
if (width <= height)
{
lphs->MaxPix = height - 3 * width;
lphs->Direction = WM_VSCROLL;
- lphs->hWndUp = CreateWindow("BUTTON", "",
- WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,
- 0, 0, width, width, hwnd, 1, wndPtr->hInstance, 0L);
- lphs->hWndDown = CreateWindow("BUTTON", "",
- WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,
- 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_OWNERDRAW,
- 0, 0, height, height, hwnd, 3, wndPtr->hInstance, 0L);
- lphs->hWndDown = CreateWindow("BUTTON", "",
- WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,
- width - height, 0, height, height, hwnd, 4,
- wndPtr->hInstance, 0L);
}
if (lphs->MaxPix < 1) lphs->MaxPix = 1;
if (wndPtr->hCursor == (HCURSOR)NULL)
@@ -398,31 +510,90 @@
}
+
+LPHEADSCROLL AllocScrollBar(DWORD dwStyle, int width, int height)
+{
+ LPHEADSCROLL lphs;
+ lphs = (LPHEADSCROLL)malloc(sizeof(HEADSCROLL));
+ if (lphs == 0) {
+ printf("Bad Memory Alloc on ScrollBar !\n");
+ return NULL;
+ }
+ lphs->ThumbActive = FALSE;
+ lphs->TimerPending = FALSE;
+ lphs->ButtonDown = 0;
+ lphs->MinVal = 0;
+ lphs->MaxVal = 100;
+ lphs->CurVal = 0;
+ lphs->CurPix = 0;
+ if (dwStyle & WS_VSCROLL) {
+ lphs->MaxPix = height - 3 * width;
+ lphs->Direction = WM_VSCROLL;
+ }
+ else {
+ lphs->MaxPix = width - 3 * height;
+ lphs->Direction = WM_HSCROLL;
+ }
+ if (lphs->MaxPix < 1) lphs->MaxPix = 1;
+ return lphs;
+}
+
+
+void NC_CreateScrollBars(HWND hWnd)
+{
+ RECT rect;
+ int width, height;
+ WND *wndPtr;
+ LPHEADSCROLL lphs;
+ wndPtr = WIN_FindWndPtr(hWnd);
+ width = wndPtr->rectClient.right - wndPtr->rectClient.left;
+ height = wndPtr->rectClient.bottom - wndPtr->rectClient.top;
+ if (wndPtr->dwStyle & WS_VSCROLL) {
+ if (wndPtr->dwStyle & WS_HSCROLL) height -= SYSMETRICS_CYHSCROLL;
+ lphs = AllocScrollBar(WS_VSCROLL, SYSMETRICS_CXVSCROLL, height);
+#ifdef DEBUG_SCROLL
+ printf("NC_CreateScrollBars Vertical %lX !\n", lphs);
+#endif
+ lphs->hWndOwner = hWnd;
+ wndPtr->VScroll = lphs;
+ }
+ if (wndPtr->dwStyle & WS_HSCROLL) {
+ if (wndPtr->dwStyle & WS_VSCROLL) width -= SYSMETRICS_CYVSCROLL;
+ lphs = AllocScrollBar(WS_HSCROLL, width, SYSMETRICS_CYHSCROLL);
+#ifdef DEBUG_SCROLL
+ printf("NC_CreateScrollBars Horizontal %lX !\n", lphs);
+#endif
+ lphs->hWndOwner = hWnd;
+ wndPtr->HScroll = lphs;
+ }
+}
+
+
/*************************************************************************
- * GetScrollWindowHandle
+ * GetScrollObjectHandle
*/
-HWND GetScrollWindowHandle(HWND hWnd, int nBar)
+LPHEADSCROLL GetScrollObjectHandle(HWND hWnd, int nBar)
{
WND *wndPtr;
+ LPHEADSCROLL lphs;
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;
+ wndPtr = WIN_FindWndPtr(hWnd);
+ if (nBar == SB_VERT) return (LPHEADSCROLL)wndPtr->VScroll;
+ if (nBar == SB_HORZ) return (LPHEADSCROLL)wndPtr->HScroll;
+ return NULL;
}
- return hWnd;
+ return ScrollBarGetStorageHeader(hWnd);
}
/*************************************************************************
* SetScrollPos [USER.62]
*/
-int SetScrollPos(HWND hwnd, int nBar, int nPos, BOOL bRedraw)
+int SetScrollPos(HWND hWnd, int nBar, int nPos, BOOL bRedraw)
{
int nRet;
LPHEADSCROLL lphs;
- hwnd = GetScrollWindowHandle(hwnd, nBar);
- lphs = ScrollBarGetStorageHeader(hwnd);
+ lphs = GetScrollObjectHandle(hWnd, nBar);
if (lphs == NULL) return 0;
nRet = lphs->CurVal;
lphs->CurVal = (short)nPos;
@@ -436,9 +607,9 @@
printf("SetScrollPos min=%d max=%d\n",
lphs->MinVal, lphs->MaxVal);
#endif
- if ((bRedraw) && (IsWindowVisible(hwnd))) {
- InvalidateRect(hwnd, NULL, TRUE);
- UpdateWindow(hwnd);
+ if ((bRedraw) && (IsWindowVisible(lphs->hWndOwner))) {
+ InvalidateRect(lphs->hWndOwner, &lphs->rect, TRUE);
+ UpdateWindow(lphs->hWndOwner);
}
return nRet;
}
@@ -448,11 +619,10 @@
/*************************************************************************
* GetScrollPos [USER.63]
*/
-int GetScrollPos(HWND hwnd, int nBar)
+int GetScrollPos(HWND hWnd, int nBar)
{
LPHEADSCROLL lphs;
- hwnd = GetScrollWindowHandle(hwnd, nBar);
- lphs = ScrollBarGetStorageHeader(hwnd);
+ lphs = GetScrollObjectHandle(hWnd, nBar);
if (lphs == NULL) return 0;
return lphs->CurVal;
}
@@ -462,11 +632,10 @@
/*************************************************************************
* SetScrollRange [USER.64]
*/
-void SetScrollRange(HWND hwnd, int nBar, int MinPos, int MaxPos, BOOL bRedraw)
+void SetScrollRange(HWND hWnd, int nBar, int MinPos, int MaxPos, BOOL bRedraw)
{
LPHEADSCROLL lphs;
- hwnd = GetScrollWindowHandle(hwnd, nBar);
- lphs = ScrollBarGetStorageHeader(hwnd);
+ lphs = GetScrollObjectHandle(hWnd, nBar);
if (lphs == NULL) return;
lphs->MinVal = (short)MinPos;
lphs->MaxVal = (short)MaxPos;
@@ -478,9 +647,9 @@
#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);
+ if ((bRedraw) && (IsWindowVisible(lphs->hWndOwner))) {
+ InvalidateRect(lphs->hWndOwner, &lphs->rect, TRUE);
+ UpdateWindow(lphs->hWndOwner);
}
}
@@ -489,11 +658,10 @@
/*************************************************************************
* GetScrollRange [USER.65]
*/
-void GetScrollRange(HWND hwnd, int nBar, LPINT lpMin, LPINT lpMax)
+void GetScrollRange(HWND hWnd, int nBar, LPINT lpMin, LPINT lpMax)
{
LPHEADSCROLL lphs;
- hwnd = GetScrollWindowHandle(hwnd, nBar);
- lphs = ScrollBarGetStorageHeader(hwnd);
+ lphs = GetScrollObjectHandle(hWnd, nBar);
if (lphs == NULL) return;
*lpMin = lphs->MinVal;
*lpMax = lphs->MaxVal;
@@ -519,16 +687,20 @@
}
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);
+*/
}
}