开发者

Why is my mousehook inside dll unable to recognize simple BOOL?

#pragma data_seg(".shared")  // ".shared" is defined in exports.def to allow  
HWND        m_hHwndMouse = 0;
HHOOK        m_hHookMouse = 0;
BOOL hover = true;
#pragma data_seg()

this section is managed with .def file

EXPORTS
    SetValuesMouse
    MouseProc

SECTIONS
    .shared READ WRITE SHARED

I am directing this dll(adding values) + trying to change the BOOL hover = true; by changing this value trough autoit dll call

DllCall(".\simplemousehook.dll", "int", "SetValuesMouse", "hwnd", $main, "hwnd", $hhMouse[0], "BOOL", 0)

this simply makes the

HWND        m_hHwndMouse = 0;
HHOOK        m_hHookMouse = 0;

from the shared section changed in the function SetValuesMouse

void WINAPI SetValuesMouse(HWND hWnd, HHOOK hk, BOOL ho)
{
    m_hHwndMouse = hWnd;
    m_hHookMouse = hk;
    hover = ho;
}

Ok, so now my mouse hook inside DLL knows where to send messages(m_HWNDMOuse)

LRESULT CALLBACK MouseProc( int nCode, WPARAM wParam, LPARAM lParam )
{
    case WM_MOUSEMOVE:
    wParm = AU3_WM_MOUSEMOVE;
        PostMessage(m_hHwndMouse, wParm,(WPARAM)( (MOUSEHOOKSTRUCT*) lParam )->hwnd,     LPARAM(fromp));

This works perfectly fine and my gui(which is hHwndMouse ) normally receives the message from the dll, so obviously i am able to change it trough setvaluesmouse function

开发者_Python百科

BUT...

if i do this

if (hover = 1)
{
.. do something here
}

and prior to that i change the BOOL hover to 0 trough the function SetValuesMouse the dll ignores that hover is 0 and "does something here"...

Why is it unable to read the bool properly and ignore the ...do something here...?

I know i am probably making totally stupid mistake here but i can't help it but to ask for help.


You are missing an = in the if condition, it should be if (hover == 1).


One = sign in C means assignment, when you incorrectly perform that if-check, you're actually mutating the value of hover and triggering the event unexpectedly.

== is the equality operator in C.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜