Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Scrollbar movement Notification:

Scrollbar movement Notification:

Scheduled Pinned Locked Moved C#
helpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sudhakar Pasupunuri
    wrote on last edited by
    #1

    Hi.. I have a specification sheet which has a horizontal scrool bar.. I would like to know what is the windows notify message sent when i move the horizontal scroll bar. I tried WM_HSCROLL but it was not working for me.. Can any one help me in this reg. Thanks Sudhakar

    H 1 Reply Last reply
    0
    • S Sudhakar Pasupunuri

      Hi.. I have a specification sheet which has a horizontal scrool bar.. I would like to know what is the windows notify message sent when i move the horizontal scroll bar. I tried WM_HSCROLL but it was not working for me.. Can any one help me in this reg. Thanks Sudhakar

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Make sure WM_HSCROLL and WM_VSCROLL are defined correctly, as in this example:

      using System;
      using System.Drawing;
      using System.Windows.Forms;
       
      class Test : Form
      {
      static void Main()
      {
      Application.Run(new Test());
      }
       
      Label lbl;
       
      Test()
      {
      Text = "Sample";
      AutoScroll = true;
       
      lbl = new Label();
      Controls.Add(lbl);
      lbl.Location = new Point(0, 0);
      lbl.Size = Size + Size;
      lbl.TextAlign = ContentAlignment.MiddleCenter;
      }
       
      protected override void OnResize(EventArgs e)
      {
      lbl.Size = Size + Size;
      base.OnResize(e);
      }
       
      const int WM_HSCROLL = 0x0114; // == 276
      const int WM_VSCROLL = 0x0115; // == 277
       
      protected override void WndProc(ref Message m)
      {
      if (m.Msg == WM_HSCROLL)
      {
      lbl.Text = string.Format("HPos: {0}", HIWORD((int)m.WParam));
      }
       
      if (m.Msg == WM_VSCROLL)
      {
      lbl.Text = string.Format("VPos: {0}", HIWORD((int)m.WParam));
      }
       
      base.WndProc(ref m);
      }
       
      int HIWORD(int dword)
      {
      return dword >> 16;
      }
      }

      (Scroll to the center and watch the values change) You can also use the AutoScrollPosition for a ScrollableControl derivative, which includes (but is not limited to) Panel, UserControl, and Form. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups