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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:28:14+00:00 2026-05-20T06:28:14+00:00

I have recently begun learning the Win32 API using this tutorial: http://www.winprog.org/tutorial/ (though I’m

  • 0

I have recently begun learning the Win32 API using this tutorial:

http://www.winprog.org/tutorial/ (though I’m using C++, not C as in the tutorial)
I’m currently experimenting with the “edit box”-function where I’m trying to compare the text written in the edit box with another line of characters.
Code:

#define IDC_MAIN_EDIT   101

Code:

case WM_CREATE:
{
    HFONT hfDefault;
    HWND hEdit;

    hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", 
        WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL, 
        0, 0, 100, 100, hwnd, (HMENU)IDC_MAIN_EDIT, GetModuleHandle(NULL), NULL);
    if(hEdit == NULL)
        MessageBox(hwnd, "Could not create edit box.", "Error", MB_OK | MB_ICONERROR);

    hfDefault = GetStockObject(DEFAULT_GUI_FONT);
    SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
}
break;
case WM_SIZE:
{
    HWND hEdit;
    RECT rcClient;

    GetClientRect(hwnd, &rcClient);

    hEdit = GetDlgItem(hwnd, IDC_MAIN_EDIT);
    SetWindowPos(hEdit, NULL, 0, 0, rcClient.right, rcClient.bottom, SWP_NOZORDER);
}
break;

Code:

bool comparison (HWND hEdit) {
LPWSTR pszText;
DWORD dwTextLength;
DWORD dwBufferSize;

dwTextLength = GetWindowTextLength(hEdit);
dwBufferSize = dwTextLength + 1;

GetWindowText(hEdit, pszText, dwBufferSize);

if(pszText == TEXT("3")) {
    return true;
}
else {
    return false;
}
}

The problem when I call the “comparison”-function is that pszText and hEdit aren’t initialized. I get why pszText isn’t and I’ve tried using the new/delete to fix it, but I don’t get it to work. I have no clue about hEdit. Am I perhaps using the GetWindowText-function wrong?
Warnings
Code:

warning C4700: uninitialized local variable ‘pszText’ used
warning C4700: uninitialized local variable ‘hEdit’ used

Run-Time Check Failure (appear when I’m using the function, and this is just one of them)
Code:

Run-Time Check Failure #3 – The variable ‘hEdit’ is being used without being initializ

  • 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-20T06:28:15+00:00Added an answer on May 20, 2026 at 6:28 am

    Look into the very important concept of scope. refer this page http://www.cplusplus.com/doc/tutorial/variables/

    c++ Code:

      case WM_CREATE:
    
      {
    
              HFONT hfDefault;
    
              HWND hEdit;
    
    
    
              hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "",
    
                  WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL,
    
                  0, 0, 100, 100, hwnd, (HMENU)IDC_MAIN_EDIT, GetModuleHandle(NULL), NULL);
    
              if(hEdit == NULL)
    
                  MessageBox(hwnd, "Could not create edit box.", "Error", MB_OK | MB_ICONERROR);
    
    
    
              hfDefault = GetStockObject(DEFAULT_GUI_FONT);
    
              SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
    
          } 
    

    The variable hEdit only exists for the duration of the block in which it’s declared, which is within the {}s for the WM_CREATE case.

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

Sidebar

Related Questions

I've recently begun learning C# but have encountered an annoying problem. Every variable I
I have recently begun using Scala. I've written a DSL in it which can
I have recently begun writing unit tests (using GoogleTest ) for a C++ project.
I've recently begun a fairly small 2D project using SFML and TinyXML and have
I usually script/program using python but have recently begun programming with JavaScript and have
I have recently begun using coderush. One thing that annoys me is that the
I have recently begun the practice of using <%# Ruby on Rails comments %>
I've recently begun my journey of learning CSS, and have been studying Gmail's design,
I have recently begun delving into the world that is database programming with C++
I have recently begun working on a pre-existing PHP application, and am having a

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.