| Header file: | application.h |
| Object name: | APPLICATION |
| Object Index: | 1 of 1 Object |
The APPLICATION object is a simple object - it merely registers your applications class name and handles a few other low-level things. You can change the applications icon from here, and terminate the application.
About the only thing that you need to keep in mind is that this object is global and already created for you - there should not be too much need for any more than one of these. The global object is called APPLICATION, and you can go ahead and use the properties of that object from anywhere within your program.
| Name | Description | Value |
| asNormal | Just a standard application. | 0 |
| asNoWM_PAINT | Any windows created under this application style will not need to be repainted - Windows will store the window's contents and repaint it for you. This is advised only for use with small windows, as it takes up a large amount of memory to do this. | CS_SAVEBITS |
| asRedrawOnResize | This style makes any window redraw when it is resized - otherwise Windows will only send the paint message when the window has been enlarged. | CS_VREDRAW | CS_HREDRAW |
| asMultipleDCs | When Windows allocates it's Device Contexts (for graphics), each window will have it's own Device Context. There shouldn't be too much need for this. | CS_OWNDC |
| asChildrenOwnParentDC | Any child windows of another window will use their parents device context for drawing their graphics. Not hugely useful. | CS_PARENTDC |
| asOneDC | All windows that you create will use one Device context should you select this style. | CS_CLASSDC |
| asDisableCloseButton | With this style, all windows created will not have a close button. Use with caution! | CS_NOCLOSE |
| asEnhanceDrawing | Somehow this style enhances the drawing for any windows under this class. Don't ask me how this works! | CS_BYTEALIGNCLIENT |
| asEnhanceResizing | This style enhances resizing. Again, don't ask me how, it just does. | CS_BYTEALIGNWINDOW |
| Prototype | Description |
| bool CreateApp(char* ClassName, int Style, WNDPROC WindowProcedure); | This function registers and sets up the application classname. This is one of the first things you should be doing in your program (See the chapters on this). Replace ClassName with the classname you'd like your program to have (eg. FooBarClass), and style with a style (or combination of styles) from the table above. To combine styles, simply OR (|) the styles together. For WindowProceedure, replace that with a suitable WNDPROC function. However, if you are using the GUI controller and don't want to look at the message queue, then pass NULL. Passing NULL if you do not have the GUI controller will make the program fail. |
| char* GetAppClassName(void); | This function returns the classname that you specified when you created the application. |
| void SetLastInstance(HINSTANCE LastInstance); | By calling this function with the parameter given when WinMain was called, you have a reference of the last instance of your program. You can retrieve that instance with one of the following functions. |
| HINSTANCE GetInstance(void); | This function returns the instance of this current program. Instead of this you could also use GetModuleHandle(NULL);. |
| HINSTANCE GetLastInstance(void); | If you set the last instance with the value passed along in WinMain, you can retreive that here. This means that you can use this value anywhere in your program, rather than creating another global variable and saving the value there. |
| char* GetCmdLine(void); | This function returns the command line arguments. |
| void SetIcon(char* Name, int ID); | This sets the application's icon from a resource. Use either the resources name or it's ID number. If you don't use it's name, put NULL there, and if you don't use it's ID, put 0 (Zero) there. This is the large icon (32x32 version). |
| void SetIcon(HICON Icon); | If you have loaded an icon into a HICON type, you can apply it to the application with this function. |
| void SetIconSm(char* Name, int ID); | This function works exactly the same as the first SetIcon function, except for the fact that it sets the application's small icon (16x16 version). |
| void SetIconSm(HICON Icon); | Again, this works exactly the same way that the second SetIcon function works, except it applies to the small icon for the application. |
| void SetCursor(char* Name, int ID); | This function sets the cursor from the resources - either by name, or by ID number. If you use the ID number, name must be NULL, and if you use the Name, ID must be 0 (Zero). This cursor is the default cursor applied to all windows created by your application. |
| void SetCursor(HCURSOR Cursor); | This function is exactly the same as the above function, except that it takes the handle of an already loaded cursor. |
| void SetCursorFW(int ID); |
This function sets the cursor from one of Window's standard sets - or whatever they are under the theme the user has set them to. Use one of these ID's: (taken from the Win32 SDK Reference)
|
| void SetBrush(COLORREF Colour); | Sets the brush colour for all windows. It takes a colour, which can be integer or hexadecimal. Even better: specify in RGB format with the RGB Macro: RGB(R,G,B) - where R,G, and B are the amount of each colour, 0-255. For example, RGB(255,0,0) would be bright red. |
| void SetBrush(HBRUSH Brush); | Sets the brush colour for all windows. Takes a brush handle. |
| void SetBrush(int Brush); |
This sets the brush for the windows from one of Windows standard predefined set. Use the following to set this: (taken from the Win32 SDK Reference) BLACK_BRUSH - Black brush. DKGRAY_BRUSH - Dark gray brush. GRAY_BRUSH - Gray brush. HOLLOW_BRUSH - Hollow brush (equivalent to NULL_BRUSH). LTGRAY_BRUSH - Light gray brush. NULL_BRUSH - Null brush (equivalent to HOLLOW_BRUSH). WHITE_BRUSH - White brush. |
| void Terminate(void); | Terminates the application. Quickly. Ungracefully. Just gets the job done. |
| void SetMessageQueue(WNDPROC WindowProceedure); | Sets the application's window proceedure. Only applies if you have the GUI controller active, as otherwise the messages are routed to one place which you would have already defined. |
The following snippet gives a basic idea of how to use this component.
{
//In WinMain...
APPLICATION.SetIcon(NULL, 100); //Sets the big and small
APPLICATION.SetIconSm(NULL, 101);//icon for all windows.
APPLICATION.CreateApp("TestClassName", asNormal, WindProc);
// ^^ Creates the application.
APPLICATION.Terminate(); //Bye bye!
Please note that when setting properties such as the Icon and default window brushes, this must be done before the application is created, as these values are put in when the application is created. You can not change them afterwards (future consideration to correct this).
| Back to index | The FreeFoote Foundation Classes Documentation |