VisualCpp.org Collection of Visual C++ Stuffs

5Dec/080

Type Library Marshaling

Q : For marshelling between apartments, are the stub/proxy code generated automatically by COM Runtime ? Is thre a need for us to explicitly write stub/proxy code by ourselves ?

A : If your interface methods and properties strictly uses types that are automation-compatible (i.e. the types that can be found in a VARIANT structure), then the standard proxy and stub code as contained in OLEAUT32.DLL (the standard Proxy/Stub DLL for Ole Automation) will be used. Yes, in this case, there is no need to explicitly program proxy/stub code.

However, please take note of the following :

1. The type library containing your interface definitions must be registered. This type library will be loaded by OLEAUT32.DLL at runtime in order to understand the signatures of your methods (parameter types, return types) for correct marshaling/unmarshaling and method calls across apartments.

2. The interface definitions involved in marshaling must be contained in the type library. In order for this to happen, the interface definition must either be defined inside the "library" statement in the source IDL file, or it is at least referenced inside the "library" statement. Otherwise, marshaling will fail. One of the possible failure code is TYPE_E_ELEMENTNOTFOUND (0x8002802BL).

3. Most importantly, the interface definition must be attributed with either "oleautomation" or "dual" or that it is by definition a "dispinterface". This will ensure that the Type Library Marshaler (i.e. OLEAUT32.DLL) recognizes the interface as being OLE-AUTOMATION compatible. Failure to comply will result in failure in marshaling. One of the possible failure code is E_FAIL (0x80004005L).

_______________________
Tip Courtesy :-  Lim Bio Liong

5Dec/080

Setting Cursor(s)

Setting WaitCursor :-
Required many time, to intimate the user application is busy doing some task, you can't interact with GUI meantime.

MFC Class :- CWaitCursor

CWaitCursor wait;
// Do Some work!!!! LONG.....
//Display message box
MessageBox("Some result");

//Restore the Wait cursor back to normal
wait.Restore();

Setting Different Cursor icon :-

  • CrossHair Cursor

SetCursor(LoadCursor(NULL, IDC_CROSS));

  • HELP Cursor

SetCursor(LoadCursor(NULL, IDC_HELP));

  • No Cursor (Slashed circle!)

SetCursor(LoadCursor(NULL, IDC_NO));

Pre-defined cursor Table

Value Description
IDC_APPSTARTING Standard arrow and small hourglass.
IDC_ARROW Standard arrow.
IDC_CROSS Crosshair.
IDC_HAND Hand.
IDC_HELP Arrow and question mark.
IDC_ICON Obsolete.
IDC_NO Slashed circle.
IDC_SIZE Obsolete; use IDC_SIZEALL.
IDC_SIZEALL Four-pointed arrow pointing north, south, east, and west.
IDC_SIZENESW Double-pointed arrow pointing northeast and southwest.
IDC_SIZENS Double-pointed arrow pointing north and south.
IDC_SIZENWSE Double-pointed arrow pointing northwest and southeast.
IDC_SIZEWE Double-pointed arrow pointing west and east.
IDC_UPARROW Vertical arrow.
IDC_WAIT Hourglass.
Filed under: MFC, Win32 No Comments