Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

windows translation lib

9 views
Skip to first unread message

Peter MacDonald

unread,
Jun 3, 1993, 6:25:42 PM6/3/93
to
Here is my pathetic first crack at writing a lib that can be used to
compile Windows programs under Linux without code changes.
It is really just a proof of concept, to show how easy it is.

First off, I have never programmed in windows, and probably never
will. I have done a little bit of XV programming a year or
two ago, but am very rusty. I am still trying to dig up
all the old code I wrote. All the Windows constants are wrong, and
I will get the proper windows.h, or clean-room one from the
MS Blue Book eventually.

I am also not even sure that XV should be used as the base. I
am not very X literate. Nevertheless, I did this to demonstrate
how easy it could be to do. Let me know if you can help.

Peter
--hw.c----------------------------------------------------------
#include <windows.h>

long FAR PASCAL WndProc(HWND handle, WORD msg, WORD wParam, LONG lParam);

int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)
{
static char szAppName[]="HelloWin";
HWND hwnd;
MSG msg;
WNDCLASS wndclass;

if(!hPrevInstance) {
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;

RegisterClass(&wndclass);
}

hwnd=CreateWindow(szAppName, "The Hello Program", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL );

ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);

while(GetMessage(&msg,NULL,0,0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}

long FAR PASCAL WndProc(HWND hwnd, WORD message, WORD wParam, LONG lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;

switch (message)
{
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
GetClientRect( hwnd, &rect);
DrawText(hdc, "Hello, Windows!", -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER );
EndPaint( hwnd, &ps);
return(0);
case WM_DESTROY:
PostQuitMessage(0);
return(0);
}
}
------------------------------------------------------------
#include <stdio.h>
#define FAR
#define PASCAL
#define _export

typedef int HANDLE;
typedef char *LPSTR;
typedef unsigned short WORD;
typedef long LONG;
typedef char *HWND;
typedef int HDC;

typedef struct {
int wParam;
} MSG;

typedef struct {
int style;
void *lpfnWndProc;
int cbClsExtra;
int cbWndExtra;
HANDLE hInstance;
int hIcon;
int hCursor;
int hbrBackground;
char *lpszMenuName;
char *lpszClassName;
} WNDCLASS;

typedef struct {
} PAINTSTRUCT;

typedef struct {
} RECT;

#define IDI_APPLICATION "ApplIcon"
#define WHITE_BRUSH 1
#define IDC_ARROW 2
#define WS_OVERLAPPEDWINDOW 3
#define CW_USEDEFAULT 4
#define CS_HREDRAW 5
#define CS_VREDRAW 6
#define WM_PAINT 7
#define DT_SINGLELINE 8
#define DT_CENTER 9
#define DT_VCENTER 10
#define WM_DESTROY 11

int LoadIcon(HANDLE h, char*);
int LoadCursor(char *a, int);
int GetStockObject(int);
int RegisterClass(WNDCLASS *wndclass);
HWND CreateWindow(char*, char*, int, int, int, int, int, char *, char*, HANDLE, char*);
int ShowWindow(HWND hwnd, int nCmdShow);
int UpdateWindow(HWND hwnd);
int GetMessage(MSG *msg,char *,int, int);
int TranslateMessage(MSG *msg);
int DispatchMessage(MSG *msg);
int BeginPaint(HWND hwnd, PAINTSTRUCT *ps);
int GetClientRect( HWND hwnd, RECT *rect);
int DrawText(HDC hdc, char *str, int, RECT *rect, int dtflag);
int EndPaint( HWND hwnd, PAINTSTRUCT *ps);
int PostQuitMessage(int);
int DefWindowProc( HWND hwnd, WORD message, WORD wParam, LONG lParam);

-windows.c-----------------------------------------------------------
#include <windows.h>
#include <xview/xview.h>

Frame frame;

int LoadIcon(HANDLE h, char*b)
{
}

int LoadCursor(char *a, int b)
{
}

int GetStockObject(int a)
{
}

int RegisterClass(WNDCLASS *wndclass)
{
}

HWND CreateWindow(char*szAppName, char *Label, int ol, int x, int y, int w, int h, char *d, char*e, HANDLE f, char*g)
{
if (x == CW_USEDEFAULT) x=0;
if (y == CW_USEDEFAULT) y=0;
if (w == CW_USEDEFAULT) w=300;
if (h == CW_USEDEFAULT) h=300;
frame = (Frame)xv_create(NULL, FRAME, FRAME_LABEL, Label,
XV_X, x, XV_Y, y, XV_HEIGHT, h, XV_WIDTH, w,
NULL);
}

int ShowWindow(HWND hwnd, int nCmdShow)
{
}

int UpdateWindow(HWND hwnd)
{
}

int GetMessage(MSG *msg,char *b,int c, int d)
{
xv_main_loop(frame);
}

int TranslateMessage(MSG *msg)
{
}

int DispatchMessage(MSG *msg)
{
xv_main_loop(frame);
return(0);
}

int BeginPaint(HWND hwnd, PAINTSTRUCT *ps)
{
}

int GetClientRect( HWND hwnd, RECT *rect)
{
}

int DrawText(HDC hdc, char *str, int c, RECT *rect, int dtflag)
{
}

int EndPaint( HWND hwnd, PAINTSTRUCT *ps)
{
}

int PostQuitMessage(int a)
{
}

int DefWindowProc( HWND hwnd, WORD message, WORD wParam, LONG lParam)
{
}

main(int argc, char *argv[])
{
HANDLE hInstance, hPrevInstance;
LPSTR lpszCmdLine; int nCmdShow;

xv_init(argc,argv);
WinMain(hInstance,hPrevInstance,lpszCmdLine,nCmdShow);
}

Eric Youngdale

unread,
Jun 4, 1993, 12:05:36 AM6/4/93
to
In article <1993Jun3.2...@sol.UVic.CA> pmacdona@sanjuan (Peter MacDonald) writes:
>Here is my pathetic first crack at writing a lib that can be used to
>compile Windows programs under Linux without code changes.
>It is really just a proof of concept, to show how easy it is.

I have created a mail channel called WABI where Windows under linux
issues can be discussed. A number of people have written me expressing
interest in these sorts of things, and it seemed like a good idea to take this
discussion to a mail channel and spare c.o.l. the extra bandwidth.

To join the channel, send mail to
linux-activ...@joker.cs.hut.fi, with the line:

X-MN-Admin: join WABI

in the header of the message.

-Eric
--
"When Gregor Samsa woke up one morning from unsettling dreams, he
found himself changed in his bed into a lawyer."

Howlin' Bob

unread,
Jun 4, 1993, 12:35:16 AM6/4/93
to
>In article <1993Jun3.2...@sol.UVic.CA> pmacdona@sanjuan (Peter MacDonald) writes:
>>Here is my pathetic first crack at writing a lib that can be used to
>>compile Windows programs under Linux without code changes.
>>It is really just a proof of concept, to show how easy it is.

Peter, does this mean you're throwing your gauntlet into
the ring? If someone actually starts working on it, instead
of talking, I might have to revise my estimates :-)

By the way, Peter--and I don't do this out of ego--your "credits"
list showed Matthias Lautner to be the author of dosemu. While
this is true for version 0.4 and earlier, I have made what
I believe are significant contributions, as well as becoming the
new maintainer. Perhaps I could be co-listed so that people know
where to send the hate mail?

--
Robert Sanders
Georgia Institute of Technology, Atlanta Georgia, 30332
uucp: ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!gt8134b
Internet: gt8...@prism.gatech.edu

Peter MacDonald

unread,
Jun 4, 1993, 8:59:23 AM6/4/93
to
In article <100...@hydra.gatech.EDU> gt8...@prism.gatech.EDU (Howlin' Bob) writes:
>>In article <1993Jun3.2...@sol.UVic.CA> pmacdona@sanjuan (Peter MacDonald) writes:
>>>Here is my pathetic first crack at writing a lib that can be used to
>>>compile Windows programs under Linux without code changes.
>>>It is really just a proof of concept, to show how easy it is.
>
>Peter, does this mean you're throwing your gauntlet into
>the ring? If someone actually starts working on it, instead
>of talking, I might have to revise my estimates :-)

Well, I guess so. I have already done a bit a work. I now have
a windows.c file that will allow you to compile and link and run any
windows program (theoretically). Unimplemented functions just
print out a message that they were called. The MS-windows hello-world
program runs, under xview. I suggest that we just continue on by
compiling successively more complex windows progs and implementing the
reportedly missing functions. We still have to decide wether to
use xview or not. It looks so much nicer.

>
>By the way, Peter--and I don't do this out of ego--your "credits"
>list showed Matthias Lautner to be the author of dosemu. While
>this is true for version 0.4 and earlier, I have made what
>I believe are significant contributions, as well as becoming the
>new maintainer. Perhaps I could be co-listed so that people know
>where to send the hate mail?

I can't believe how much response I am getting this time. Last time,
a few months ago, all I got was a trickle.

Consider yourself added.

0 new messages