|
The following is from MSDN documentation for onchange Event[^] (emphasis added):
Remarks
This event is fired when the contents are committed and not while the value is changing. For example, on a text box, this event is not fired while the user is typing, but rather when the user commits the change by leaving the text box that has focus. In addition, this event is executed before the code specified by onblur when the control is also losing the focus.
The onchange event does not fire when the selected option of the select object is changed programatically.
I've never worked with any of this, but I'd think you might be able to do what you want if, after changing the selection, you use IHTMLDocument4::createEventObject[^] to create an event, set the relevant properties for that event using the IHTMLEventObj Interface[^] (check the doc for the onchange Event[^] to see which properties are available for handlers), and finally use either IHTMLDocument4::fireEvent[^] or IHTMLElement3::fireEvent[^] to the fire the event yourself.
As a side note, I don't see in your code the Release calls for the COM interfaces you are acquiring. Consider using ATL's CComPtr[^] and CComQIPtr[^], which automatically handle that for you.
Hope that helps,
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Thanks for the information. It gives me more to try. I do have a follow-up question to you or anyone else based on your reply:
Is there a way to programmatically (C++) make the select element "lose focus" after setting its value? Would that cause the event to fire?
Any example code to create an event would also be helpful. I just recall I looked at the fireEvent interface but it was not readily apparent what to do. But I will look again.
Thanks again.
|
|
|
|
|
SureshMahanty wrote:
Is there a way to programmatically (C++) make the select element "lose focus" after setting its value?
To make it lose focus, I think you could make something else get it, and yes, I think that would be possible, but...
SureshMahanty wrote:
Would that cause the event to fire?
I don't think so.
SureshMahanty wrote:
Any example code to create an event would also be helpful.
As I said before, I've never worked with this so I'm afraid I can't offer any concrete example.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Thanks Jose. I was actually posting the follow-up to anyone who may want to respond. I appreciate the info you have given already.
If anyone has pointers on how to use the fireEvent method to fire an onchange event for a particular SELECT Element, that would be much appreciated. Here is what the MSDN documentation says for fireEvent:
IHTMLDocument4::fireEvent Method Internet Development Index
Fires a specified event on the object.
Syntax
HRESULT fireEvent( BSTR bstrEventName,
VARIANT *pvarEventObject,
VARIANT_BOOL *pfCancelled
);
Parameters
bstrEventName
[in] BSTR that specifies the name of the event to fire.
pvarEventObject
[in] Pointer to a VARIANT that specifies the IHTMLEventObj
interface from which the event properties are obtained.
pfCancelled
[out, retval] VARIANT_BOOL that receives one of the
following values:
VARIANT_TRUE - Event fired successfully.
VARIANT_FALSE - Event was cancelled.
If I just want to fire the onchange event, does anybody have a clue what the parameters values should be?
Should bstrEventName literally be set to "onchange"?
How do I create an IHTMLEventObj for pVarEventObj and what would the "event properties" be? It must somehow include a "handle" to the specific DOM object (i.e. the specific SELECT element) or some sort of event "handler". I am just using those terms as a "lay person", rather than exact meanings.
Also, I am not sure how to get the IHTMLDocument4 object...I already have an IHTMLDocument2, do I just "redundantly" call queryInterface in the same way/context that I got the IHTMLDocument2 object, except query for IID_IHTMLDocument4?
BTW, I ordered "Programming Internet Explorer 5" and hopefully it will help with this question (whenever it arrives). But unfortunately, I need to try to push forward regardless of whether it arrives or is useful.
|
|
|
|
|
Hi guys,
I have an application tool which needs to safely and effectively close down other applications. I have seen a few posts on here about getting the PROCESSENTRY32 structure and then issuing a TerminateProcess command on it, however, this doesn't seem the safest method. Using SendMessage(WM_CLOSE,0,0) appears to be a safer option. Therefore my question is: is it possible to get a window handle to the main window created by a known PROCESSENTRY32 structure?
Thanks in advance,
Simon
|
|
|
|
|
Try using EnumWindows. Look it up on MSDN. EnumWindows will look at every windows handle for you, and then you just need a way of telling which window you want!
You need to write a function that EnumWindows will call. In this function use GetWindowText or GetClassName. Then compare each window with the text or class name you know you're looking for. How do you know what the text or class name for the window is? The text is easy. That's what's displayed in the bar at the very top of the window. The class name is better, if the program you're targeting has a stable class name. To find the class name of the window you want to target use Spy++. Be careful, though, because a program can have several windows and several class names for the windows. You just have to make sure to get the class name of the parent.
This method works great! I've used it myself. You have to be careful, though, because not all programs will let you close them safely. Internet Explorer or Windows Explorer (I think they're virtually the same thing) won't close if you send them the WM_CLOSE message. But hey, if you can find a way to safely close them, I'd like to know too!
Danny
|
|
|
|
|
srev wrote:
herefore my question is: is it possible to get a window handle to the main window created by a known PROCESSENTRY32 structure?
this will help
Is it possible to get info between HWND and Process handle?[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Any recommendations from those who tried both? I would like to use something simpler like RMI for C++[^], but it's still young and under development, and I need something mature, stable and scalable
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
did you have a look at ICE[^]?
|
|
|
|
|
Very interesting. Too bad it is GPL, and at this point I can't purchase a commercial license.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Nemanja Trifunovic wrote:
Any recommendations from those who tried both? I would like to use something simpler like RMI for C++[^], but it's still young and under development, and I need something mature, stable and scalable
XML-RPC[^] seems to have gained momentum as lightweight alternative for distributed computing (disclaimer: haven't tried it).
|
|
|
|
|
Nah, too much overhead. This needs to be a binary protocol.
BTW, I have already worked with SOAP, and it seemed to me that it was a XML-RPC killer.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Hello,
I tried CORBA, but I (and every other student) didn't like it. You have incredibly much initialization to do and additional servers to run if you want maximum flexibility and scalability.
If it's no problem for your client to integrate the CORBA infrastructure and you can get passed the initialization, everything works like a charm. As far as I know (D)COM, your code with CORBA will look much more cleaner.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Who can help me to add to a title bar a menu( or a dialog ) in a MFC SDI application?
NG
|
|
|
|
|
Hi,
Is it possible to create a macro that would create an instance of a class? I'm trying this but the compiler won't accept it:
#define Logger() (MyLogger tempLogger(__FUNCTION__, __FILE__, __LINE__))
Thanks
Hua-Ying
|
|
|
|
|
|
error C2059: syntax error : ')'
error C2146: syntax error : missing ')' before identifier 'tempLogger'
error C3861: 'tempLogger': identifier not found, even with argument-dependent lookup
|
|
|
|
|
class MyLogger
{
MyLogger( char*, char*, char*)
{
}
};
#define Logger() (MyLogger tempLogger(__FUNCTION__, __FILE__, __LINE__))
no error on visual c++ 6.0...
NG
|
|
|
|
|
The syntax error only occurs when I try to use the macro. The errors are:
error C2059: syntax error : ')'
error C2146: syntax error : missing ')' before identifier 'tempLogger'
error C3861: 'tempLogger': identifier not found, even with argument-dependent lookup
Hua-Ying
|
|
|
|
|
#include <iostream>
using namespace std;
#define Logger() MyLogger tempLogger(__FUNCTION__, __FILE__, __LINE__)
class MyLogger
{
public:
MyLogger(char *pFunction, char *pFile, long Line)
{
cout<
|
|
|
|
|
Thanks that really does work!
I've always though that argument in a #define were separated by spaces so that it would see 3 arguments there. I guess I was wrong!
|
|
|
|
|
How do i find a control's current x,y coordinates on the window??
|
|
|
|
|
looking here[^] i found that code :
CRect ButtonRect;
GetWindowRect(ButtonRect);
pParent->ScreenToClient(ButtonRect)
reading the sample more in details should help you more...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
Use GetClientRect() if you want the coordinates relative to the upper-left of the client area (i.e., left and top are both 0). Use GetWindowRect() if you want the coordinates relative to the upper-left of the screen.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|