by xhbcoder » Thu May 08, 2008 4:48 pm
Antonio,
The EXE is now showing the main Appplication screen.
I created an equivalent and dummy (function name and return only) for functions written in C so we could compile to create an executable.
The EXE is now flashing the main window but exits immediately.
The following is an error code when I tried to compile one of C source codes that was excluded that may be part of the main window.
LINE ERROR DESCRIPTION
44 error E2349 Nonportable pointer conversion in function WMCopyData
107 error E2342 Type mismatch in parameter 'hWndParent'(Wanted 'HWND_*,'got 'int') in function CREATEWINE
107 error E2342 Type mismatch in parameter 'hMenu'(Wanted 'HMENU_*,'got 'int') in function CREATEWINE
107 error E2342 Type mismatch in parameter 'iNUMBER'(Wanted 'int,'got 'HWND_') in function CREATEWINE
195 Warning W8065 Call to function 'GetWndApp' with no prototype in function CONNECT1
195 error E2342 Type mismatch in parameter "hwnd" (wanted 'HWND_*', got 'int') in function CONNECT1
229 error E109 Not an allowed type in function RECV1
0 ERROR *** 6 errors in Compile ***
Herewith I posted the COPYDATA.c for more info.
Thanks and regards,
Jose
/*
* COPYDATA.C written by George J. Hanson 11/13/2000 10:18PM
*/
#include "hbapi.h"
#include <stdio.h>
#include <Windows.h>
#define __WINDOWS_H
#include <ClipApi.h>
#include <WinSock.h>
#include <fwmsgs.h>
#define WM_COPYDATA 0x004A
extern HANDLE __hInstance;
/*
* lParam of WM_COPYDATA message points to...
*/
/*
typedef struct tagCOPYDATASTRUCT {
DWORD dwData;
DWORD cbData;
long lpData;
}
COPYDATASTRUCT, *PCOPYDATASTRUCT;
*/
/*
* Send a string to hWnd target using WM_COPYDATA
* Use CopyMemory API to copy to a Visual Basic String
* See modSubclass.bas
*
*/
CLIPPER WMCOPYDATA(/* hWnd target, hWnd sender, string ,dwData */)
{
HWND hWnd;
COPYDATASTRUCT cds;
hWnd = (HWND)_parni(1);
cds.dwData = _parnl(4);
cds.cbData = _parclen(3);
cds.lpData = (long)_parc(3);
if (hWnd && cds.cbData)
{
if (InSendMessage())
ReplyMessage(TRUE);
_retnl(SendMessage(hWnd, WM_COPYDATA, (WORD)_parni(2), (LONG)&cds));
}
else
_retnl(0);
}
/*
* Receive string passed from other app via WM_COPYDATA
*
*/
CLIPPER ONWMCOPYDA(/* wParam, lParam [, @dwData] */)
{
PCOPYDATASTRUCT pCds;
pCds = (PCOPYDATASTRUCT)_parnl(2);
if (PCOUNT()>=3)
_stornl(pCds->dwData,3);
if (pCds->cbData > 0)
_retclen( (LPSTR)pCds->lpData, (int)pCds->cbData );
else
_retc( "" );
ReplyMessage(1);
}
/*
*
* HWND CreateWindowEx(
* DWORD dwExStyle, // extended window style
* LPCTSTR lpClassName, // registered class name
* LPCTSTR lpWindowName, // window name
* DWORD dwStyle, // window style
* int x, // horizontal position of window
* int y, // vertical position of window
* int nWidth, // window width
* int nHeight, // window height
* HWND hWndParent, // handle to parent or owner window
* HMENU hMenu, // menu handle or child identifier
* HINSTANCE hInstance, // handle to application instance
* LPVOID lpParam // window-creation data
* );
*
*/
CLIPPER CREATEWINE() // ( nExtendedStyle, cClassName, cTitle, nStyle, nLeft, nTop, nWidth,
// nHeight, hWndOwner, hMenu, cExtraData ) --> hWnd
{
_retni( CreateWindowEx(_parnl( 1 ), // Extended style
_parc( 2 ), // Class
_parc( 3 ), // Title
_parnl( 4 ), // Style
_parni( 5 ), // Left
_parni( 6 ), // Top
_parni( 7 ), // Width
_parni( 8 ), // Height
_parni( 9 ), // Parent
_parni( 10 ), // Menu
__hInstance,
( PCOUNT() > 10 ) ? ( void FAR * ) _parc( 11 ): 0 ) ); // Address Window-Creation-Data
}
/*
* GetWorkRect() created by George J. Hanson on 12/15/2000 1:18AM
*
* Wrapper to SystemParametersInfo(SPI_GETWORKAREA,...
* Retrieves the size of the work area on the primary display monitor.
* The work area is the portion of the screen not obscured by the system taskbar
* or by application desktop toolbars. The pvParam parameter must point to a RECT
* structure that receives the coordinates of the work area, expressed in virtual
* screen coordinates.
*/
CLIPPER GETWORKREC() // --> { nTop, nLeft, nBottom, nRight }
{
RECT rct;
rct.top = 0;
rct.left = 0;
rct.bottom = 0;
rct.right = 0;
#define SPI_GETWORKAREA 48
SystemParametersInfo(SPI_GETWORKAREA,0,&rct,0);
_reta( 4 );
_storni( rct.top, (WORD)-1, 1 );
_storni( rct.left, (WORD)-1, 2 );
_storni( rct.bottom, (WORD)-1, 3 );
_storni( rct.right, (WORD)-1, 4 );
}
// Windows Socket: Connect
// Written 03/20/2003 09:37AM by George J. Hanson
// Add the _ prefix to these functions that are in fivewin's winapi.lib
unsigned long PASCAL FAR _inet_addr (const char FAR * cp);
int PASCAL FAR _connect (SOCKET s, const struct sockaddr FAR *name, int namelen);
u_short PASCAL FAR _htons (u_short hostshort);
int PASCAL FAR _recv (SOCKET s, char FAR * buf, int len, int flags);
CLIPPER CONNECT1() // ( socket, ipAddress|hostname, port, non-blocking ) --> int (0 on success or SOCKET_ERROR on failure)
{
SOCKET socket;
SOCKADDR_IN saServer;
LPHOSTENT lpHostEntry = NULL;
int rc;
socket = _parni(1);
saServer.sin_family = AF_INET;
saServer.sin_port = _htons( _parni(3) );
saServer.sin_addr.s_addr = _inet_addr( _parc(2) );
// Check if address valid ip address
if (saServer.sin_addr.s_addr == INADDR_NONE)
{
// Check if address is a valid hostname
lpHostEntry = gethostbyname( _parc(2) );
if ( lpHostEntry != NULL )
// Address is a valid hostname
saServer.sin_addr = *((LPIN_ADDR)*lpHostEntry->h_addr_list);
else
// No valid address
rc = SOCKET_ERROR;
}
// else address is a valid ip address
if (rc != SOCKET_ERROR)
{
// Connect
rc = _connect( _parni(1), (LPSOCKADDR)&saServer, sizeof(struct sockaddr) );
// Non-blocking
if (rc != SOCKET_ERROR && _parni(4))
rc = WSAAsyncSelect( socket, GetWndApp(), WM_ASYNCSELECT, FD_ACCEPT|FD_READ|FD_CLOSE|FD_CONNECT|FD_WRITE );
}
_retni( rc );
}
// This version uses first two parameters and return value like the original winsock recv function so errors can be detected.
// Uses a 4k buffer.
CLIPPER RECV1() // ( nSocket, @cRecv ) --> nLength (or SOCKET_ERROR)
{
BYTE buffer[ 4096 ];
WORD wLen;
// Is cRecv parameter a character passed by reference?
if (_parinfo(2) == 33)
// Receive data from socket
wLen = _recv( _parni( 1 ), buffer, 4096, 0 );
else
// Can't store in parameter that is not by reference
wLen = (WORD)SOCKET_ERROR;
// Is there a socket error?
if (wLen == (WORD)SOCKET_ERROR)
_storc( "", 2 );
else
if (_storclen( buffer, wLen, 2 ) == 0)
// Failed to store parameter
wLen = (WORD)SOCKET_ERROR;
_retni( wLen );
}