Click here to Skip to main content
15,899,026 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Solve Error Pin
Christian Graus1-Sep-05 16:38
protectorChristian Graus1-Sep-05 16:38 
GeneralRe: Solve Error Pin
Member 21610041-Sep-05 16:58
Member 21610041-Sep-05 16:58 
QuestionList of files in a directory Pin
bugDanny1-Sep-05 9:43
bugDanny1-Sep-05 9:43 
AnswerRe: List of files in a directory Pin
carks1-Sep-05 9:56
carks1-Sep-05 9:56 
GeneralRe: List of files in a directory Pin
bugDanny1-Sep-05 10:00
bugDanny1-Sep-05 10:00 
AnswerRe: List of files in a directory Pin
ThatsAlok1-Sep-05 16:19
ThatsAlok1-Sep-05 16:19 
GeneralRe: List of files in a directory Pin
sunit52-Sep-05 0:56
sunit52-Sep-05 0:56 
QuestionProblem automating IE MSHTML SELECT Element Pin
SureshMahanty1-Sep-05 8:27
SureshMahanty1-Sep-05 8:27 
I am very new to using Internet Explorer MSHTML Controls, mostly developing my code by gleaning the web for useful code snippits. However, I have not been able to find anything that addresses the issue I am having. Hopefully somebody knows the answer to my question. I found DHTMLUI on this site, but it only has placeholders for the "SELECT ELement" code I seek.

I am programming using Visual C++ version 6.0.
I am running Internet Explorer 6.0.3790.1830 on OS Microsoft Windows Server 2003 Web Edition Service Pack 1.

Background:
I am trying to automate a web-based management interface to our company's product. My first step is to come up with a proof-of-concept that will demonstrate that I can control any of the DOm elements that I encounter. After much Googling I have been able to write a C++ program to navigate the Internet Explorer web-browser to the desired login page, parse that login page and input username/password to login, parse the various frames in the subsequent frames, (as a test) and automatically click on all anchor links in the frame that contains "navigation-related" links and see another frame display the various different pages.

Question:
Now I am trying to set values in things such as SELECT/OPTION elements, radio inputs, etc.
However, I am having trouble with the SELECT/OPTION and radio inputs. The problem is that there is an "onchange=<javascript_function>" in the SELECT and radio inputs. I have tried to select an option in various ways, and the visible browser does in fact show the Selected value in the GUI changes, but for some reason the onchange javascript function does not execute.

Does anybody know how to do what I am trying to do? How can I debug this issue? I feel that the "event" for onchange is not "firing". I read some user group posting (from another website) that made an off-handed reference to a possible bug in IE, but I would be surprised if that were true because I think I am doing something very basic.

FYI, here is the HTML that contains the example select/option item I am trying to control/automate via MSHTML C++:


10
25
50
100
All


Basically, it is supposed to refresh the screen with more items-per-page depending on what the user selects. When I manually do it with my mouse, it works fine. I just cannot seem to get it to do the ChangeRecPerPage() when I use IE MSHTML Controls. Here is a code excerpt of what I am doing in C++:

bool
Frame::SetOptionElement(IHTMLSelectElement*& prSelect, const char* pOptionName)
{
IHTMLOptionElement* ptr_option = NULL;
IDispatch* ptr_disp = NULL;

HRESULT hr;

long len = 0;
prSelect->get_length(&len);

// find and set the option value specified
for (int i=0; i < len; i++)
{
VARIANT var_index;
var_index.vt = VT_UINT;
var_index.lVal = i;

hr = prSelect->item(var_index, var_index, &ptr_disp);

if (FAILED(hr))
{
// error: could not get option item dispatcher
cerr << i << ") Could not get option item dispatcher " << hr << endl;
continue;
}

hr = ptr_disp->QueryInterface(IID_IHTMLOptionElement,(LPVOID*)&ptr_option);
if (FAILED(hr))
{
// error: could not get option item
cerr << i << ") Could not get option item" << hr << endl;
continue;
}

BSTR text;
ptr_option->get_text(&text);
CString text_str = text;

if(text_str.Find(pOptionName) >= 0)
{
cerr << "Found option named " << text_str << endl;
BSTR value;
hr = ptr_option->get_value(&value);
hr = prSelect->put_value(value);
/*
// Also attempted using put_selectedIndex with hard-coded index value.
// It did change the value shown (i.e. index 3 -> display "100"), but the
// displayed number of items per page remained.
long selected_index = 0;
hr = prSelect->get_selectedIndex(&selected_index);
long debug_selected_index = 3;
hr = prSelect->put_selectedIndex(debug_selected_index);
hr = prSelect->get_selectedIndex(&selected_index);
*/
return true;
}
}
return false;
}

AnswerRe: Problem automating IE MSHTML SELECT Element Pin
Jose Lamas Rios1-Sep-05 15:46
Jose Lamas Rios1-Sep-05 15:46 
GeneralRe: Problem automating IE MSHTML SELECT Element Pin
SureshMahanty1-Sep-05 19:16
SureshMahanty1-Sep-05 19:16 
GeneralRe: Problem automating IE MSHTML SELECT Element Pin
Jose Lamas Rios2-Sep-05 3:31
Jose Lamas Rios2-Sep-05 3:31 
GeneralRe: Problem automating IE MSHTML SELECT Element Pin
SureshMahanty2-Sep-05 9:42
SureshMahanty2-Sep-05 9:42 
QuestionSafely closing a process Pin
srev1-Sep-05 6:09
srev1-Sep-05 6:09 
AnswerRe: Safely closing a process Pin
bugDanny1-Sep-05 9:51
bugDanny1-Sep-05 9:51 
AnswerRe: Safely closing a process Pin
ThatsAlok2-Sep-05 20:50
ThatsAlok2-Sep-05 20:50 
QuestionDCOM vs CORBA for distributed computing? Pin
Nemanja Trifunovic1-Sep-05 6:02
Nemanja Trifunovic1-Sep-05 6:02 
AnswerRe: DCOM vs CORBA for distributed computing? Pin
Zdeslav Vojkovic1-Sep-05 7:41
Zdeslav Vojkovic1-Sep-05 7:41 
GeneralRe: DCOM vs CORBA for distributed computing? Pin
Nemanja Trifunovic1-Sep-05 7:47
Nemanja Trifunovic1-Sep-05 7:47 
AnswerRe: DCOM vs CORBA for distributed computing? Pin
Roland Pibinger1-Sep-05 12:53
Roland Pibinger1-Sep-05 12:53 
GeneralRe: DCOM vs CORBA for distributed computing? Pin
Nemanja Trifunovic1-Sep-05 15:32
Nemanja Trifunovic1-Sep-05 15:32 
AnswerRe: DCOM vs CORBA for distributed computing? Pin
Bob Stanneveld1-Sep-05 19:33
Bob Stanneveld1-Sep-05 19:33 
QuestionTitle bar( caption bar) whith menu Pin
Neagoe Gabriel1-Sep-05 4:51
Neagoe Gabriel1-Sep-05 4:51 
Question#define syntax for create a class instance Pin
hyling1-Sep-05 4:19
hyling1-Sep-05 4:19 
AnswerRe: #define syntax for create a class instance Pin
toxcct1-Sep-05 4:36
toxcct1-Sep-05 4:36 
GeneralRe: #define syntax for create a class instance Pin
hyling1-Sep-05 6:42
hyling1-Sep-05 6:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.