ebmDevMag.com home
ebm Developer's Magazine
links

developer's mag
main page

article
part 1
part 2
part 3
part 4
part 5
part 6
part 7
part 8
part 9


3 - Inside CLabel

Once you have a label on the form, there are several calls that are useful in accessing it:
  SetFont(const FONT*font);
  SetLabel(const char *label);
  const char *GetLabel(void);
The first, SetFont(), allows you to change the font used to draw the label. This call is especially useful since the Form Editor has no way to specify the font, and using this call afterwards allows you to change the text without creating the control by hand.

SetLabel() and GetLabel() allow access to the text of the label itself, passing and returning a const (non-editable) pointer. A non-intuitive aspect of this is that the pointer passed must be valid for the life of the label, or until another pointer is exchanged for it. The reason is that the label does not store the text internally, only the pointer. If later the label needs to be redisplayed, and the pointer is invalid, the displayed result will most likely be garbage.

Previous Section
Next Section

Copyright © 2001-2006 ebmDevMag.com - Legal Notice