Jump to content

Null wParam in Message Handler?


Mbee
 Share

Recommended Posts

I want to catch file/folder drops and process them in a message handler. It should be very simple, but something odd's going on. Here are the relevant statements...

GUIRegisterMsg( $WM_DROPFILES, "_L_DropMsgHandler" )

. . .

Func _L_DropMsgHandler( $arg_WinHdl, $arg_MsgID, $arg_wParam, $arg_lParam )
    #forceref $arg_WinHdl, $arg_MsgID, $arg_wParam, $arg_lParam

    Local $Lf_hDrop, $Lf_CursorInfo[5], $Lf_ControlID, $Lf_SlotNum, $Lf_ThisPath
    Local $Lf_Xpos, $Lf_Ypos

    $Lf_hDrop = $arg_wParam                             ; This Param is a Handle to a Drop struct

    If ($Lf_hDrop = 0) Or ($Lf_hDrop = "") Then
        _UpdStatusMsg("_L_AltDropMsgHandler Invoked with Null Drop Handle")
        _WinAPI_DragFinish( $Lf_hDrop )
        Return $GUI_RUNDEFMSG
    EndIf

    Local $Lf_PointTag = DllStructCreate( $tagPOINT )   ; Create the TAG structure to hold the coordinates where the item was dropped

    $Lf_PointTag = _WinAPI_DragQueryPoint( $Lf_hDrop )
    $Lf_Xpos = DllStructGetData( $Lf_PointTag, 1 )
    $Lf_Ypos = DllStructGetData( $Lf_PointTag, 2 )

    Local $Lf_DroppedObjectsAra = _WinAPI_DragQueryFileEx( $Lf_hDrop, 0 ); Get files AND folders
    If @error <> 0 Then
        _UpdStatusMsg("_L_AltDropMsgHandler: _WinAPI_DragQueryFileEx @error = " & @error)
        _WinAPI_DragFinish( $Lf_hDrop )
        Return $GUI_RUNDEFMSG
    EndIf

    If  $Lf_DroppedObjectsAra[0] = 0 Then           ; If nothing dropped (shouldn't happen)
        _UpdStatusMsg("_L_AltDropMsgHandler -- No Files Dropped")
        _WinAPI_DragFinish( $Lf_hDrop )
        Return $GUI_RUNDEFMSG
    EndIf

    $Lf_ThisPath = $Lf_DroppedObjectsAra[1]                     ; Ignore all but the first dropped object
    _UpdStatusMsg("_L_AltDropMsgHandler -- Dropped Path = '" & $Lf_ThisPath & "'")

    $Lf_CursorInfo = GUIGetCursorInfo( $arg_WinHdl )
    If @error <> 0 Then
        _UpdStatusMsg("_L_AltDropMsgHandler -- GUIGetCursorInfo() call failed!")
        _WinAPI_DragFinish( $Lf_hDrop )
        Return $GUI_RUNDEFMSG
    EndIf

    $Lf_ControlID = $Lf_CursorInfo[4]
    If $Lf_ControlID = 0 Then                                               ; Not over ANY control whatsoever
        _UpdStatusMsg("_L_AltDropMsgHandler - Zero Control ID")
        _WinAPI_DragFinish( $Lf_hDrop )
        Return $GUI_RUNDEFMSG
    EndIf

    _WinAPI_DragFinish( $Lf_hDrop )
    Return $GUI_RUNDEFMSG

EndFunc

Immediately upon entry to the message handler, the $arg_wParam value is a null string. What am I doing wrong? Please advise.

Link to comment
Share on other sites

Hi @Mbee.  I have been using those functions/messages successfully without a single problem (almost - see example script section).  Could you make a full runable snippet of your script so we can test it out. 

Link to comment
Share on other sites

5 hours ago, Nine said:

Hi @Mbee.  I have been using those functions/messages successfully without a single problem (almost - see example script section).  Could you make a full runable snippet of your script so we can test it out. 

Hi, my friend!

I was afraid you'd ask for that. The script is over 10000 lines of code, with message and event handlers all over the place. If you had happened to read other of my threads in which others have asked for the same thing, you would recognize that I'm an enormous pain in the ass when it comes to trying to provide such. My typical reply is that I think it would take far more time to produce a runnable snippet that reproduces the problem than to re-re-analyze every line of code.

But, since you have been so kind to me in the past, I'm gonna go ahead and see what I can come up with. It'll take a while, but I'll give up before too long a time has passed.

Thank you, @Nine !

Link to comment
Share on other sites

Well, I thought I'd try a few things before embarking on creating that snippet, and what I found suggests that such a snippet isn't necessary because I've narrowed down the problem.

When I build an executable of my script and run it, I get an error message stating that I've used a variable before declaring it. Of course I can't translate the line number of shown in the error message to something useful, so I've had to work to get it. The first thing I tried was to use #Au3Stripper to obtain a useful line number, but I'm using the FreeImage UDF which confuses the hell out of the stripper and crashes it. Then I tried the graphical debugger, which reported the error in my OP. But it occurred to me that the null parameter might well be a side-effect of the fact that the graphical debugger simply can't handle all the complexity of my script, so I created this thread,

Here's the nub: It's not a debugger side-effect. I've finally traced the line number that caused the undeclared variable error is the first line that tries to use the "$arg_wParam" variable. I made a mod to test that variable specifically (before copying it to another variable) for null immediately upon entry, and sure enough, it always complains that it hasn't been declared. I also tried changing the parameter variable name a few times, but the same error always occurred.

This isn't the first time something inexplicable that absolutely should NOT occur has happened anyway (though in another script). To try to solve that problem, I've tried uninstalling and re-installing all of Autoit, including SciTE for AutoIt, but that made no difference. So it probably won't solve this problem.

 

Do you have any ideas as to what I should try next? For myself, I'm going to try to completely remove everything related to FreeImage and see if that changes anything.  Let me know what you think, okay?

 

Link to comment
Share on other sites

Well, @Nine, I used your #AutoIt3Wrapper line and received lots and lots of new compile-time error messages.

But for now, that's moot considering the bizarre behavior I'm seeing regarding the declaration "issue" above. There's no way I'm going to call it a bug, not without knowledge that I do not possess, but as I indicated above, this is the second time I've seen something virtually impossible, or at least something that's not supposed to happen. 

The only alternative I can see is that my huge script and all the third party UDFs mixed in has reached some AutoIt code "corners" that have not been reached during testing.

 

Link to comment
Share on other sites

15 minutes ago, Mbee said:

received lots and lots of new compile-time error messages

This is your issue  You may look at the other side and say it is not normal, but AutoIt tells you you got problems everywhere.  You should consider to solve those problems.  I personally got script with over 20k lines.  And using those barriers (wrapper and opt), I don't have any issue, and if I had one, I would invest all my time to resolve it.  So now you have a decision to make.

Link to comment
Share on other sites

20 hours ago, Nine said:

This is your issue.

I agree with Nine about it not being size of script. My app combines almost 95k lines if code and runs without issue.

I have had inexplicable issues before and found certain characters somehow embedded in the script. Pulled my (non-existent) hair out for days ....

My suggestion: Copy your script into new blank script.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...