Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Simple COM Client Server

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Simple COM Client Server

    NDA clear here is my first example. A very simple Client Server.

    Client:
    Code:
    '=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    'SED_PBWIN
    '=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    ' A simple Client / Server example
    '******************************************************************************
    '                                 James C. Fuller
    '                                  August 8,2008
    '                              [email protected]
    '------------------------------------------------------------------------------
    'COMPILE IBoxServer.Bas First
    'Then open the IBOX.TLB with PBRow to create the IBOX.INC File
    '******************************************************************************
    'Include file created with PBrow
    #INCLUDE "IBOX.INC"
    '------------------------------------------------------------------------------
    
    
    
    FUNCTION PBMAIN() AS LONG
    
    	LOCAL oIBox AS IIBOX
    	LOCAL sName AS STRING
    	oIBox = NEWCOM CLSID $CLSID_CIBOX LIB "IBOX.DLL"
    	IF ISNOTHING (oIBox)THEN
    		? "No oIBox"
    		EXIT FUNCTION
    	END IF
    	sName = oIBox.Show("Enter Name")
    
    	?"sName = "+sName
    
    END FUNCTION
    Server:
    Code:
    '=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    'SED_PBWIN
    '=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    'A very simple Com Server Example for use with IBOXCLIENT.BAS
    'Compile this first.
    '******************************************************************************
    '                            James C. Fuller
    '                            August 8, 2008
    '                         [email protected]
    '******************************************************************************
    #COMPILE DLL "IBOX.DLL
    #DIM ALL
    #COM NAME "IBOX"
    #COM GUID GUID$("{2594918F-1131-488C-A11E-CFAFB4A17D36}")
    
    
    $cIBoxGuid = GUID$("{4B512D6D-B7FF-40FB-80EE-B0224C8DB7D6}")
    $iIBoxGuid = GUID$("{D955C227-7321-448A-89EC-7DEEC9B9661A}")
    GLOBAL UserName AS STRING
    
    CLASS cIBox $cIBoxGuid AS COM
    	INSTANCE hDlg AS DWORD
    	INSTANCE Result,w AS LONG
    	INTERFACE iIBox $iIBoxGuid : INHERIT DUAL
    		METHOD Show<400>(BYVAL Param1 AS STRING) AS STRING
    			w = INT(LEN(Param1) * 5)   ' width of winidow
    			IF w < 105 THEN
    				w = 105
    			END IF
    			DIALOG NEW 0, Param1,,, (w + 40), 30 TO hDlg
    			CONTROL ADD TEXTBOX, hDlg, 101, "", 14,  9, (w - 28), 12
    			CONTROL ADD BUTTON, hDlg, %IDOK, "OK", w, 9, 30, 14, 1 CALL OkButton
    			CONTROL SET FOCUS hDlg,101
    			DIALOG SHOW MODAL hDlg TO Result
    			IF Result THEN
    				METHOD = UserName
    			END IF
    		END METHOD
    	END INTERFACE
    
    END CLASS
    
    
    
    CALLBACK FUNCTION OkButton () AS LONG
        IF CBCTLMSG = 0 THEN
            CONTROL GET TEXT CBHNDL, 101 TO UserName
            DIALOG END CBHNDL, 1
            FUNCTION = 1
        END IF
    END FUNCTION

    Attached is the source and the exe.


    James
    Attached Files
    Last edited by jcfuller; 12 Aug 2008, 04:25 PM.
Working...
X