For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > October 2004 > C program in VB









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author C program in VB
Don Hali

2004-10-30, 8:55 am

Hi

I received the code of a interface written i C, but I can't program in C.
Can someone interpret me this in VB?

/////////////////////////////////////////////////////////////////////////////
// CHotelTstAppDlg dialog

//Deklaration:

unsigned int CHotelTstAppDlg::m_UM_ELAPINotify = 0;





//Registrierung

BEGIN_MESSAGE_MAP(CHotelTstAppDlg, CDialog)
//{{AFX_MSG_MAP(CHotelTstAppDlg)
....
....
//}}AFX_MSG_MAP
ON_REGISTERED_MESSAGE(CHotelTstAppDlg::m
_UM_ELAPINotify, OnELAPINotify)
//internal service message
END_MESSAGE_MAP()






//Aufruf von Connect mit Parameterübergabe:


void CHotelTstAppDlg::OnConnect()
{
// TODO: Add your control notification handler code here
BYTE bDeviceID;
HWND hOwnerWnd= m_hWnd;
UINT* puNotifyMsg= &m_UM_ELAPINotify;


UpdateData();
bDeviceID= GetDeviceId(m_iDevice);

DWORD dwRet;

if(m_bUseVB_API)
dwRet= m_pWELAPI->VB_Connect( (LONG) bDeviceID, (LONG) hOwnerWnd,
(LONG*) puNotifyMsg);
else
dwRet= m_pWELAPI->Connect( bDeviceID, hOwnerWnd, puNotifyMsg);

if(dwRet == ELAPI_OK)
SetConnectionFlag(TRUE);
else
SetConnectionFlag(FALSE);
}





//Callback-Funktion mit auswerten der Parameter:



LRESULT CHotelTstAppDlg::OnELAPINotify(WPARAM wParam, LPARAM lParam)
{
CString str;

// Message received from SManager
switch( LOWORD(wParam) )
{
case SVC_DISCONNECTED:
printLine("SVC_DISCONNECTED");
SetConnectionFlag(FALSE);
trace("CHotelTstDlg::OnELAPINotify: message: SVC_DISCONNECTED
received");
break;
// Data received
case SVC_DATARECEIVED:
printLine("SVC_DATARECEIVED");
trace("CHotelTstDlg::OnELAPINotify: message: SVC_DATARECEIVED
received");

WORD size;
size= HIWORD(wParam);
char * pacRecBuffer;
pacRecBuffer= new char[size];

ReceiveData( (unsigned char*)pacRecBuffer, size);

ProcessReceiveData(pacRecBuffer, size);
delete pacRecBuffer;
break;

default:
trace("CHotelTstDlg::OnELAPINotify: undefined message:!!!");
break;
}
return 1;
}


oid HotelTstAppDlg::ReceiveData(char* pacRecBuffer, WORD wSize)
{
CString str;
WORD wStrCount=3;

if(pacRecBuffer==NULL)
return;

switch(pacRecBuffer[0])
{

// Hotel_Start_Conf
case 0x45:

int RefID;
int len;
RefID= pacRecBuffer[1];
len= ((int)pacRecBuffer[2]) << 8;
len+= pacRecBuffer[3];

switch(pacRecBuffer[4])
{
case 0xD0: // parameter result
int ilenResult;
ilenResult= pacRecBuffer[5];
int iResultValue;
iResultValue= pacRecBuffer[6];
int iErrorValue;
iErrorValue= pacRecBuffer[7];
}
}
}

THANKS FOR EVERY HELP

Nijazi Halimaji


Ralph

2004-10-30, 8:55 am


"Don Hali" <spami@gmx.net> wrote in message
news:uxOmCJmvEHA.1976@TK2MSFTNGP09.phx.gbl...
> Hi
>
> I received the code of a interface written i C, but I can't program in C.
> Can someone interpret me this in VB?
>


First off. The code is not written in C, but in C++ (MFC).
Second, it appears to be a dialog which is using the services of something
referenced by "m_pWELAPI", which is what I assume you meant by an
'interface'.

You will likely need to create a VB form and reference that object. How will
depend on what it is - a control, an API (dll), or ... With out more
information anything else would be a pure guess.

The fact it has something called a "VB_Connect" is interesting. Attempt to
reference the item and see what services are available in the ObjectViewer.

hth
-ralph






Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com