Thread: BeforeNavigate2 event and PostData

  1. #1
    Registered User
    Join Date
    Jan 2006
    Location
    Latvia
    Posts
    102

    BeforeNavigate2 event and PostData

    I'm capturing the BeforeNavigate2 event of a WebBrowser control and I tried to edit the PostData parameter from here, but it won't send my updated data (just sends the original PostData).
    Code:
    void BeforeNavigate2(IDispatch *pDisp, VARIANT * url,VARIANT * Flags,VARIANT * TargetFrameName,
     VARIANT * PostData,VARIANT * Headers,  VARIANT_BOOL * Cancel) 
    {
    		SAFEARRAY* psa = (SAFEARRAY*)SendMessage(msgForward, WM_USER+0xdead,
    			(WPARAM)0, (LPARAM)PostData->pvarVal->parray); //retrieves modified post data into psa
    		SafeArrayCopyData(psa, PostData->pvarVal->parray); //applies the modified data
    }
    I've made sure it all works in debugger, isn't this the place where modifications of PostData before request can be made?
    Last edited by Overlord; 11-08-2008 at 08:48 PM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    According to the manual page - did you read it, or just assume what you were trying would work, the only thing this function can do is decide whether or not to allow the transfer.
    It does that by setting *Cancel = TRUE;

    Oh, and it says some other stuff as well.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jan 2006
    Location
    Latvia
    Posts
    102
    I didn't read it all, however, it would make much more sense if I could edit the variables in this function, instead of cancelling the current request and making another one, wouldn't it?

    Thanks for enlightening me on this.

Popular pages Recent additions subscribe to a feed