|

(Download
Code) 


Selecting Date and Time is particularly
important when building most VBCE applications. H/PCs and
P/PCs are often used as PDAs, opening a large demand
for applications that, in some way, have a close relationship with
certain moments in time.
However, theres no in-built Date control on
the Visual Basic 6.0 Windows CE Toolkit. Once again, well
have to search for alternative ways to implement this functionality.
Theres always the option of implementing the
calendar with VBCE elements. However, to keep GUI consistency and
the "familiar interface to perform common tasks", wed
have to clone the control already available on the Windows CE. This
seems to be an excellent opportunity to explore the Windows CE API
and reuse the code already available.

In Windows CE theres two basic types of controls:
"Windows Controls" and "Common Controls". The
first type include basic functionality like buttons, labels, list
boxes or combo boxes. "Common controls" provide extra
functionality and include most other controls, including Image Lists,
Progress Bars, Toolbars, Month Calendars and others. In this case,
we are particularly interested on the Month Calendar control.
"Common controls are a set of windows that are
supported by the common control library, which is a dynamic-link
library (DLL) included with the Windows operating system".
Theres a basic distinction between the two types of controls
which is related with the way windows communicate between them.
Let's first have a look on "Messages" and "Callbacks"
to understand this distinction.

On our context, the Common Control will be a child
window of the VBCE window that well be building. These two
windows will be working in conjunction to provide the desired Date
input task.
The basic mechanism underneath every interaction in
the Windows OS is the "asynchronous message-passing".
The OS sends "messages" to windows, these windows take
control and process the messages and return to the OS again after
acting accordingly. Every window has a function that the OS calls
to handle all the messages for that window. Well call it WindowProc.
On our particular example, we have two windows interacting:
our VBCE window and the Month-Calendar control window. Both windows
are capable of sending messages to each other. However, well
call them differently.

Lets assume that our VBCE window wants to instruct
the Month-Calendar window to change its background colour. This,
of course, is performed through sending a message and well
use the SendMessage API function to perform this. However, there
are instances where it is the Month-Calendar control that wants
to inform the VBCE window that some user action has occurred. This
is performed through Callbacks. Weve seen earlier that every
window has a default function, WindowProc, to process all messages.
When the Month-Calendar control window wants to send a message to
our VBCE window, it does so by calling its WindowProc with a set
of parameters that specify the contents of that message.
"Common Controls" differ from "Windows
Controls" in the type of callback messages they send. Instead
of "WM_COMMAND" messages, "Common Controls"
use "WM_NOTIFY" messages that can handle much more information.
It should be logical by now that "WM_NOTIFY" messages
pass this information through User Defined Types (structures).
VBCE windows do not provide handling functionality for "WM_NOTIFY"
messages sent by "Common Controls". This is why we would
have to implement "Subclassing" for this only purpose.
Part II
|