Red de conocimiento informático - Material del sitio web - Cómo modificar el valor de los elementos de una página web usando VC++

Cómo modificar el valor de los elementos de una página web usando VC++

Esto es parte del software auxiliar para un juego web que escribí

bool CMoveArmEle::ChooseAirArm(int iAirNum)

{

USES_CONVERSION;

bool bChooseArmHead = false ;

if( 7 == m_iType )//No se requiere que un comandante abra una base

bChooseArmHead = true ;

IDispatch* pDisp = m_pHtmlView->GetForm("f1");

if( NULL == pDisp )

devuelve falso ;

CComQIPtr< IHTMLFormElement > spFormElement = pDisp;

pDisp->Release();

long nElemCount=0 //Obtener el número de campos en el formulario

HRESULT hr = spFormElement->get_length( &nElemCount );

if ( FAILED( hr ) )

return false

for(long j; =0; j

{

CComDispatchDriver spInputElement; //Obtener el campo del formulario j

hr = spFormElement->item( CComVariant( j ), CComVariant(), &spInputElement );

if ( FAILED( hr ) ) continue;

CComVariant vName,vVal,vType //Obtener el nombre, valor y tipo; del campo del formulario

hr = spInputElement.GetPropertyByName( L"nombre", &vName );

if( FAILED( hr ) ) continuar;

hr = spInputElement.GetPropertyByName( L" valor", &vVal );

if( FAILED( hr ) ) continuar;

hr = spInputElement.GetPropertyByName( L"tipo", &vType );

if( FAILED( hr ) ) continuar;

LPCTSTR lpName = vName.bstrVal?

OLE2CT( vName.bstrVal ) : _T("NULL"); //Nombre de dominio desconocido

LPCTSTR lpVal = vVal.bstrVal?

OLE2CT( vVal.bstrVal ): _T("NULL"); //Valor nulo, no ingresado

LPCTSTR lpType = vType.bstrVal?

OLE2CT( vType.bstrVal ) : _T("NULL"); //Tipo desconocido

p>

// spInputElement.ch

// strMess.Format("Nombre=%s Valor=%s Tipo=%s\n",lpName,lpVal,lpType);

// TRACE(strMess);

if(!bChooseArmHead) //Elige comandante

{

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

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

)

{

CComQIPtr < IHTMLElement > spele(spInputElement);

if(spele)

spele->click()

else

; ASSERT(false);

bChooseArmHead = true ;

}

}

{//Elija avión de transporte

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

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

)

{

CComQIPtr < IHTMLInputTextElement > spInputText(spInputElement);

CString strAirNum ;

strAirNum.Format("%d",iAirNum);

spInputText->put_value(strAirNum.AllocSysString());

}

}

if( 0 == strcmp(lpVal,"下注step") )

{

CComQIPtr < IHTMLInputTextElement > spInputText(spInputElement);

CComQIPtr < IHTMLInputButtonElement > spInputButton(spInputElement);

CComQIPtr < IHTMLInputHiddenElement > spInputHidden(spInputElement);

CComQIPtr < IHTMLSelectElement > spSelect(spInputElement);

CComQIPtr < IHTMLElement > spele(spInputElement); spele ->click();

}

}

}

Si aún no puedes entenderlo, te sugiero subes el código a mi foro

Ver mi firma para la dirección del foro