Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6476083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:46:55+00:00 2026-05-25T06:46:55+00:00

I am writing a C++ MFC Dialog based Application and my program has lots

  • 0

I am writing a C++ MFC Dialog based Application and my program has lots of sliders. I want the program to call a function depending on which Slider is being changed by the user. I tried using GetPos() but not much success so far. Any easier way of doing this?

Message Map:

BEGIN_MESSAGE_MAP(CSerialPortDlg, CDialog)
    ON_WM_SYSCOMMAND()
    ON_WM_PAINT()
    ON_WM_QUERYDRAGICON()
    //}}AFX_MSG_MAP
    //ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
    ON_BN_CLICKED(IDC_READ_COMM, OnBnClickedReadComm)
    ON_WM_CLOSE()
    ON_BN_CLICKED(IDC_WRITE, OnBnClickedWrite)
    //ON_CBN_SELCHANGE(IDC_SENSORS, OnCbnSelchangeSensors)
    //ON_CBN_SELCHANGE(IDC_SENSOR_LIST, OnCbnSelchangeSensorList)
    ON_BN_CLICKED(IDC_GO, OnGo)
    ON_WM_TIMER()
    ON_BN_CLICKED(IDC_KILL_TIMER, OnBnClickedKillTimer)
    ON_BN_CLICKED(IDC_READ_TIMER, OnBnClickedReadTimer)
    ON_BN_CLICKED(IDC_WRITE_COMM, OnBnClickedWriteComm)
    ON_BN_CLICKED(IDC_TERMINATE, OnBnClickedTerminate)
    ON_BN_CLICKED(IDC_RUN, OnBnClickedRun)
    ON_CONTROL(NM_CLICK,IDC_BOOM_SLIDER, Write_Boom)
    ON_CONTROL(NM_CLICK,IDC_PITCH_SLIDER, Write_Pitch)
END_MESSAGE_MAP()

…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:46:56+00:00Added an answer on May 25, 2026 at 6:46 am

    Slider controls send WM_HSCROLL or WM_VSCROLL notifications when they are scrolled, horizontally or vertically. Catch them in your dialog and there you can call your desired function, depending on who sent the notification.

    BEGIN_MESSAGE_MAP(CMyDlg, CDialog)  
        //...  
        ON_WM_HSCROLL()  
        //...   
    END_MESSAGE_MAP()  
    
    
    //////////////////////////
    // nSBCode: The operation performed on the slider  
    // nPos: New position of the slider  
    // pScrollBar: The scrollbar (slider ctrl in this case) that sent the notification  
    
    void CMyDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)  
    {  
        CSliderCtrl* pSlider = reinterpret_cast<CSliderCtrl*>(pScrollBar);  
    
        // Check which slider sent the notification  
        if (pSlider == &c_Slider1)  
        {  
        }
        else if (pSlider == &c_Slider2)  
        {  
        }  
    
        // Check what happened  
        switch(nSBCode)
        {
        case TB_LINEUP:  
        case TB_LINEDOWN:  
        case TB_PAGEUP:  
        case TB_PAGEDOWN:  
        case TB_THUMBPOSITION:  
        case TB_TOP:  
        case TB_BOTTOM:  
        case TB_THUMBTRACK:  
        case TB_ENDTRACK:  
        default:  
            break;  
        }
    
    //...  
    }  
    `
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an MFC C++ application that has a Save As button for
I have an MFC-driven dialog-based application created with MSVS2005. Here is my problem step
OK, so we're writing our MFC application to make use of the built-in localization
I'm writing a complex setup/installer application in native C++/MFC. I would very much like
I'm writing a Win32 application using plain C and WinAPI. No MFC or C++
I am writing an MFC application that doesn't use .NET (CLR support is set
I am writing a C++/MFC application that will use Microsoft Access to store data.
I am writing a wrapper class to call _CrtDumpMemoryLeaks() in WPF application. I am
Writing a dictionary application for android. Want to set translation direction in accord with
Now i am writing a MFC program with opengl in it. And when i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.