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

  • Home
  • SEARCH
  • 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 3597354
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:06:27+00:00 2026-05-18T20:06:27+00:00

In my main window, after clicking a menu item, a dialog box appears which

  • 0

In my main window, after clicking a menu item, a dialog box appears which asks the user for input. That input is then to be retrieved.

Here is the resource file for the dialog box:

//
// Dialog resources
//
IDD_PID DIALOG 0, 0, 158, 84
STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP
FONT 8, "MS Sans Serif"
{
    PUSHBUTTON  "&Ok", ID_PID_RET, 14, 60, 58, 14
    PUSHBUTTON  "&Cancel", ID_PID_CANCEL, 86, 60, 52, 14
    CTEXT       "Enter the PID of the process", -1, 32, 16, 91, 15, SS_CENTER
    CONTROL     "", ID_PID_INPUT, RICHEDIT_CLASS, WS_TABSTOP | WS_BORDER | ES_AUTOHSCROLL, 47, 33, 59, 14, WS_EX_CLIENTEDGE
}

Here is the WindowProc where the dialog is used:

//
// Message handling for main window
//
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch(message)
    {
    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
        case ID_FILE_PID:
            int choice = DialogBox(thishInstance, MAKEINTRESOURCE(IDD_PID), hWnd, AboutDlgProc);
            if (choice == ID_PID_RET)
            {
                HWND temp = GetDlgItem(hWnd, ID_PID_INPUT);
                HRESULT HR = GetLastError();
                SendMessage(temp, WM_GETTEXT, sizeof(buff), (LPARAM)&buff);

                [...]
            }
            break;
        }
    }
}

I am a little uncertain about how it works when I try to get the HWND if I create the windows in the resource files. This should work somehow, right? hWnd is managing the dialog box, and ID_PID_RET is the control ID of the Rich Edit box for user input, so I don’t know why GetDlgItem fails. It returns “Control ID not found”, but it is defined in my resource.h. Any ideas?

  • 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-18T20:06:27+00:00Added an answer on May 18, 2026 at 8:06 pm

    DialogBox only returns after EndDialog has been called and the dialog has been destroyed. The dialog no longer exists when you call GetDlgItem. You can use DialogBoxParam and pass in a buffer/struct/class for the dialog to fill in with the content of the Rich Edit field, before it calls EndDialog.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my main window, after clicking a menu item, a dialog box appears which
I have a main window which hosts two views (user controls). One is UserControl1
My main window has spawned a child window that's positioned on top to look
I have a main window (#1) on my webpage from which I open a
Background: My application has a main window which contains a few smaller NSView objects,
i have a mvvm app that the main window is a tab control. i
I've an application that holds a main window with a list of items, and
I want to create an application which main window has canvas (or something where
I have a Window1.xaml main Window; and after some event, I display a UserControl
I'v created a window after creating my main one but calling DestroyWindow on its

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.