home *** CD-ROM | disk | FTP | other *** search
- #include "client.h"
-
- #include XColor_i
- #include XMessageBox_i
- #include XMenuBar_i
- #include XString_i
- #include XDDE_i
-
- #include <stdlib.h>
-
- SHORT volume = 50;
-
- class MyDDE: public XDDE
- {
- public:
- MyDDE( XWindow * w):XDDE(w, "Sample8", "SampleTopic"){;}
- void DataReceived( ULONG size, void * data, char * itemName, SHORT format);
- void Connected( OOL_WINDOWHANDLE handle);
- void DisConnected( void );
- };
-
-
- void MyDDE :: Connected( OOL_WINDOWHANDLE handle)
- {
- //init was succesful, we have a connect
- GetOwner()->SetText( "DDEClient - connected");
-
- //ask for data
- Advise();
- }
-
-
- void MyDDE :: DisConnected( void )
- {
- GetOwner()->SetText( "DDEClient - not connected");
- }
-
-
- void MyDDE :: DataReceived( ULONG size, void * data, char * itemName, SHORT format)
- {
- XString item = itemName;
- LONG id = 0;
-
- if(item == "FIELD1")
- id = ENTRY_ONE;
- if(item == "FIELD2")
- id = ENTRY_TWO;
- if(item == "FIELD3")
- id = ENTRY_THREE;
- if(item == "FIELD4")
- id = ENTRY_FOUR;
-
- if( id )
- {
- XFrameWindow * w = (XFrameWindow*) GetOwner();
- XWindow * entry = w->GetWindow( id );
- if( entry )
- entry->SetText( (char*) data );
- }
- }
-
-
- MyAppWindow :: MyAppWindow( XApplication * app, XResource * r ): XFrameWindow( r, "Sample8 - DDEClient", XFrameWindow::defaultDialogStyle | FRM_TASKLIST | FRM_CENTER, NULL, NULL, TRUE)
- {
- Show();
-
- Activate();
-
- //construct a dde
- dde = new MyDDE(this );
-
- //connect
- dde->Init();
- }
-
-
- MyAppWindow :: ~MyAppWindow()
- {
- dde->UnAdvise();
- delete dde;
- }
-
-
- MyApp :: MyApp(): XApplication()
- {
- XResource r( IDM_MAIN, GetResourceLibrary());
- window = new MyAppWindow( this, &r ); //create new framewindow (see above)
- }
-
- void main ( void)
- {
- MyApp * app = new MyApp(); //create a new application
- app->Start(); //let the application work
- }