Current location - Quotes Website - Signature design - How to modify the value of web page elements with VC++
How to modify the value of web page elements with VC++
This is a part of the auxiliary software of a web game I wrote.

bool CMoveArmEle::choose airarm(int iAirNum)

{

USES _ CONVERSION

bool bChooseArmHead = false

If( 7 == m_iType )// No commander is needed to open a branch base.

bChooseArmHead = true

IDispatch * pDisp = m _ pHtmlView-& gt; GetForm(" f 1 ");

if( NULL == pDisp)

Returns false

CComQIPtr & ltIHTMLFormElement & gtspFormElement = pDisp

pDisp-& gt; Publish ();

long nElemCount = 0; //Get the number of fields in the form.

HRESULT HR = spFormElement-& gt; Gets the length (& ampnelemcount);

If (Failure (hours))

Returns false

For (length j = 0;; j & ltnElemCountj++)

{

CComDispatchDriver spInputElement; //Get the j th form field

HR = spFormElement-& gt; item( CComVariant( j),CComVariant(),& ampspInputElement);

If (failure (hr)) continues;

CComVariant vName, vVal, vType// Get the name, value and type of the form field.

hr = spInputElement。 GetPropertyByName( L"name ",& ampvName);

If (failure (hr)) continues;

hr = spInputElement。 GetPropertyByName( L"value ",& ampvVal);

If (failure (hr)) continues;

hr = spInputElement。 GetPropertyByName( L"type ",& ampvType);

If (failure (hr)) continues;

LPCTSTR lpName = vName.bstrVal?

OLE2CT(vname . bstr val):_ T(" NULL "); //Unknown domain name

LPCTSTR lpVal = vVal.bstrVal?

OLE2CT(vval . bstr val):_ T(" NULL "); //null value, not entered.

LPCTSTR lpType = vType.bstrVal?

OLE2CT(vtype . bstr val):_ T(" NULL "); //Unknown type

// spInputElement.ch

// strMess。 Format ("name =%s value =%s type =%s\n", lpName, lpVal, lptype);

//TRACE(strMess);

If (! BChooseArmHead) // Select the commander

{

if( (0 == strcmp(lpName," cid "))

& amp& amp(0 == strcmp(lpType," radio "))

)

{

CComQIPtr & ltIHTMLElement & gtspele(spInputElement);

If (special)

spele->; Click ();

other

Assertion (false);

bChooseArmHead = true

}

}

{//Select a conveyor belt.

if( (0 == strcmp(lpName,m_strArmType))

& amp& amp(0 == strcmp(lpType," text "))

)

{

CComQIPtr & ltIHTMLInputTextElement & gtspInputText(spInputElement);

CString strain;

Srinam. Format ("%d", iairnum);

spInputText-& gt; put_value(strAirNum。 AllocSysString());

}

}

If( 0 == strcmp(lpVal," Next "))

{

CComQIPtr & ltIHTMLInputTextElement & gtspInputText(spInputElement);

CComQIPtr & ltIHTMLInputButtonElement & gtspInputButton(spInputElement);

CComQIPtr & ltIHTMLInputHiddenElement & gtspInputHidden(spInputElement);

CComQIPtr & ltIHTMLSelectElement & gtsp select(spInputElement);

CComQIPtr & ltIHTMLElement & gtspele(spInputElement);

spele->; Click ();

}

}

}

If you still can't handle it, I suggest uploading the code to my forum.

See my signature for the forum address.