Click here to Skip to main content
15,884,059 members

Lim Bio Liong - Professional Profile



Summary

    Blog RSS
64,895
Author
1,663
Authority
588
Debator
112
Organiser
1,019
Participant
0
Editor
0
Enquirer
Lim Bio Liong is a Specialist at a leading Software House in Singapore.

Bio has been in software development for over 10 years. He specialises in C/C++ programming and Windows software development.

Bio has also done device-driver development and enjoys low-level programming. Bio has recently picked up C# programming and has been researching in this area.

Reputation

Weekly Data. Recent events may not appear immediately. For information on Reputation please see the FAQ.

Privileges

Members need to achieve at least one of the given member levels in the given reputation categories in order to perform a given action. For example, to store personal files in your account area you will need to achieve Platinum level in either the Author or Authority category. The "If Owner" column means that owners of an item automatically have the privilege. The member types column lists member types who gain the privilege regardless of their reputation level.

ActionAuthorAuthorityDebatorEditorEnquirerOrganiserParticipantIf OwnerMember Types
Have no restrictions on voting frequencysilversilversilversilver
Bypass spam checks when posting contentsilversilversilversilversilversilvergoldSubEditor, Mentor, Protector, Editor
Store personal files in your account areaplatinumplatinumSubEditor, Editor
Have live hyperlinks in your profilebronzebronzebronzebronzebronzebronzesilverSubEditor, Protector, Editor
Have the ability to include a biography in your profilebronzebronzebronzebronzebronzebronzesilverSubEditor, Protector, Editor
Edit a Question in Q&AsilversilversilversilverYesSubEditor, Protector, Editor
Edit an Answer in Q&AsilversilversilversilverYesSubEditor, Protector, Editor
Delete a Question in Q&AYesSubEditor, Protector, Editor
Delete an Answer in Q&AYesSubEditor, Protector, Editor
Report an ArticlesilversilversilversilverSubEditor, Mentor, Protector, Editor
Approve/Disapprove a pending ArticlegoldgoldgoldgoldSubEditor, Mentor, Protector, Editor
Edit other members' articlesSubEditor, Protector, Editor
Create an article without requiring moderationplatinumSubEditor, Mentor, Protector, Editor
Approve/Disapprove a pending QuestionProtector
Approve/Disapprove a pending AnswerProtector
Report a forum messagesilversilverbronzeProtector, Editor
Approve/Disapprove a pending Forum MessageProtector
Have the ability to send direct emails to members in the forumsProtector
Create a new tagsilversilversilversilver
Modify a tagsilversilversilversilver

Actions with a green tick can be performed by this member.


 
GeneralDeclaring an Interop Struct that contains a character array. Pin
Lim Bio Liong8-Jan-11 4:04
Lim Bio Liong8-Jan-11 4:04 
GeneralCOM SAFEARRAYs - How to use it in C# Pin
Lim Bio Liong25-Sep-10 13:25
Lim Bio Liong25-Sep-10 13:25 
GeneralTroubleshooting Exceptions: System.BadImageFormatException Pin
Lim Bio Liong17-Sep-10 20:53
Lim Bio Liong17-Sep-10 20:53 
GeneralCreating ActiveX Controls in an MFC Application Pin
Lim Bio Liong10-Jan-10 19:26
Lim Bio Liong10-Jan-10 19:26 
GeneralCareful to allocate BSTRs using ::SysAllocString(). Pin
Lim Bio Liong31-Dec-09 19:08
Lim Bio Liong31-Dec-09 19:08 
GeneralAbout X.509 Certificates Pin
Lim Bio Liong31-Dec-09 18:25
Lim Bio Liong31-Dec-09 18:25 
GeneralSome General Points on Array Initialization Part 1 Pin
Lim Bio Liong22-Dec-09 20:25
Lim Bio Liong22-Dec-09 20:25 
GeneralSome Comments on Copy Constructors Pin
Lim Bio Liong20-Dec-09 23:19
Lim Bio Liong20-Dec-09 23:19 
GeneralDefault and Customized Constructors Pin
Lim Bio Liong20-Dec-09 22:54
Lim Bio Liong20-Dec-09 22:54 
GeneralDefault and Customized Constructors (Part 2) Pin
Lim Bio Liong20-Dec-09 23:16
Lim Bio Liong20-Dec-09 23:16 
GeneralGeneric Test HTML Code For Testing ActiveX Objects Pin
Lim Bio Liong19-Dec-09 14:05
Lim Bio Liong19-Dec-09 14:05 
GeneralEnsuring a Safe ActiveX Object to be used inside a Web Page Pin
Lim Bio Liong19-Dec-09 14:02
Lim Bio Liong19-Dec-09 14:02 
GeneralCOM Objects that are created via <object> tags</object> Pin
Lim Bio Liong19-Dec-09 13:59
Lim Bio Liong19-Dec-09 13:59 
GeneralInternet Explorer with Tabs : Debugging a COM Object or an ActiveX inside a Web Page [modified] Pin
Lim Bio Liong19-Dec-09 13:23
Lim Bio Liong19-Dec-09 13:23 
GeneralThe Significance of the "CLSID:" Symbol for the OBJECT Tag's CLASSID Attribute Pin
Lim Bio Liong8-Dec-09 23:24
Lim Bio Liong8-Dec-09 23:24 
GeneralCool use of the #import inject_statement() attribute Pin
Lim Bio Liong4-Dec-09 0:29
Lim Bio Liong4-Dec-09 0:29 
GeneralFailure of javascript usage of MFC ActiveX Control - Part 1 Pin
Lim Bio Liong3-Dec-09 16:31
Lim Bio Liong3-Dec-09 16:31 
GeneralFailure of javascript usage of MFC ActiveX Control - Part 2 Pin
Lim Bio Liong3-Dec-09 16:33
Lim Bio Liong3-Dec-09 16:33 
GeneralFailure of javascript usage of MFC ActiveX Control - Part 3 Pin
Lim Bio Liong3-Dec-09 16:35
Lim Bio Liong3-Dec-09 16:35 
GeneralFailure of javascript usage of MFC ActiveX Control - Part 4 Pin
Lim Bio Liong3-Dec-09 16:36
Lim Bio Liong3-Dec-09 16:36 
The following is a continuation of Bio's reply :

Hello Anand,

As promised, the following is my long answer :

Long Answer

1. Unless the value of the CLSID attribute of the OBJECT tag in your HTML code contains the symbol "CLSID:" as in :

<OBJECT classid="CLSID:2D0B18FB-673F-4B90-865F-3EC067C9DEA9" id="a"></OBJECT>

The CLASSID attribute remains invalid and so your ActiveX will not get created.

2. Next, comes the problem with "myobject" :

myobject = new ActiveXObject("SAMPLEACTIVEX.sampleActiveXCtrl.1");  

The issue has to do with the calling of the IPersistPropertyBag::InitNew() method of your MFC ActiveX Control. This interface method is called by the MSHTML.DLL code within IExplorer.exe.

3. The IPersistPropertyBag::InitNew() method is implemented for you by MFC via the COleControl::XPersistPropertyBag::InitNew() method. Your MFC class would have been derived from COleControl and so this function is already embedded within your MFC class.

3. Inside COleControl::XPersistPropertyBag::InitNew(), you will notice a call to set COleControl::m_bInitialized to TRUE. This is important as we will see later.

4. Now, when any of your control's methods is called, the JScript engine will first get MSHTML to obtain the ID of your method. This is the essence of late binding. Hence, if MyAdd() is to be invoked, JScript will need to know the ID of the MyAdd() function which in your ActiveX control would be DISPID_MYADD.

5. MSHTML will inquire of your ActiveX the ID of MyAdd() by calling your ActiveX control's IDispatch::GetIDsOfNames() method. This is implemented for you by MFC with the function : COleDispatchImpl::GetIDsOfNames().

6. After obtaining this ID, the IDispatch::Invoke() method will be called. The IDispatch::Invoke() method is implemented for your ActiveX by the COleDispatchImpl::Invoke() method. It is here that your MyAdd() function should get called. However, there is a line within COleDispatchImpl::Invoke() that goes like this :

// allow subclass to disable Invoke
if (!pThis-&gt;IsInvokeAllowed(dispid))
   return E_UNEXPECTED;

This is the function COleControl::IsInvokeAllowed() and it is the "archilles tendon" of your problem.

7. Examining COleControl::IsInvokeAllowed() :

BOOL COleControl::IsInvokeAllowed(DISPID)
{
return m_bInitialized;
}

We will note that the state of the COleControl::m_bInitialized, if FALSE, will result in the premature conclusion of the COleDispatchImpl::Invoke() method, resulting in the return of the E_UNEXPECTED HRESULT. This is the cause of the exception in your Javascript.

8. In summary, adding "CLSID:" to the CLASSID attribute of the OBJECT tag is not sufficient. You must use the ActiveX control as declared by the OBJECT tag whose id is "a". The use of the ActiveXObject() function is meant to create and return a COM interface. There are 2 problems with the use of the ActiveXObject() function in relation to your Javascript :

8.1 By declaring "myobject" and then setting it to a new ActiveXObject(), a brand new instance of your ActiveX control will be created. The "a" object will remain but it will not be used. The calling of IPersists* interface methods of your ActiveX control will not be called.

8.2 "myobject" will end up without its COleControl::XPersistPropertyBag::InitNew() ever being called which will result in its COleControl::m_bInitialized remaining FALSE. This results in the COleDispatchImpl::Invoke() function returning E_UNEXPECTED.

Hence my recommendation that you use the "a" object and remove the declaration and use of "myobject".

I hope the above rather long explanation helps.

- Bio.
GeneralInteresting Info On delete and delete [] Pin
Lim Bio Liong25-Nov-09 17:27
Lim Bio Liong25-Nov-09 17:27 
GeneralInteresting Problem Related to a Temporary VARIANT - Personal Findings - Part 1 Pin
Lim Bio Liong12-Aug-09 22:41
Lim Bio Liong12-Aug-09 22:41 
GeneralTwo Ways To Reference External Types Into An IDL. Pin
Lim Bio Liong16-Jun-09 1:11
Lim Bio Liong16-Jun-09 1:11 
GeneralThe Interface Map of CCmdTarget. Pin
Lim Bio Liong6-May-09 20:52
Lim Bio Liong6-May-09 20:52 
GeneralHandling COM Events in an MFC Client. [modified] Pin
Lim Bio Liong6-May-09 20:28
Lim Bio Liong6-May-09 20:28 

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.