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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:38:53+00:00 2026-05-24T16:38:53+00:00

I have a problem: I use SendMessage from a procedure in a DLL to

  • 0

I have a problem: I use SendMessage from a procedure in a DLL to communicate with the main window; procedure is a hook procedure that allows main window to know when mouse right button is clicked in a editbox; it sends also handle of the editbox. It works well, except for this bug: when program is running without breakpoints main window receives twice the same message (in this case WM_APP), while if I put a breakpoint in the hook procedure or in the block that handles WM_APP messages the message is considered once. For further descriptions ask me. Following the code of the hook procedure and of the block that handles WM_APP messages. Thanks

Hook procedure

MYDLL_API LRESULT CALLBACK mouseProc(int nCode, WPARAM wParam, LPARAM lParam)
{
// processes the message
if(nCode >= 0)
{
    // if user clicked with mouse right button
    if(wParam != NULL && (wParam == WM_RBUTTONDOWN || wParam == WM_RBUTTONUP))
    {
        wchar_t *s = (wchar_t*) malloc(CLASSNAMELEN*sizeof(wchar_t));
        //MessageBox(mainHwnd, (LPCWSTR)L"Captured mouse right button", (LPCWSTR)L"Test", MB_OK);
        MOUSEHOOKSTRUCT *m = (MOUSEHOOKSTRUCT*) lParam;
        GetClassName(m->hwnd, (LPWSTR) s, CLASSNAMELEN);
        //MessageBox(mainHwnd, (LPCWSTR) s, (LPCWSTR)L"Test", MB_OK);
        // only if user clicked on a edit box
        if(wcsncmp(s, L"Edit", 4) == 0)
            SendMessage(mainHwnd, WM_APP, 0, (LPARAM) lParam);
        free(s);
        s = NULL;
    }
}

// calls next hook in chain
return CallNextHookEx(NULL, nCode, wParam, lParam);
}

block in main program that handles WM_APP messages

case WM_APP:
    {
        //MessageBox(hWnd, (LPCWSTR)L"Received WM_APP", (LPCWSTR)L"Test", MB_OK);
        // copies text from the edit box
        MOUSEHOOKSTRUCT *m = (MOUSEHOOKSTRUCT*) lParam;
        int n = GetWindowTextLength(m->hwnd);
        // if text has been inserted
        if(n > 0 && n < 1024)
        {
            wchar_t *s = (wchar_t*) malloc((n+1)*sizeof(wchar_t));
            // gets text
            GetWindowText(m->hwnd, (LPWSTR) s, n+1);
            s[n] = (wchar_t) 0;
            //MessageBox(hWnd, (LPCWSTR)s, (LPCWSTR)L"Test", MB_OK);
            // saves text in database
            stateClassPointer->insertInList(s); 
        }
    }
    break;
  • 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-24T16:38:53+00:00Added an answer on May 24, 2026 at 4:38 pm

    It is probably because you are sending the message for WM_RBUTTONDOWN and WM_RBUTTONUP, that is when the right button is pressed and when it is released.

    When you are debugging the WM_RBUTTONUP is eaten by the debugger so you don’t get it.

    PS: Shouldn’t you use PostMessage() instead of SendMessage(), just to be safe?

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

Sidebar

Related Questions

In a couple of scripts that I use I have problem that is intermittent.
i try to use SendMessage with EM_FINDWORDBREAK i have got the position of mouse
regarding to this question , i have a problem if use that query for
i have problem use link_to_remote link_to_remote document example say link_to_remote Delete this post, :update
I have found a problem with use JQuery timeout, i have a page with
I have problem with setting proper charset on my jsf pages. I use MySql
I have quite a problem concerning the use of relational database concepts in Delphi
I have a problem in php code inserting values into database (I use PHPMyAdmin).
Ok I have this problem I'm trying to use Jquery to load a partial
I have a problem with ViewHolder class. I use ViewHolder to improve my List

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.