Compiling "OS/2 Presentation Manager Programming" Samples on 2016: Difference between revisions
No edit summary |
No edit summary |
||
Line 34: | Line 34: | ||
WELCOME is just a PM window that shows up with a message that says "Welcome to OS/2 2.0 Presentation Manager". That's all. | WELCOME is just a PM window that shows up with a message that says "Welcome to OS/2 2.0 Presentation Manager". That's all. | ||
===W.C=== | |||
But we start with "W.EXE" it is a program that does not uses PM yet and does not do much. | But we start with "W.EXE" it is a program that does not uses PM yet and does not do much. | ||
Line 57: | Line 59: | ||
It will work to create the w.exe the app will run, but it does not do anything. | It will work to create the w.exe the app will run, but it does not do anything. | ||
Now, just because I'm curious, I'm going to analyze that EXE with [[PMDLL]]. | |||
[[Image:PM-APP-001.png]] | |||
Look that this program shows that it loads (or requires) the LIBC and the GCC libraries. This obvious because I'm compiling it with GCC, but it is good to know if this is the first time you compile a program. | |||
===WELCOME.C=== | |||
Now let's look at WELCOME.C, which is the final evolution of the | Now let's look at WELCOME.C, which is the final evolution of the |
Revision as of 17:32, 2 July 2016
DRAFT
This is a quick article about compiling some samples from the OS/2 Presentation Manager Programming from Charles Petzold (1994), but giving the approach on how to compile that samples on eComStation (or OS/2 Warp 4.52) on the 2016 year.
My goals are:
- Try (as much as possible) to compile the samples with free / open source available tools
- Try to most simply way to install the development enviroment
- Try also the most simple ways to compile this samples.
Preparing the Development Environment
On the book it talks about IBM C or Borland, both those programs are old and hard to find for OS/2 now. This is why I'm trying to compile the book PM Samples with free/open source tool that are available online.
The easiest way to prepare the environment is using Arca Noae Package Manager [1] to remotely install the required tools and libraries.
Arca Noae Package Manager has a simple WarpIn interface to install it, so it went easy. After that I followed the advice of the VirtualBox Port Wiki to install the required software.
On Arca Noae Package Manager just select "YUM - Install" and add the following:
ash which kbuild gcc gcc-wlink gettext-devel git pthread-devel libxml2-devel libxslt-devel openssl-devel libcurl-devel zlib-devel libpng-devel libqt4-devel libidl-devel libvncserver-devel nasm libpoll-devel libaio-devel
Yes, some of those are not complete required for just this samples but I don't want to worry about it right now.
Checking out the source code
The source code can be downloaded from Charles's FTP site [2] (yes it is still there) or you can do a check out from Github [3]. If you want to use github check out my other article "Using Git under eComStation".
Compiling Chapter 2
Since I don't know much about programming I got help to compile this program from the OS2World forum.
Chapter 2 has the WELCOME sample that is divided in several steps, Charles name those W , WE, WEL, WELC, WELCO, WELCOM, WELCOME. It is the same program that goes evolving according as you go forward in Chapter 2.
WELCOME is just a PM window that shows up with a message that says "Welcome to OS/2 2.0 Presentation Manager". That's all.
W.C
But we start with "W.EXE" it is a program that does not uses PM yet and does not do much. Look at "W.C" sample:
/*---------------------------------- W.C -- A Do-Nothing Program (c) Charles Petzold, 1993 ----------------------------------*/ #include<stdio.h> int main (void) { return 0 ; }
To compile this with the gcc compiler it is as simple as:
gcc -o w.exe w.c w.def
It will work to create the w.exe the app will run, but it does not do anything.
Now, just because I'm curious, I'm going to analyze that EXE with PMDLL.
Look that this program shows that it loads (or requires) the LIBC and the GCC libraries. This obvious because I'm compiling it with GCC, but it is good to know if this is the first time you compile a program.
WELCOME.C
Now let's look at WELCOME.C, which is the final evolution of the
/*--------------------------------------------------------- WELCOME.C -- A Program that Writes to its Client Window (c) Charles Petzold, 1993 ---------------------------------------------------------*/ #include <os2.h> MRESULT EXPENTRY ClientWndProc (HWND, ULONG, MPARAM, MPARAM) ; int main (void) { static CHAR szClientClass [] = "Welcome1" ; static ULONG flFrameFlags = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER | FCF_MINMAX | FCF_SHELLPOSITION | FCF_TASKLIST ; HAB hab ; HMQ hmq ; HWND hwndFrame, hwndClient ; QMSG qmsg ; hab = WinInitialize (0) ; hmq = WinCreateMsgQueue (hab, 0) ; WinRegisterClass ( hab, // Anchor block handle szClientClass, // Name of class being registered ClientWndProc, // Window procedure for class CS_SIZEREDRAW, // Class style 0) ; // Extra bytes to reserve hwndFrame = WinCreateStdWindow ( HWND_DESKTOP, // Parent window handle WS_VISIBLE, // Style of frame window &flFrameFlags, // Pointer to control data szClientClass, // Client window class name NULL, // Title bar text 0L, // Style of client window 0, // Module handle for resources 0, // ID of resources &hwndClient) ; // Pointer to client window handle while (WinGetMsg (hab, &qmsg, NULLHANDLE, 0, 0)) WinDispatchMsg (hab, &qmsg) ; WinDestroyWindow (hwndFrame) ; WinDestroyMsgQueue (hmq) ; WinTerminate (hab) ; return 0 ; } MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { static CHAR szText [] = "Welcome to the OS/2 2.0 Presentation Manager!" ; HPS hps; RECTL rcl ; switch (msg) { case WM_CREATE: DosBeep (261, 100) ; DosBeep (330, 100) ; DosBeep (392, 100) ; DosBeep (523, 500) ; return 0 ; case WM_PAINT: hps = WinBeginPaint (hwnd, NULLHANDLE, NULL) ; WinQueryWindowRect (hwnd, &rcl) ; WinDrawText (hps, -1, szText, &rcl, CLR_NEUTRAL, CLR_BACKGROUND, DT_CENTER | DT_VCENTER | DT_ERASERECT) ; WinEndPaint (hps) ; return 0 ; case WM_DESTROY: DosBeep (523, 100) ; DosBeep (392, 100) ; DosBeep (330, 100) ; DosBeep (261, 500) ; return 0 ; } return WinDefWindowProc (hwnd, msg, mp1, mp2) ; }
This program now loads a PM Window creating all the stuff that PM needs.
You can compile it with gcc by running:
gcc -o welcome.exe welcome.c welcome.def