Problem with window messaging system vc++

Joined
Nov 24, 2022
Messages
80
Reaction score
7
Hi.
Have a small problem when I want to hide edit window when I'm pressing enter button
What I'm doing wrong.
Everything runs before switch() expression.

All I want is on dblclick mouse on listbox element, move edit3 window (at the bottom of picture) to the position of listbox selected element and to be shown. Then write sth into it, press eneter ,copy value to listbox (replace current element) and hide this edit3 window.
```
// hWndList - handle to a ListBox window

if ((HWND)lParam == hWndList) {
if (message == (INT)WM_LBUTTONUP | (INT)WM_COMMAND) { /* works correctly */ }

// the one below works always (makes beeep every time) and I want it to be run only when I make double click on this listbox window
if ((HWND)lParam == hWndList) {
if (message == (INT)WM_LBUTTONDBLCLK | (INT)WM_COMMAND) { MessageBeep(1); } }

// here I expect to hide edit window when I press enter button
if ((HWND)lParam == hEdit3 ) {
if (wParam == IDOK) { ShowWindow(hEdit3,SW_HIDE);} }

// this one never runs
if ((HWND)lParam == hEdit3 ) {
if(message == WM_LBUTTONDOWN){ }}
 

Attachments

  • 111111a.jpg
    111111a.jpg
    24.7 KB · Views: 8
Joined
Jan 30, 2023
Messages
107
Reaction score
13
It looks like your problem is that the code block for hiding the edit window (hEdit3) is not being executed because the message value is not equal to WM_LBUTTONDOWN.

The message value is what determines what action the window procedure should take. The WM_LBUTTONDOWN message is sent when the left mouse button is pressed while the mouse pointer is within the client area of a window. It appears that you want to hide the edit window when the "OK" button is pressed, in which case the message you want to check for is WM_COMMAND, not WM_LBUTTONDOWN.

Try changing the following

SCSS:
if(message == WM_LBUTTONDOWN){ }

SCSS:
if(message == WM_COMMAND && wParam == IDOK) {
  ShowWindow(hEdit3,SW_HIDE);
}

This should be Ok
 
Joined
Nov 24, 2022
Messages
80
Reaction score
7
No it doesn't work.
Code:
if ((HWND)lParam == hEdit3) {

        if (message == WM_COMMAND && wParam == IDOK) {

            ShowWindow(hEdit3, SW_HIDE);

        }

    }
Shouldn't be HIWORD(wParam) ?
And something with notify option?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,787
Messages
2,569,630
Members
45,335
Latest member
Tommiesal

Latest Threads

Top