News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

ATL and MFC example

Started by donkey, February 20, 2009, 07:13:22 AM

Previous topic - Next topic

donkey

In another thread I posted an example of a web page that demonstrated the simple use of an active template to display a web page. The WebBrowser class object is a member of Microsoft Foundation Class or MFC, a group of objects that are primarily accessed through COM interfaces. The ATL, or Active Template Library allows programmers to implement MFC classes in a way that's both practical and intuitive for a Win32 API programmer. One major limitation of COM is the lack of a mechanism to notify your application when something has changed in the object, a loop to check it constantly would be time consuming and impractical, so Microsoft gave us DISP that triggers events via the Invoke method of IDispatch. In order to receive notifications you must implement the DISP interface in your code and process those events you need. To write an "Event Sink" you have to implement both IUnknown and IDispatch in your application then pass the pointer to the object using AtlAdvise. When an event occurs the object will send a dispatch to your program to notify it of the event through the Invoke method. Two parameters of IDispatch::Invoke are of particular concern, the dispIdMember contains the dispatch ID, that is essentially the notification code and the pdispparams contains the parameters in a DISPPARAMS structure that contains some header information and an array of VARIANT structures containing the individual arguments for that event. In order to extract the arguments we need we use the DispGetParam function that will place the argument into a temporary VARIANT for us to use as we like. In the earlier thread I did not demonstrate the usage of DispGetParam which was an oversight on my part thinking that most here would know how to use it, I have modified the original program to display a progress bar that gets it data through the event sink. To keep the program simple I have just put all off the controls into a rebar band, just slide the one you want to see into place, I have not accounted for adjusting the control size if you create a new band after all this is just a demo.

This demo is written in GoAsm and uses headers from my GoAsm Header Project, available at my website

Here is the proggy...

[attachment deleted by admin]
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

ecube

why you never give masm any love :\ your goasm is confusing stuff is kinda confusing.

donkey

Quote from: E^cube on February 20, 2009, 09:05:09 AM
why you never give masm any love :\ your goasm is confusing stuff is kinda confusing.

I used to use MASM, I prefer GoAsm and now I don't use MASM for any projects.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable