Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to handle click event in win32 API?
    primarykey
    data
    text
    <p>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..</p> <pre><code> 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(&amp;msg,NULL,0,0)) { TranslateMessage(&amp;msg); DispatchMessage(&amp;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) &amp;&amp; (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; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload