diff src/scrollbar-msw.c @ 546:666d73d6ac56

[xemacs-hg @ 2001-05-20 01:17:07 by ben] fixes so MinGW compiles. console-msw.h, scrollbar-msw.c, event-msw.c: we might receive scrollbar events on windows without scrollbars (e.g. holding down and moving the wheel button). dired.c: win9x support. eval.c: doc comment about gcpro'ing in record_unwind_protect. frame-msw.c: typo. frame.c: avoid problems with errors during init_frame_3. process-nt.c: remove unused mswindows-quote-process-args. rec for 21.4. unexcw.c: use do/while. autoload.el: Oops, off by one argument. mouse.el: Add an argument to mouse-track so that hooks can be overridden. (let-binding doesn't work when the hooks have been made local.) modify mouse-track-run-hook accordingly, and fix mouse-track-default and mouse-track-insert to use the new functionality. printer.el: Oops, off by one paren.
author ben
date Sun, 20 May 2001 01:17:16 +0000
parents 54fa1a5c2d12
children 38db05db9cb5
line wrap: on
line diff
--- a/src/scrollbar-msw.c	Fri May 18 04:39:44 2001 +0000
+++ b/src/scrollbar-msw.c	Sun May 20 01:17:16 2001 +0000
@@ -56,25 +56,26 @@
     orientation = SBS_HORZ;
 
   SCROLLBAR_MSW_HANDLE (sb) =
-    CreateWindowEx(0, "SCROLLBAR", 0, orientation|WS_CHILD,
-		 CW_USEDEFAULT, CW_USEDEFAULT,
-		 CW_USEDEFAULT, CW_USEDEFAULT,
-		 FRAME_MSWINDOWS_HANDLE (f),
-		 NULL, NULL, NULL);
-  SCROLLBAR_MSW_INFO (sb).cbSize = sizeof(SCROLLINFO);
+    CreateWindowEx (0, "SCROLLBAR", 0, orientation|WS_CHILD,
+		    CW_USEDEFAULT, CW_USEDEFAULT,
+		    CW_USEDEFAULT, CW_USEDEFAULT,
+		    FRAME_MSWINDOWS_HANDLE (f),
+		    NULL, NULL, NULL);
+  SCROLLBAR_MSW_INFO (sb).cbSize = sizeof (SCROLLINFO);
   SCROLLBAR_MSW_INFO (sb).fMask = SIF_ALL;
   GetScrollInfo(SCROLLBAR_MSW_HANDLE (sb), SB_CTL,
 		&SCROLLBAR_MSW_INFO (sb));
-  SetWindowLong (SCROLLBAR_MSW_HANDLE(sb), GWL_USERDATA, (LONG)sb);
+  SetWindowLong (SCROLLBAR_MSW_HANDLE (sb), GWL_USERDATA, (LONG) sb);
 
 #if 0
   {
-	  HWND h = SCROLLBAR_MSW_HANDLE (sb);
-	  int x = SetWindowLong (SCROLLBAR_MSW_HANDLE(sb), GWL_USERDATA, (LONG)sb);
-	  int y = GetLastError();
-	  struct scrollbar_instance *z = (struct scrollbar_instance *)GetWindowLong (SCROLLBAR_MSW_HANDLE(sb),
-		  GWL_USERDATA);
-	  *z = *z;
+    HWND h = SCROLLBAR_MSW_HANDLE (sb);
+    int x = SetWindowLong (SCROLLBAR_MSW_HANDLE(sb), GWL_USERDATA, (LONG)sb);
+    int y = GetLastError();
+    struct scrollbar_instance *z =
+      (struct scrollbar_instance *)GetWindowLong (SCROLLBAR_MSW_HANDLE(sb),
+						  GWL_USERDATA);
+    *z = *z;
   }
 #endif
 }
@@ -180,10 +181,19 @@
   int vert = GetWindowLong (hwnd, GWL_STYLE) & SBS_VERT;
   int value;
 
-  sb = (struct scrollbar_instance *)GetWindowLong (hwnd, GWL_USERDATA);
-  win = real_window (sb->mirror, 1);
-  frame = XWINDOW (win)->frame;
-  f = XFRAME (frame);
+  sb = (struct scrollbar_instance *) GetWindowLong (hwnd, GWL_USERDATA);
+  if (!sb)
+    {
+      frame = mswindows_find_frame (hwnd);
+      f = XFRAME (frame);
+      win = FRAME_SELECTED_WINDOW (f);
+    }
+  else
+    {
+      win = real_window (sb->mirror, 0);
+      frame = XWINDOW (win)->frame;
+      f = XFRAME (frame);
+    }
 
   /* SB_LINEDOWN == SB_CHARLEFT etc. This is the way they will
      always be - any Windows is binary compatible backward with
@@ -255,7 +265,7 @@
 
     case SB_ENDSCROLL:
 #ifdef VERTICAL_SCROLLBAR_DRAG_HACK
-      if (vertical_drag_in_progress)
+      if (vertical_drag_in_progress && sb)
 	/* User has just dropped the thumb - finally update it */
 	SetScrollInfo (SCROLLBAR_MSW_HANDLE (sb), SB_CTL,
 		       &SCROLLBAR_MSW_INFO (sb), TRUE);