cWinApp Struct Reference

Inheritance diagram for cWinApp

Inheritance graph

Collaboration diagram for cWinApp:

Collaboration graph


Public Methods

bool cWinApp_defproc (struct cWinApp *ptr_win_app, struct Message *ptr_message)
bool cWinApp_pause (struct cWinApp *ptr_win_app, clock_t timeout)
struct DisplayGraphicscWinApp_init_display (void)
void cWinApp_clear_screen (void)
void cWinApp_cancel_shutup (struct cWinApp *ptr_win_app)
void cWinApp_ext_cancel_shutup (void)
struct ProcesscWinApp_request_focus (struct cWinApp *ptr_win_app)
bool cWinApp_has_focus (struct cWinApp *ptr_win_app)
struct DisplayGraphicscWinApp_get_display (void)
struct MessagecWinApp_peek_message (struct cWinApp *ptr_win_app, bool remove, int min, int max)
struct MessagecWinApp_get_message (struct cWinApp *ptr_win_app, long timeout, int min, int max)
void cWinApp_put_message (struct cWinApp *ptr_win_app, struct Message *ptr_message)
char* cWinApp_get_name (struct cWinApp *ptr_win_app)
void cWinApp_Disconnect (struct cWinApp *ptr_win_app)
bool cWinApp_Select (struct cWinApp *ptr_win_app)
void cWinApp_update (struct cWinApp *ptr_win_app)
struct cClipcWinApp_GetParent (struct cWinApp *ptr_win_app)
void cWinApp_Hide (struct cWinApp *ptr_win_app)
void cWinApp_Show (struct cWinApp *ptr_win_app)
void cWinApp_Disable (struct cWinApp *ptr_win_app)
void cWinApp_Enable (struct cWinApp *ptr_win_app)
void cWinApp_AddObj (struct cWinApp *ptr_win_app, struct cObject *ptr_object, int x, int y)
void cWinApp_InsObj (struct cWinApp *ptr_win_app, struct cObject *ptr_object, int x, int y, int index)
void cWinApp_RemObj (struct cClip *ptr_win_app, struct cObject *ptr_object)
bool cWinApp_SelectFirst (struct cWinApp *ptr_win_app)
bool cWinApp_SelectPrev (struct cWinApp *ptr_win_app, bool round)
bool cWinApp_SelectNext (struct cWinApp *ptr_win_app, bool round)
void cWinApp_Scroll (struct cWinApp *ptr_win_app, struct rect_t *rectangle)
void cWinApp_Scroll_Ex (struct cWinApp *ptr_win_app, int x, int y)
void cWinApp_SendScroll (struct cWinApp *ptr_win_app)
int cWinApp_GetShifty (struct cWinApp *ptr_win_app)
int cWinApp_GetShiftx (struct cWinApp *ptr_win_app)
int cWinApp_GetCount (struct cWinApp *ptr_win_app)
struct cObjectcWinApp_get_by_index (struct cWinApp *ptr_win_app, int index)
int cWinApp_FindObj (struct cWinApp *ptr_win_app, struct cObject *ptr_object)
struct cObjectcWinApp_GetSelectedObject (struct cWinApp *ptr_win_app)


Detailed Description

The cWinApp structure is your application object. It implements cywin's functions, to work with user's objects such as: cBitmap, cEdit, cList, cItem, etc.

You must make a pointer to it using the init_module function.

See also:
Application


Member Function Documentation

void cWinApp_AddObj ( struct cWinApp * ptr_win_app,
struct cObject * ptr_object,
int x,
int y )
 

Adds an object to the cWinApp in position (x, y).

Parameters:
ptr_win_app   A pointer to the initialized cWinApp structure
ptr_object   A pointer to the initialized cObject structure
x   x-coordinate of the new object
y   y-coordinate of the new object
Returns:
None
   #include <cywin.h>
     ...
     struct cButton button;
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     cButton_ctor( &button, "Button text", mrOk );
     // Puts the 'button' object on the Cybiko screen.
     // It's the same as using the cClip_AddObj( &button ) function.
     cWinApp_AddObj( main_module.m_process, &button, 20, 50 );
     ...
     cButton_dtor( &button, LEAVE_MEMORY );

void cWinApp_Disable ( struct cWinApp * ptr_win_app )
 

Disables a cWinApp object so that it cannot be selected.

Parameters:
ptr_win_app   A pointer to the initialized cWinApp structure
Returns:
None

void cWinApp_Disconnect ( struct cWinApp * ptr_win_app )
 

Disconnects a cWinApp from its parent object.

Parameters:
ptr_win_app   A pointer to the initialized cWinApp structure
Returns:
None

void cWinApp_Enable ( struct cWinApp * ptr_win_app )
 

Enables a cWinApp object so that it may be selected.

Parameters:
ptr_win_app   A pointer to the initialized cWinApp structure
Returns:
None

int cWinApp_FindObj ( struct cWinApp * ptr_win_app,
struct cObject * ptr_object )
 

Returns a child object's index in cWinApp (or -1).

Parameters:
ptr_win_app   A pointer to the initialized cClip structure
ptr_object   A pointer to the needed cObject
Returns:
The child object's index in cWinApp (or -1).
   #include <cywin.h>
     ...
     struct cButton button1;
     struct cButton button2;
     struct cButton button3;
     struct module_t main_module;
     struct cObject * currentObj;
     int nButtonNumber;
     int i;
     ...
     init_module( &main_module );
     ...
     cButton_ctor( &button1, "Button text 1", mrOk );
     cWinApp_AddObj( main_module.m_process, &button1, 20, 50 );
     ...
     cButton_ctor( &button2, "Button text 2", mrOk );
     cWinApp_InsObj( main_module.m_process, &button2, 20, 50, 1 );
     ...
     // It's the same as using the cClip_InsObj( &button3 ) function.
     cButton_ctor( &button3, "Button text 3", mrOk );
     cWinApp_InsObj( main_module.m_process, &button3, 20, 50, 2 );
     ...
      // Finds the object.
     if ( cWinApp_FindObj( main_module.m_process, &button2 ) != -1 )
     ...
     cButton_dtor( &button, LEAVE_MEMORY );

int cWinApp_GetCount ( struct cWinApp * ptr_win_app )
 

Returns a count of child objects.

Parameters:
ptr_win_app   A pointer to the initialized cClip structure
Returns:
Child objects count
   #include <cywin.h>
     ...
     struct cButton button1;
     struct cButton button2;
     struct cButton button3;
     struct module_t main_module;
     int nButtonNumber;
     ...
     init_module( &main_module );
     ...
     cButton_ctor( &button1, "Button text 1", mrOk );
     cWinApp_AddObj( main_module.m_process, &button1, 20, 50 );
     ...
     cButton_ctor( &button2, "Button text 2", mrOk );
     cWinApp_InsObj( main_module.m_process, &button2, 20, 50, 1 );
     ...
     // It's the same as using the cClip_InsObj( &button3 ) function.
     cButton_ctor( &button3, "Button text 3", mrOk );
     cWinApp_InsObj( main_module.m_process, &button3, 20, 50, 2 );
     ...
     // nButtonNumber will be equal to 3.
     nButtonNumber = cWinApp_GetCount( main_module.m_process );
     ...
     cButton_dtor( &button, LEAVE_MEMORY );

struct cClip * cWinApp_GetParent ( struct cWinApp * ptr_win_app )
 

Returns a pointer to the parent object.

Parameters:
ptr_win_app   A pointer to the initialized cWinApp structure
Returns:
A pointer to the parent object

struct cObject * cWinApp_GetSelectedObject ( struct cWinApp * ptr_win_app )
 

Returns the currently selected object.

Parameters:
ptr_win_app   A pointer to the initialized cClip structure
Returns:
The currently selected object
   #include <cywin.h>
     ...
     struct cButton button1;
     struct cButton button2;
     struct cButton button3;
     struct module_t main_module;
     struct cObject * selectedObj;
     int nButtonNumber;
     int i;
     ...
     init_module( &main_module );
     ...
     cButton_ctor( &button1, "Button text 1", mrOk );
     cWinApp_AddObj( main_module.m_process, &button1, 20, 50 );
     ...
     cButton_ctor( &button2, "Button text 2", mrOk );
     cWinApp_InsObj( main_module.m_process, &button2, 20, 50, 1 );
     ...
     // It's the same as using the cClip_InsObj( &button3 ) function.
     cButton_ctor( &button3, "Button text 3", mrOk );
     cWinApp_InsObj( main_module.m_process, &button3, 20, 50, 2 );
     ...
     cObject_Select( &button2 );
     ...
     // Redraws selected objects.
     cButton_update( cWinApp_GetSelectedObject( main_module.m_process );
     ...
     cButton_dtor( &button, LEAVE_MEMORY );

int cWinApp_GetShiftx ( struct cWinApp * ptr_win_app )
 

Returns the 'x' coordinate shift (as a result of scrolling).

Parameters:
ptr_win_app   A pointer to the initialized cClip structure
Returns:
'x' coordinate shift (as a result of scrolling).
   #include <cywin.h>
     ...
     struct cBitmap cbmp;
     struct Bitmap bmp;
     struct module_t main_module;
     int nShift_X;
     ...
     init_module( &main_module );
     ...
     // Creates a bitmap from the file "root.ico".
     Bitmap_ctor_Ex1( &bmp, "root.ico" );
     cBitmap_ctor( &cbmp, &bmp );
     // Puts the cBitmap object on the Cybiko screen.
     cWinApp_AddObj( main_module.m_process, &cbmp, 160, 240 );
     ...
     // Scrolls the bitmap to the visible area.
     cWinApp_Scroll_Ex( main_module.m_process, -160, -240 );
     cWinApp_SendScroll( main_module.m_process );
     // nShift_X will be equal to -160.
     nShift_X = cWinApp_GetShiftx( main_module.m_process );
     ...
     cBitmap_dtor( &cbmp, LEAVE_MEMORY );
     Bitmap_dtor( &bmp, LEAVE_MEMORY );
See also:
cWinApp_GetShifty.

int cWinApp_GetShifty ( struct cWinApp * ptr_win_app )
 

Returns the 'y' coordinate shift (as a result of scrolling).

Parameters:
ptr_win_app   A pointer to the initialized cClip structure
Returns:
'y' coordinate shift (as a result of scrolling)
   #include <cywin.h>
     ...
     struct cBitmap cbmp;
     struct Bitmap bmp;
     struct module_t main_module;
     int nShift_Y;
     ...
     init_module( &main_module );
     ...
     // Creates a bitmap from the file "root.ico".
     Bitmap_ctor_Ex1( &bmp, "root.ico" );
     cBitmap_ctor( &cbmp, &bmp );
     // Puts the cBitmap object on the Cybiko screen.
     cWinApp_AddObj( main_module.m_process, &cbmp, 160, 240 );
     ...
     // Scrolls the bitmap to the visible area.
     cWinApp_Scroll_Ex( main_module.m_process, -160, -240 );
     cWinApp_SendScroll( main_module.m_process );
     // nShift_Y will be equal to -240.
     nShift_Y = cWinApp_GetShifty( main_module.m_process );
     ...
     cBitmap_dtor( &cbmp, LEAVE_MEMORY );
     Bitmap_dtor( &bmp, LEAVE_MEMORY );
     ...
See also:
cWinApp_GetShiftx.

void cWinApp_Hide ( struct cWinApp * ptr_win_app )
 

Hides a cWinApp object.

Parameters:
ptr_win_app   A pointer to the initialized cWinApp structure
Returns:
None
See also:
cWinApp_Show.

void cWinApp_InsObj ( struct cWinApp * ptr_win_app,
struct cObject * ptr_object,
int x,
int y,
int index )
 

Adds an object to the cWinApp in position (x, y) with a z-position index (maximal index is on the top).

Parameters:
ptr_win_app   A pointer to the initialized cWinApp structure
ptr_object   A pointer to the initialized cObject structure
x   x-coordinate of the new object
y   y-coordinate of the new object
index   The index of the new object's z-position
Returns:
None
   #include <cywin.h>
     ...
     struct cButton button1;
     struct cButton button2;
     struct cButton button3;
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     cButton_ctor( &button1, "Button text 1", mrOk );
     cWinApp_AddObj( main_module.m_process, &button1, 20, 50 );
     ...
     cButton_ctor( &button2, "Button text 2", mrOk );
     cWinApp_InsObj( main_module.m_process, &button2, 20, 50, 1 );
     ...
     // It's the same as using the cClip_InsObj( &button3 ) function.
     cButton_ctor( &button3, "Button text 3", mrOk );
     cWinApp_InsObj( main_module.m_process, &button3, 20, 50, 2 );
     ...
     cButton_dtor( &button, LEAVE_MEMORY );

void cWinApp_RemObj ( struct cClip * ptr_win_app,
struct cObject * ptr_object )
 

Removes an object from cWinApp.

Parameters:
ptr_win_app   A pointer to the initialized cClip structure
ptr_object   A pointer to the initialized cObject structure
Returns:
None
   #include <cywin.h>
     ...
     struct cButton button;
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     cButton_ctor( &button, "Button text", mrOk );
     // Puts the 'button' object on the Cybiko screen.
     // It's the same as using the cClip_AddObj( &button ) function.
     cWinApp_AddObj( main_module.m_process, &button, 20, 50 );
     ...
     // It's the same as using the cClip_RemObj( &button ) function.
     cClip_RemObj( main_module.m_process, &button );
     cButton_dtor( &button, LEAVE_MEMORY );

void cWinApp_Scroll ( struct cWinApp * ptr_win_app,
struct rect_t * rectangle )
 

Scrolls a cWinApp to make a rectangle visible.
Provides minimal scrolling.

Parameters:
ptr_win_app   A pointer to the initialized cClip structure
rectangle   A pointer to the initialized rect_t structure
Returns:
None
   #include <cywin.h>
     ...
     struct cBitmap cbmp;
     struct Bitmap bmp;
     struct module_t main_module;
     struct rect_t rect;
     ...
     init_module( &main_module );
     ...
     // Creates a bitmap from the file "root.ico".
     Bitmap_ctor_Ex1( &bmp, "root.ico" );
     cBitmap_ctor( &cbmp, &bmp );
     // Puts the cBitmap object on the Cybiko screen.
     cWinApp_AddObj( main_module.m_process, &cbmp, 160, 240 );
     ...
     rect_set( &rect, 160, 240, bmp.h, bmp.w );
     // Scrolls the bitmap to the visible area.
     cWinApp_Scroll( main_module.m_process, &rect );
     ...
     cBitmap_dtor( &cbmp, LEAVE_MEMORY );
     Bitmap_dtor( &bmp, LEAVE_MEMORY );
     ...
See also:
cWinApp_Scroll_Ex.

void cWinApp_Scroll_Ex ( struct cWinApp * ptr_win_app,
int x,
int y )
 

Scrolls a cWinApp by (x, y), but cannot exceed the child's boundaries.

Parameters:
ptr_win_app   A pointer to the initialized cClip structure
x   An "x" coordinate shift
y   An "y" coordinate shift
Returns:
None
   #include <cywin.h>
     ...
     struct cBitmap cbmp;
     struct Bitmap bmp;
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     // Creates a bitmap from the file "root.ico".
     Bitmap_ctor_Ex1( &bmp, "root.ico" );
     cBitmap_ctor( &cbmp, &bmp );
     // Puts the cBitmap object on the Cybiko screen.
     cWinApp_AddObj( main_module.m_process, &cbmp, 160, 240 );
     ...
     rect_set( &rect, 160, 240, bmp.h, bmp.w );
     // Scrolls the bitmap to the visible area.
     cWinApp_Scroll_Ex( main_module.m_process, -160, -240);
     ...
     cBitmap_dtor( &cbmp, LEAVE_MEMORY );
     Bitmap_dtor( &bmp, LEAVE_MEMORY );
     ...
See also:
cWinApp_Scroll.

bool cWinApp_Select ( struct cWinApp * ptr_win_app )
 

Selects a cWinApp object.

Parameters:
ptr_win_app   A pointer to the initialized cWinApp structure
Returns:
TRUE if the object was selected

bool cWinApp_SelectFirst ( struct cWinApp * ptr_win_app )
 

Selects the first object in the cWinApp.

Parameters:
ptr_win_app   A pointer to the initialized cClip structure
Returns:
FALSE if the function failed.
   #include <cywin.h>
     ...
     struct cButton button1;
     struct cButton button2;
     struct cButton button3;
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     cButton_ctor( &button1, "Button text 1", mrOk );
     cWinApp_AddObj( main_module.m_process, &button1, 20, 50 );
     ...
     cButton_ctor( &button2, "Button text 2", mrOk );
     cWinApp_InsObj( main_module.m_process, &button2, 20, 50, 1 );
     ...
     // It's the same as using the cClip_InsObj( &button3 ) function.
     cButton_ctor( &button3, "Button text 3", mrOk );
     cWinApp_InsObj( main_module.m_process, &button3, 20, 50, 2 );
     ...
     // Selects the first button.
     cWinApp_SelectFirst( main_module.m_process );
     ...
     cButton_dtor( &button, LEAVE_MEMORY );
See also:
cWinApp_SelectPrev, cWinApp_SelectNext.

bool cWinApp_SelectNext ( struct cWinApp * ptr_win_app,
bool round )
 

Selects the next object in the cWinApp.

Parameters:
ptr_win_app   A pointer to the initialized cClip structure
round   TRUE if you need to select the last object after selecting the first
Returns:
FALSE if the function failed
   #include <cywin.h>
     ...
     struct cButton button1;
     struct cButton button2;
     struct cButton button3;
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     cButton_ctor( &button1, "Button text 1", mrOk );
     cWinApp_AddObj( main_module.m_process, &button1, 20, 50 );
     ...
     cButton_ctor( &button2, "Button text 2", mrOk );
     cWinApp_InsObj( main_module.m_process, &button2, 20, 50, 1 );
     ...
     // It's the same as using the cClip_InsObj( &button3 ) function.
     cButton_ctor( &button3, "Button text 3", mrOk );
     cWinApp_InsObj( main_module.m_process, &button3, 20, 50, 2 );
     ...
     // Selects the first button.
     cWinApp_SelectFirst( main_module.m_process );
     ...
     // Selects the next button.
     cWinApp_SelectNext( main_module.m_process , TRUE);
     cButton_dtor( &button, LEAVE_MEMORY );
See also:
cWinApp_SelectFirst, cWinApp_SelectPrev.

bool cWinApp_SelectPrev ( struct cWinApp * ptr_win_app,
bool round )
 

Selects the previous object in cWinApp.

Parameters:
ptr_win_app   A pointer to the initialized cClip structure
round   TRUE if you need to select the last object after selecting the first
Returns:
FALSE if the function failed
   #include <cywin.h>
     ...
     struct cButton button1;
     struct cButton button2;
     struct cButton button3;
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     cButton_ctor( &button1, "Button text 1", mrOk );
     cWinApp_AddObj( main_module.m_process, &button1, 20, 50 );
     ...
     cButton_ctor( &button2, "Button text 2", mrOk );
     cWinApp_InsObj( main_module.m_process, &button2, 20, 50, 1 );
     ...
     // It's the same as using the cClip_InsObj( &button3 ) function.
     cButton_ctor( &button3, "Button text 3", mrOk );
     cWinApp_InsObj( main_module.m_process, &button3, 20, 50, 2 );
     ...
     // Selects the first button.
     cWinApp_SelectFirst( main_module.m_process );
     ...
     // Selects the previous button.
     cWinApp_SelectPrev( main_module.m_process , TRUE);
     cButton_dtor( &button, LEAVE_MEMORY );
See also:
cWinApp_SelectFirst, cWinApp_SelectNext.

void cWinApp_SendScroll ( struct cWinApp * ptr_win_app )
 

Forces this object to redraw its scrolling arrows.

Parameters:
ptr_win_app   A pointer to the initialized cClip structure
Returns:
None
   #include <cywin.h>
     ...
     struct cBitmap cbmp;
     struct Bitmap bmp;
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     // Creates a bitmap from the file "root.ico".
     Bitmap_ctor_Ex1( &bmp, "root.ico" );
     cBitmap_ctor( &cbmp, &bmp );
     // Puts the cBitmap object on the Cybiko screen.
     cWinApp_AddObj( main_module.m_process, &cbmp, 160, 240 );
     ...
     // Scrolls the bitmap to the visible area.
     cWinApp_Scroll_Ex( main_module.m_process, -160, -240 );
     cWinApp_SendScroll( main_module.m_process );
     ...
     cBitmap_dtor( &cbmp, LEAVE_MEMORY );
     Bitmap_dtor( &bmp, LEAVE_MEMORY );
     ...

void cWinApp_Show ( struct cWinApp * ptr_win_app )
 

Shows a cWinApp object.

Parameters:
ptr_win_app   A pointer to the initialized cWinApp structure
Returns:
None
See also:
cWinApp_Hide.

void cWinApp_cancel_shutup ( struct cWinApp * ptr_win_app )
 

Cancels the MSG_SHUTUP message.
Used to cancel a task switch operation previously launched by another application in the task manager. Deletes all MSG_SHUTUP messages from the message queue. Requires a cWinApp object pointer.

Parameters:
ptr_win_app   A pointer to the cWinApp initialized structure
Returns:
None
   #include <cywin.h>
     ...
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     ptr_message = cWinApp_get_message( main_module.m_process, 0, 1, MSG_USER );
     if( ptr_message->msgid == MSG_SHUTUP)
     {
       // We cancel shutup and delete all MSG_SHUTUP messages.
       cWinApp_cancel_shutup( main_module.m_process );
       ...
     }
     ...
See also:
MSG_SHUTUP, cWinApp_ext_cancel_shutup.

void cWinApp_clear_screen ( void )
 

Clears the screen with the color white.

Returns:
None
   #include <cywin.h>
     ...
     struct DisplayGraphics* ptr_gfx;
     ...
     // Clears the screen.
     cWinApp_clear_screen();
     ...
     // Draws the filled rectangle.
     ptr_gfx = cWinApp_init_display();
     DisplayGraphics_set_color( ptr_gfx , CLR_BLACK );
     DisplayGraphics_fill_rect( ptr_gfx , 5, 5, 30, 30 );
     DisplayGraphics_show( ptr_gfx );
     ...

bool cWinApp_defproc ( struct cWinApp * ptr_win_app,
struct Message * ptr_message )
 

The Message-processing function.

Parameters:
ptr_win_app   A pointer to the cWinApp object
ptr_message   A pointer to the processed message
Returns:
TRUE if the message was processed
   #include <cywin.h>
     ...
     struct module_t main_module;
     struct Message* ptr_message;
     ...
     init_module( &main_module );
     ...
     ptr_message = cWinApp_get_message( main_module.m_process, 0, 1, MSG_USER );
     if ( ptr_message->msgid == MSG_KEYDOWN )
     {
       //  If user presses the '?' button, help will be shown.
       cWinApp_defproc( main_module.m_process, ptr_message);
     }
     ...

void cWinApp_ext_cancel_shutup ( void )
 

Cancels the MGS_SHUTUP message statically.
Used to cancel a task switch operation previously launched by another application in the task manager. Doesn't require a cWinApp object pointer, but doesn't delete any other MSG_SHUTUP messages.

Returns:
None
   #include <cywin.h>
     ...
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     ptr_message = cWinApp_get_message( main_module.m_process, 0, 1, MSG_USER );
     if( ptr_message->msgid == MSG_SHUTUP)
     {
       // We cancel shutup.
       cWinApp_ext_cancel_shutup();
       ...
     }
     ...
See also:
MSG_SHUTUP, cWinApp_cancel_shutup.

struct cObject * cWinApp_get_by_index ( struct cWinApp * ptr_win_app,
int index )
 

Returns an object with its index.

Parameters:
ptr_win_app   A pointer to the initialized cClip structure
index   Index of the object in cWinApp
Returns:
The object with its index
   #include <cywin.h>
     ...
     struct cButton button1;
     struct cButton button2;
     struct cButton button3;
     struct module_t main_module;
     struct cObject * currentObj;
     int nButtonNumber;
     int i;
     ...
     init_module( &main_module );
     ...
     cButton_ctor( &button1, "Button text 1", mrOk );
     cWinApp_AddObj( main_module.m_process, &button1, 20, 50 );
     ...
     cButton_ctor( &button2, "Button text 2", mrOk );
     cWinApp_InsObj( main_module.m_process, &button2, 20, 50, 1 );
     ...
     // It's the same as using the cClip_InsObj( &button3 ) function.
     cButton_ctor( &button3, "Button text 3", mrOk );
     cWinApp_InsObj( main_module.m_process, &button3, 20, 50, 2 );
     ...
     // Redraws all objects.
     for ( i=0; i<cWinApp_GetCount( main_module.m_process ); i++)
     {
       cButton_update( cWinApp_get_by_index( main_module.m_process, i) );
     }
     ...
     cButton_dtor( &button, LEAVE_MEMORY );

struct DisplayGraphics * cWinApp_get_display ( void )
 

Returns the graphics context.

Returns:
The graphics context
   #include <cywin.h>
     ...
     struct Bitmap bmp;
     ...
     // Creates a bitmap from the file "root.ico".
     Bitmap_ctor_Ex1( &bmp, "root.ico" );
     ...
     // Draws bitmap.
     Graphics_draw_bitmap( cWinApp_get_display(), &bmp, 30, 40, BM_NORMAL );
     ...
     Bitmap_dtor( &bmp, LEAVE_MEMORY );
     ...

struct Message * cWinApp_get_message ( struct cWinApp * ptr_win_app,
long timeout,
int min,
int max )
 

The calling thread waits until the first message that fits the specified range appears in the queue.
Be careful not to overload the queue. Call Message_delete() when you finish with the message.

Parameters:
ptr_win_app   A pointer to the initialized cWinApp object
timeout   Timeout value (in milliseconds)
min   Retrieves the minimum ID of the message in the queue
max   Retrieves the maximum ID of the message in the queue
Returns:
Pointer to the Message if there is one in the process' queue
   #include <cywin.h>
     ...
     struct module_t main_module;
     struct Message* ptr_message;
     ...
     init_module( &main_module );
     ...
     ptr_message = cWinApp_get_message( main_module.m_process, 0, 1, MSG_USER );
     if( ptr_message->msgid == MSG_KEYDOWN )
     {
       if( Message_get_key_param( ptr_message )->scancode == KEY_ESC )
       {
         // Processes key 'Esc'.
       }
     }
   ...
See also:
Message_delete

char * cWinApp_get_name ( struct cWinApp * ptr_win_app )
 

Returns the message queue's name.

Parameters:
ptr_win_app   A pointer to the initialized cWinApp structure
Returns:
The message queue's name

bool cWinApp_has_focus ( struct cWinApp * ptr_win_app )
 

Checks whether the application has the focus.

Parameters:
ptr_win_app   A pointer to the cWinApp initialized structure
Returns:
TRUE if the application has the focus
   #include <cywin.h>
   ...
   cWinApp_request_focus( main_module.m_process );
   ...
   if( cWinApp_has_focus( main_module.m_process ) )
   {
     // Draws something.
     ...
   }
   ...

struct DisplayGraphics * cWinApp_init_display ( void )
 

Obtains the graphics context.

Returns:
A pointer to the DisplayGraphics object
   #include <cywin.h>
     ...
     struct DisplayGraphics* ptr_gfx;
     ...
     // Clears the screen.
     cWinApp_clear_screen();
     ...
     // Draws a filled rectangle.
     ptr_gfx = cWinApp_init_display();
     DisplayGraphics_set_color( ptr_gfx , CLR_BLACK );
     DisplayGraphics_fill_rect( ptr_gfx , 5, 5, 30, 30 );
     DisplayGraphics_show( ptr_gfx );
     ...

bool cWinApp_pause ( struct cWinApp * ptr_win_app,
clock_t timeout )
 

Pauses execution of the thread.

Parameters:
ptr_win_app   A pointer to the cWinApp initialized structure
timeout   The time span to sleep (in milliseconds)
Returns:
FALSE if the timeout has passed
   #include <cywin.h>
     ...
     play_tone(30);
     cWinApp_pause(main_module.m_process, 200);
     play_tone(-1);
     ...

struct Message * cWinApp_peek_message ( struct cWinApp * ptr_win_app,
bool remove,
int min,
int max )
 

Peeks or gets a message from queue.
If 'remove' is TRUE, the message will be removed. This function does not wait for a message to be available, it returns 0 immediately it there are no messages in the specified range. Don't use it unless you really need it.

Parameters:
ptr_win_app   A pointer to the initialized cWinApp object
remove   If TRUE, the message will be removed from the message queue
min   Retrieves the minimum ID of the message in the queue.
max   Retrieves the maximum ID of the message in the queue
Returns:
A pointer to the Message if there is one in the process' queue; otherwise 0
   #include <cywin.h>
     ...
     struct module_t main_module;
     struct Message* ptr_message;
     ...
     init_module( &main_module );
     ...
     // Removes all keyboard messages from the queue.
     while(ptr_message = cWinApp_peek_message( main_module.m_process, 0, MSG_KEYDOWN, MSG_KEYDOWN ))
     {
       Message_delete( ptr_message );
     }
     ...

void cWinApp_put_message ( struct cWinApp * ptr_win_app,
struct Message * ptr_message )
 

Puts a Message in the Queue.

Parameters:
ptr_win_app   A pointer to the initialized cWinApp object
ptr_message   A pointer to the message to send
Returns:
None
   #include <cywin.h>
   #define MSG_MAKE_TASK MSG_USER + 1
     ...
     struct module_t main_module;
     struct Message* ptr_message;
     ...
     init_module( &main_module );
     ...
     ptr_message = cWinApp_get_message( main_module.m_process, 0, 1, MSG_MAKE_TASK );
     if( ptr_message->msgid == MSG_MAKE_TASK )
     {
       cWinApp_pause( main_module.m_process, 250 );
       cWinApp_put_message( main_module.m_process, ptr_message );
     }
     else
     {
       Message_delete( ptr_message );
     }
     ...

struct Process * cWinApp_request_focus ( struct cWinApp * ptr_win_app )
 

Requests focus for the application.

Parameters:
ptr_win_app   A pointer to the cWinApp initialized structure
Returns:
A pointer to a Process object
   #include <cywin.h>
     ...
     cWinApp_request_focus( main_module.m_process );
     ...
     if( cWinApp_has_focus( main_module.m_process ) )
     {
       // Draws something.
       ...
     }
     ...

void cWinApp_update ( struct cWinApp * ptr_win_app )
 

Updates a cWinApp object.

Parameters:
ptr_win_app   A pointer to the initialized cWinApp structure
Returns:
None