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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:51:00+00:00 2026-05-14T01:51:00+00:00

I have created a simple win 32 application..in which it has a textbox and

  • 0

I have created a simple win 32 application..in which it has a textbox and a button in a dialog window..first when I created this..it didnt display the dialog window and then what I did is added the code below to handle the close(WM_CLOSE) of the dialog window…but I want to know, how to handle the button click event..

  void ValidatePassword(CString encryptedPassword)
{
    //create password dialog window
    CreateEvent(NULL,true,false,L"TestEvent");
    MSG msg;
    HWND hwnd = CreateWindowEx(0,WC_DIALOG,L"Security Alert",WS_OVERLAPPEDWINDOW|WS_VISIBLE,
                    600,300,300,200,NULL,NULL,NULL,NULL);

    //create label
    CreateWindowEx(NULL,L"Static",L"Requires Password to Run the File:", WS_CHILD|WS_VISIBLE,
                    10,25,300,20,hwnd,(HMENU)label_id,NULL,NULL);

    //create textboxcontrol within the dialog
    CreateWindowEx(WS_EX_CLIENTEDGE,L"EDIT",L"",WS_CHILD|WS_VISIBLE | ES_PASSWORD,
                    10,50,125,25,hwnd,(HMENU)textbox_id,NULL,NULL);
    //create button
    HWND button = CreateWindowEx(WS_EX_CLIENTEDGE,L"Button",L"OK",WS_CHILD|WS_VISIBLE,
                    10,100,100,25,hwnd,(HMENU)button_id,NULL,NULL);

    ShowWindow (hwnd, SW_SHOW);
    UpdateWindow(hwnd);
    //SetWindowLong(button,DWL_DLGPROC, (long)myProc);

    while(GetMessage(&msg,NULL,0,0))
    {

        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }




}

LRESULT WINAPI myProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{


    HWND hwndButton;
    switch (message)
    { 
        /* Handles all Windows Messages */
        case WM_COMMAND:

            {
              if(((HWND)lParam) && (HIWORD(wParam) == BN_CLICKED))
              {
                int iMID;
                iMID = LOWORD(wParam);
                switch(iMID)
                {
                  case button_id:
                      {
                       MessageBox(hwnd, (LPCTSTR)"You just pushed me!",  (LPCTSTR) "My Program!", MB_OK|MB_ICONEXCLAMATION);
                       break;
                       }
                  default:
                       break;
                }
              }
              break;
            }
        case WM_DESTROY:
            {
              PostQuitMessage (0);       /* send a WM_QUIT to Message Queue, to shut off program */
              break;
             }
    }

    return 0; 
}
  • 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-14T01:51:00+00:00Added an answer on May 14, 2026 at 1:51 am

    Yikes.

    It should not be necessary to call SetWindowLong to set the dialog proc for a dialog. Your “simple” program should look something like

    #include <windows.h>
    #include "resource.h"
    
    BOOL CALLBACK myProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
      switch(uMsg)
      {
      case WM_INITDIALOG:
        return TRUE;
      case WM_COMMAND:
        if( LOWORD(wParam) == IDCLOSE) // close button click
          EndDialog(hwnd,0);
        return TRUE;
      }
      return FALSE;
    }
    
    int CALLBACK WinMain(HINSTANCE hExe,HINSTANCE,LPCSTR,INT)
    {
      return DialogBox(hExe,MAKEINTRESOURCE(IDD_DIALOG),NULL,myProc);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 376k
  • Answers 376k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer use updateprogress of tool kit :hope this will help you… May 14, 2026 at 8:41 pm
  • Editorial Team
    Editorial Team added an answer If you take the example of map :: (a ->… May 14, 2026 at 8:40 pm
  • Editorial Team
    Editorial Team added an answer The "family" argument and the corresponding rc parameter are not… May 14, 2026 at 8:40 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.