| Header file: | static.h |
| Object name: | fSTATIC |
| Object index: | 1 of 1 Object |
The fSTATIC is a simple, yet useful component which serves little purpose... actually, it just sits there and looks pretty. It can display text, icons, or images, or it can even be one of those line-things, or a box - it does quite a few things...
So far I have not had much luck making the control transparent. If you look at a window that you created the static on, it looks okay and proper. However, should you obscure the window and show it again, forcing a repaint - you will notice that the text sits on the background - the background being the things that are behind the window itself! It looks rather wierd, and I am not exactly sure why this happens, and I hope to rectify it one day.
However, the component works flawlessly when used as an image container, so use it for that, by all means.
This component is derived from _GUIBASE, and inherits the properties from that.
| Name | Description | Value |
| Name | Description | Value |
| ssNormal | This style is just the basic style - you will need to add other styles to make the static control into whatever you want it to be. However, you will ALWAYS need to include this style, unless you have something special in mind. | AvWind |
| The following options are a little different. Whereas the above options are a mixture of styles to create one type of object, the following styles are by themselves. You can mix them up to make more customised objects. You mix the styles with the OR (|) operator. You can even mix them with the above styles to enhance them further. Mix and match away! | ||
| ssBitmap | This style specifies that the static control is to contain a bitmap. Nice and simple. | SS_BITMAP |
| ssIcon | This style will make the static control able to accept and display icons. | SS_ICON |
| ssWMFFile | WMF's? Who uses them? Lots of clipart does... anyway, with this style, you will be able to set the static control to display a WMF (Windows Meta File - a vector-based drawing format). | SS_METAPIC |
|
ssCentreImage ssRightImage | This style will make the image be centred or right aligned in the static controls total area, if the total area is bigger than the image. Simple, right? |
SS_CENTERIMAGE SS_RIGHTIMAGE |
| ssRealSizeImage | This style causes the image to be shown its usual size. The static control will then ignore your requests to resize the image. | SS_REALSIZEIMAGE |
|
ssBlackFrame ssGreyFrame ssWhiteFrame | A static control with any one of these styles will have a coloured border around the edge - but nothing else. |
SS_BLACKFRAME SS_GRAYFRAME SS_WHITEFRAME |
|
ssBlackBox ssGreyBox ssWhiteBox | These styles make the static control into one big coloured box. No text, nothing else but filled colour. |
SS_BLACKRECT SS_GRAYRECT SS_WHITERECT |
| ssSunken | This style makes the static control take on a sunken look. You can add this to a static that displays images or a box or even to text. | SS_SUNKEN |
| ssEtchedBox | This style makes the static control look like an etched box. Simple enough... | SS_ETCHEDFRAME |
|
ssEtchedHorizontal ssEtchedVertical | These styles make the static control look like one of those fancy etched lines. The first style creates a horizontal line, and the second creates a vertical line. |
SS_ETCHEDHORZ SS_ETCHEDVERT |
|
ssCentreAligned ssLeftAligned ssLeftWithNoWordWrap ssRightAligned ssRightJustified | All of these styles do similar things, but different ways. The styles with just 'xxxxAligned' all align the text in the xxxx side, and if the text is too long, it will be wrapped to the next line. The ssLeftWithNoWordWrap style aligns the text on the left and does not wrap lines that are too long. The last style, ssRightJustified... well, I used to know what it does, but I can't find that bit of documentation now... I think it justifies the text within the static control's area. |
SS_CENTER SS_LEFT SS_LEFTNOWORDWRAP SS_RIGHT SS_RIGHTJUST |
| ssProperlyFormatAmpersand | Ordinarily when you assign a caption to a control, the ampersand (&) has a special meaning. An ampersand means to put an underline under the next letter, indicating that that letter is a shortcut key. Unfortunately, static controls understand this too, and if they see an ampersand in the caption - the next letter will be underlined. And no, you can not underline the whole caption by putting an ampersand in front of each letter - only the last ampersand will be detected and used (the others evapourate). Normally you can use a double ampersand (&&) to print an ordinary single ampersand, but that might not be appropriate, so you can use this style to prevent the processing of ampersands. | SS_NOPREFIX |
| ssSimple | This style specifies that the static control is just to be a simple, single-line text control. Text will not wrap to the next line if it is too long. | SS_SIMPLE |
| ssNotify | This stlye enables the static control to send 'I've been clicked' and 'I've been double-clicked' messages to it's parent window. You don't need this unless you intend to use the OnClick or OnDoubleClick event handlers, or you want to handle that event yourself. You can get raw clicks with the OnMouseDown and OnMouseUp events (inherited from _GUIBASE). | SS_NOTIFY |
| Prototype | Description |
| void SetBackgroundColour(COLORREF Colour); | This function sets the colour that will act as the background colour when the static control is repainted. This colour will only come into effect when the static control is repainted, and will only be used if you are using the GUI controller. This extention of the GUI controller rarely seems to work. |
|
void SetStaticIcon(HICON Icon); void SetStaticBitmap(HBITMAP Bitmap); | These two functions set an image for the static control. These pictures can be either an icon or a bitmap, based on which function you use. They take either a HICON or a HBITMAP. If you just want to load a bitmap from a resource, set the caption of the static control to the name of the resource - and make sure that you have set all the appropriate styles. |
| HICON GetStaticIcon(void); | This function returns the icon that is currently in the static control. It could be useful for gaining an icon loaded from resources... |
| HBITMAP GetStaticBitmap(void); | This function returns the bitmap that is currently in the static control. It could be useful for gaining an icon loaded from resources... |
Please note that the events listed here are done in pairs; one as a property, and the other as a function. The property is assigned a function name, ie. Object.OnClick = &FunctionName, whilst the function is called to verify that an event has occured. Please see the chapter on event handling for information on how to use these correctly.
| Prototype | Description | Sent under |
|
bool CheckClicked(wParam, lParam); void (*OnClick)(fSTATIC* Sender); | This event occurs when the static control was clicked. Please note that this event will only be sent if the static control has the ssNotify style. | WM_COMMAND |
|
bool CheckDoubleClicked(wParam, lParam); void (*OnDoubleClick)(fSTATIC* Sender); | This event occurs when the static control is double clicked. This event is only sent if the static control has the ssNotify style. | WM_COMMAND |
The following snippet gives a basic idea of how to use this component.
//Create a static control....
fSTATIC Static;
Static.CreateWin(Window.GetHandle(), "This is a test...", STATIC_ID,
ssUsual, ssNormal | ssSimple);
//The above static just displays text. Move it to wherever
//you want.
Static.Destroy();
//Here, try something a little fancier. If you add a resource
//to your resource file, say mypicture.bmp, and you make it's
//name MyPicture, then you can load and display the resource like
//this:
Static.CreateWin(Window.GetHandle(), "MyPicture", STATIC_ID,
ssUsual, ssNormal | ssBitmap | ssRealSizeImage);
//Now just move it to wherever you want!
| Back to index | The FreeFoote Foundation Classes Documentation |