Building a Callout Control
by Thiadmer Riemersma

Example 1:

#include "callout.h"

LoadLibrary("callout.dll");
HWND hwndCallout = CreateWindow("Callout",
                    "Guess what this icon does...",
                    WS_POPUP, 0, 0, 0, 0,
                    NULL, 0, hInstance, NULL);
SendMessage(hwndCallout, CM_SETANCHOR, 0, MAKELONG(100, 200));
ShowWindow(hwndCallout, SW_SHOW);


Example 2:

#include "callout.h"

LoadLibrary("callout.dll");
HWND hwndCallout = CreateWindow(CALLOUT_CLASS,
                    "Guess what this icon does...",
                    WS_POPUP, 0, 0, 0, 0,
                    NULL, 0, hInstance, NULL);
Callout_SetAnchor(hwndCallout, 100, 200);
Callout_SetBorder(hwnd, 2, TRUE);
ShowWindow(hwndCallout, SW_SHOW);


Example 3

#include "callout.h"

LoadLibrary("callout.dll");
HWND hwndCallout = CreateWindow(CALLOUT_CLASS,
                     "Everything is gone;\n"
                     "Your life's work has been destroyed.\n"
                     "Squeeze trigger?", /* David Carlson */
                     WS_POPUP, 0, 0, 0, 0,
                     NULL, 0, hInstance, NULL);
Callout_SetMinWidth(hwndCallout, 180, FALSE);
Callout_SetExtraHeight(hwndCallout, 44, FALSE);
LPRECT rc = Callout_GetRect(hwndCallout);

HWND buttons[3];
buttons[0] = CreateWindow("Button", "Do not ask me this again",
                      WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
                      rc->left, rc->bottom - 16, 180, 16,
                      hwndCallout, 0, hInstance, NULL);
buttons[1] = CreateWindow("Button", "Yes",
                      WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                      rc->left, rc->bottom - 38, 70, 20,
                      hwndCallout, 0, hInstance, NULL);
buttons[2] = CreateWindow("Button", "No",
                      WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                      rc->left + 110, rc->bottom - 38, 70, 20,
                      hwndCallout, 0, hInstance, NULL);
hfont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0);
for (i = 0; i < 3; i++)
  SendMessage(buttons[i], WM_SETFONT, (WPARAM)hfont, TRUE);



Table 1

Message             Wrapper macro                      Description

WM_GETFONT                                    Font handle to use for the text
WM_SETFONT

WM_GETICON                                     Icon handle (optional)
WM_SETICON

CM_GETANCHOR        Callout_GetAnchor(hwnd)    Position of anchor in client coordinates
CM_SETANCHOR        Callout_SetAnchor(hwnd, x, y)

CM_GETBACKCOLOR     Callout_GetBackColor(hwnd)   Color of interior of balloon
CM_SETBACKCOLOR     Callout_SetBackColor(hwnd, Color, Repaint)

CM_GETBORDER        Callout_GetBorder(hwnd)      Border thickness
CM_SETBORDER        Callout_SetBorder(hwnd, Width, Repaint)

CM_GETDRAWTEXTPROC  Callout_GetDrawTextProc(hwnd)  Text drawing function to replace DrawText()
CM_SETDRAWTEXTPROC  Callout_SetDrawTextProc(hwnd, Proc, Repaint)

CM_GETEXTRAHEIGHT   Callout_GetExtraHeight(hwnd)     Extra height of balloon text box
CM_SETEXTRAHEIGHT   Callout_SetExtraHeight(hwnd, Height, Repaint)

CM_GETMINWIDTH      Callout_GetMinWidth(hwnd)    Minimum width of balloon text box
CM_SETMINWIDTH      Callout_SetMinWidth(hwnd, Width, Repaint)

CM_GETRADIUS        Callout_GetRadius(hwnd)      Radius of rectangle rounding
CM_SETRADIUS        Callout_SetRadius(hwnd, Radius, Repaint)

CM_GETRECT          Callout_GetRect(hwnd)  Position and size of balloon text box

CM_GETTAILHEIGHT    Callout_GetTailHeight(hwnd)   Height of tail in pixels
CM_SETTAILHEIGHT    Callout_SetTailHeight(hwnd, Height, Repaint)

CM_GETTAILJOIN      Callout_GetTailJoin(hwnd)      Horizontal position where tail joins 
CM_SETTAILJOIN      Callout_SetTailJoin(hwnd, Join, Repaint)   balloon; a percentage of the balloon width

CM_GETTAILOFFSET    Callout_GetTailOffset(hwnd)    Vertical offset of tail to anchor point
CM_SETTAILOFFSET    Callout_SetTailOffset(hwnd, Offset, Repaint)

CM_GETTAILSLANT     Callout_GetTailSlant(hwnd)                     Tail slant (tangent of the angle); a negative
CM_SETTAILSLANT     Callout_SetTailSlant(hwnd, Slant, Repaint)     value slants to the left

CM_GETTAILSTYLE     Callout_GetTailStyle(hwnd)                     Tail style: CS_SPEAK or CS_THINK
CM_SETTAILSTYLE     Callout_SetTailStyle(hwnd, Style, Repaint)

CM_GETTAILWIDTH     Callout_GetTailWidth(hwnd)                     Width of the tail where it joins the balloon
CM_SETTAILWIDTH     Callout_SetTailWidth(hwnd, Width, Repaint)

CM_GETTEXTCOLOR     Callout_GetTextColor(hwnd)                     Color of the text and border of the callout
CM_SETTEXTCOLOR     Callout_SetTextColor(hwnd, Color, Repaint)

CM_GETTIMEOUT       Callout_GetTimeout(hwnd)                       Timeout in milliseconds; 0 = no timeout
CM_SETTIMEOUT       Callout_SetTimeout(hwnd, Timeout)

CM_GETVERTALIGN     Callout_GetVertAlign(hwnd)       Alignment of callout relative to the anchor
CM_SETVERTALIGN     Callout_SetVertAlign(hwnd, Alignment, Repaint) point: CS_ALIGNABOVE or CS_ALIGNBELOW







1


