PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

What is CComModule for?

I am a NoobE,

In most or all of the example code I have seen for PocketFrog, an instance of CComModule is used as a global and its init() called in WinMain().

Why is this? What is this for?
CComModule is basically a global object needed by the ATL classes.

ATL is a template-based library that wraps things in Windows. ATL can be seen as something similar to MFC, but without all the bloat. It also produces much more efficient code.

In the PF samples, I use ATL to create the main window and to handle Windows messages (usually done in a WindowProc). Because of this, the CComModule global object is needed.
In the PF samples, I use ATL to create the main window and to handle Windows messages (usually done in a WindowProc).


So we do not need a WindowProc because the PocketFrog framework uses this global? And it handles everything when a button is pressed or the navigator control is used?
Anonymous wrote:So we do not need a WindowProc because the PocketFrog framework uses this global? And it handles everything when a button is pressed or the navigator control is used?


That's the basic idea. The WindowProc is implemented inside ATL. If you look at class Game, you will see macros such as:

BEGIN_MESSAGE_MAP() / END_MESSAGE_MAP()

This is where the message handlers are defined. For example, when WM_CLOSE is received by the window, the method Game::OnClose() will be called. You could name the method anything you want, but it make sense to use the name of the message. (ex: WM_KEYDOWN -> OnKeyDown).

Each function entry in the message map corresponds to one WM_xxx message that the window can receive.
OK.

I gotcha. I am remembering the good ole MFC days. I know this is not MFC but I am begining to see some parallels.

Thanks a bunch.