c-code nach pb übersetzen....

Fragen zu allen anderen Programmiersprachen.
Benutzeravatar
nicolaus
Moderator
Beiträge: 1175
Registriert: 11.09.2004 13:09
Kontaktdaten:

c-code nach pb übersetzen....

Beitrag von nicolaus »

Hallo
Wer kann mir bei der übersetzung des folgenden c-codes nach pb helfen?
hier die headerdatei

Code: Alles auswählen

#ifndef	__FS_MODULE_H__
#define	__FS_MODULE_H__

#define	DLLEXPORT	__declspec(dllexport)
#define	FSAPI	__stdcall

/**
 * This is the module's import table definition.
 */
typedef struct _MODULE_IMPORT {
	struct {
		int fnID;
		PVOID fnptr;
	} IMPORTSentry;
	struct {
		int fnID;
		PVOID fnptr;
	} nullentry;
} MODULE_IMPORT;

/**
 * This is the module's export table definition
 */
typedef struct _MODULE_LINKAGE {
	int ModuleID;
	void (FSAPI *ModuleInit)(void);
	void (FSAPI *ModuleDeinit)(void);
	UINT32 ModuleFlags;
	UINT32 ModulePriority;
	UINT32 ModuleVersion;
	PVOID ModuleTable;
} MODULE_LINKAGE;

#endif	/* __FS_MODULE_H__ */
und hier die c-datei

Code: Alles auswählen

#include <windows.h>
#include "module.h"

/*
 * We define just basic interface to the flight simulator so it will be
 * able to load the module.
 */
DLLEXPORT MODULE_IMPORT ImportTable = {
	{0x00000000, NULL},
	{0x00000000, NULL}
};

void FSAPI module_init(void) {}
void FSAPI module_deinit(void) {}

DLLEXPORT MODULE_LINKAGE Linkage = {
	0x00000000,
	module_init,
	module_deinit,
	0,
	0,
	0x0900,	// FS2004 version (use 0x0800 for FS2002)
	NULL
};

// The standard window procedure used by the flight simulator
WNDPROC oldWndProc;

// Flight simulator main window handle
HWND hFSimWindow;

#define	MENU_ENTRY	"My Mo&dule"
#define	ID_MY_MENUITEM	40001

/**
 * Main window procedure that is called by the flight simulator to process
 * incoming window messages.
 */
LRESULT CALLBACK FSimWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch (uMsg) {
		case WM_NCPAINT:
			{
				HMENU hMenu, hMyMenu;

				hMenu = GetMenu(hwnd);
				if (hMenu != NULL) {
					int i;
					// Look for our menu entry in the main menu.
					for (i = 0; i < GetMenuItemCount(hMenu); i++) {
						char buf[128];
						GetMenuString(hMenu, i, buf, 128, MF_BYPOSITION);
						if (strcmp(buf, MENU_ENTRY) == 0) {
							// It is already here, we do not need to add it again
							break;
						}
					}
					if (i < GetMenuItemCount(hMenu)) {
						// It is already here, we do not need to add it again
						break;
					}
					/* Create new menu. NOTE: It seems that this will be
					 * reached more times, so we cannot save the handle, because
					 * in such case it could be destroyed and we will not have
					 * any access to it in the simulator.
					 */
					hMyMenu = CreateMenu();
					AppendMenu(hMyMenu, MF_STRING | MF_ENABLED, ID_MY_MENUITEM, "My &First Menu Entry");
					// add the created menu to the main menu
					AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT_PTR)hMyMenu, MENU_ENTRY);
				}
			}
			break;
		case WM_COMMAND:
			if (LOWORD(wParam) == ID_MY_MENUITEM) {
				// Add your code here
				MessageBox(hwnd, "It works!", "HURA", MB_OK | MB_ICONEXCLAMATION);
				return 0;
			}
			break;
	}
	// Call the original window procedure to handle all other messages
	return CallWindowProc(oldWndProc, hwnd, uMsg, wParam, lParam);
}

/**
 * Entry point of the DLL.
 */
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
	switch (fdwReason) {
		case DLL_PROCESS_ATTACH:
			hFSimWindow = FindWindow("FS98MAIN", NULL);
			oldWndProc = (WNDPROC)SetWindowLong(hFSimWindow, GWL_WNDPROC, (LONG)FSimWindowProc);
			break;
	}
	return TRUE;
}
danke schon mal für eure hilfe.

Gruß nico
MARTIN
Beiträge: 454
Registriert: 08.09.2004 14:03
Wohnort: Kiel

Beitrag von MARTIN »

hmm...
Also ich habe versucht das nach PB zu übersetzen, leider habe ich da ein paar Problemme.

Könntest du vielleich präzisieren was dich an dem code Interesiert ?
Vielleicht kann ich dir dann weiter helfen.
Amilo 1667|Suse Linux 10.1_64bit/WinXP |PB 4.00/3.94
Antworten