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 6008395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:49:05+00:00 2026-05-23T01:49:05+00:00

Language: Visual C++, MFC Environment: Visual Studio 2005 I have a dialog that requires

  • 0

Language: Visual C++, MFC

Environment: Visual Studio 2005

I have a dialog that requires the user to set file paths for six different settings. Each text box has a browse button which launches a file browser.

How can I set it up so that all of the browse buttons all call the same function to launch the chooser, then use a switch to determine which button invoked the file chooser so that I can set the text of the appropriate CEdit box with the path? // run-on sentence, hah

I’m sure I’ll have to use GetDlgCtrlID, I’m just not sure how.

Thank you for your help in advance!

~ Jon

EDIT: Here’s the code I have now…very simple because I’m just getting it to work for now.

BEGIN_MESSAGE_MAP(FSC_3DPersp, CSAPrefsSubDlg)
//{{AFX_MSG_MAP(FSC_3DPersp)
    // NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
ON_COMMAND(BN_CLICKED, &FSC_3DPersp::Browse)
 END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

// FSC_3DPersp message handlers

void FSC_3DPersp::Browse(UINT uiID)
{
// TODO: Add your control notification handler code here

switch(uiID)
{
case IDC_BUTTON1: 
    MessageBox("1");
    break;
case IDC_BUTTON2:
    MessageBox("2");
    break;
case IDC_BUTTON3:
    MessageBox("3");
    break;
case IDC_BUTTON4:
    MessageBox("4");
    break;
case IDC_BUTTON5:
    MessageBox("5");
    break;
case IDC_BUTTON6:
    MessageBox("6");
    break;
case IDC_BUTTON7:
    MessageBox("7");
    break;
}
}

BOOL FSC_3DPersp::OnCommand(WPARAM wParam, LPARAM lParam)
{
if (HIWORD(wParam) == BN_CLICKED)
{
    Browse(LOWORD(wParam));
    return TRUE;
}
return CWnd::OnCommand(wParam, lParam);
}
  • 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-23T01:49:06+00:00Added an answer on May 23, 2026 at 1:49 am

    If you’re responding to the BN_CLICKED message, the button ID will be contained in the LOWORD of the wparam of the message.

    Edit: MFC normally discards the wparam of the message. To access it you must override the OnCommand handler in your dialog.

    BOOL CMyDialog::OnCommand(WPARAM wParam, LPARAM lParam)
    {
        if (HIWORD(wParam) == BN_CLICKED)
        {
            Browse(LOWORD(wParam));
            return TRUE;
        }
        return CWnd::OnCommand(wParam, lParam);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

IDE: Microsoft Visual Studio Professional 2008 Language: C# Background: I have one form and
I'm working on Visual Studio Extensibility and I need to set the shell language
I have a Visual studio C# project and I have an installer that installs
I'm currently working on a C++ MFC project on visual studio 2003. The aim
I have a window application in visual c++. I am not using MFC I
I am using Visual Studio 2010 and suppose I have to write some program.
I've written a new Visual Studio language service for my software studio's internal scripting
I'm trying to figure out how to get mixed-language support working in Visual Studio
I am working in Visual Studio 2008 and have a Windows Forms project +
I have a Visual Studio C# .NET project. I have two master templates. One

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.