Category : OS/2 Files
Archive   : MYCTRL.ZIP
Filename : HELLO.C

 
Output of file : HELLO.C contained in archive : MYCTRL.ZIP
/****************************** Module Header ******************************\
* Module Name: HELLO.C
*
* Example of a simple OS/2 Presentation Manager application
*
* Created by Microsoft Corp., 1988
*
\***************************************************************************/

#define INCL_PM
#include
#include "hello.h"

HAB hAB;
HMQ hmqHello;
HWND hwndHello;
HWND hwndHelloFrame;

CHAR szClassName[] = "Hello";
CHAR szMessage[] = "Hello World";
CHAR szEdit[255];

/***************************** Private Function ****************************\
*
* Hello World Main procedure
*
* Effects: Set globals - hAB Handle to Application Anchor Block
* - hmqHello Handle to application window msg queue
*
* Warnings: None
*
\***************************************************************************/

int cdecl main( )
{
QMSG qmsg;
ULONG ctldata;
int cbModule;
HWND hwndMyCtrl;

hAB = WinInitialize(NULL);

hmqHello = WinCreateMsgQueue(hAB, 0);

/* In order to use the public control with class name, MyCtrl, (in the
APPDLL.DLL dynamic link library) there must be an entry in the OS2.INI
file. This entry is checked when the PM SHELL is booted. This code
checks to see if the necessary profile string information is present,
and adds an OS2.INI entry if required. One must reboot after updating
OS2.INI so that APPDLL.DLL will be loaded when the SHELL is booted. */
cbModule = WinQueryProfileString( hAB, "SYS_DLLS", "Load", "", szEdit, 255 );
if ( cbModule == 1 ) {
WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
"SYS_DLLS entry added to OS2.INI.\nSelect OK and reboot PM again and be sure to place APPDLL.DLL in LIBPATH.",
"No OS2.INI Entry!", NULL,
MB_OK | MB_ICONEXCLAMATION );
/* Add OS2.INI entry to load APPDLL.DLL at SHELL boot time */
WinWriteProfileString( hAB, "SYS_DLLS", "Load", "APPDLL" );
/* Close down the application since APPDLL.DLL hasn't been loaded yet */
WinTerminate( hAB );
return NULL;
}

if (!WinRegisterClass( hAB,
(PCH)szClassName,
(PFNWP)HelloWndProc,
CS_SYNCPAINT | CS_SIZEREDRAW,
0))
return( 0 );

ctldata = FCF_STANDARD & ~FCF_MENU & ~FCF_ACCELTABLE;

hwndHelloFrame = WinCreateStdWindow( HWND_DESKTOP,
WS_VISIBLE,
&ctldata,
(PCH)szClassName,
NULL,
0L,
(HMODULE)NULL,
HELLOICON,
(HWND FAR *)&hwndHello );


/* Create two controls of MyCtrl class, the new public control in
APPDLL.DLL. */
hwndMyCtrl = WinCreateWindow(
hwndHello, /* Parent of control is client area */
"MyCtrl", /* Class registered in APPDLL.DLL */
NULL,
WS_VISIBLE,
10, 10, 100, 20,/* Position and size control */
hwndHello, /* Owner of control is also client area */
HWND_BOTTOM, /* Bottom of the child window z-ordering */
100, /* Some ID */
NULL,
NULL );

/* If window creation failed it is likely due to missing APPDLL.DLL
in LIBPATH. */
if (!hwndMyCtrl)
WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
"Place APPDLL.DLL in LIBPATH",
"No Public Class: MyCtrl!", NULL,
MB_OK | MB_ICONEXCLAMATION );

/* Create the second control of MyCtrl class. */
hwndMyCtrl = WinCreateWindow(
hwndHello, /* Parent of control is client area */
"MyCtrl", /* Class registered in APPDLL.DLL */
NULL,
WS_VISIBLE,
10, 40, 100, 20,/* Position and size control */
hwndHello, /* Owner of control is also client area */
HWND_BOTTOM, /* Bottom of the child window z-ordering */
101, /* Some ID */
NULL,
NULL );

/* If window creation failed it is likely due to missing APPDLL.DLL
in LIBPATH. */
if (!hwndMyCtrl)
WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
"Place APPDLL.DLL in LIBPATH",
"No Public Class: MyCtrl!", NULL,
MB_OK | MB_ICONEXCLAMATION );


WinShowWindow( hwndHelloFrame, TRUE );

/* Poll messages from event queue */

while( WinGetMsg( hAB, (PQMSG)&qmsg, (HWND)NULL, 0, 0 ) )
{
WinDispatchMsg( hAB, (PQMSG)&qmsg );
}

WinDestroyWindow( hwndHelloFrame );
WinDestroyMsgQueue( hmqHello );
WinTerminate( hAB );
}



/***************************** Private Function ****************************\
*
* Procedure which processes window messages
*
* Effects: None
*
* Warnings: None
*
\***************************************************************************/

MRESULT EXPENTRY HelloWndProc( hWnd, msg, mp1, mp2 )
HWND hWnd;
USHORT msg;
MPARAM mp1;
MPARAM mp2;
{
HPS hPS;
POINTL pt;
CHARBUNDLE cb;

switch (msg)
{
case WM_CLOSE:
WinPostMsg( hWnd, WM_QUIT, 0L, 0L );
break;

case WM_PAINT:
hPS = WinBeginPaint( hWnd, (HPS)NULL, (PWRECT)NULL );
pt.x = pt.y = 0L;
cb.lColor = CLR_BLACK;
GpiSetAttrs(hPS, PRIM_CHAR, CBB_COLOR, 0L, (PBUNDLE)&cb);

GpiCharStringAt( hPS, (PPOINTL)&pt, (LONG)sizeof(szMessage)-1,
(PCH)szMessage );
WinEndPaint( hPS );
break;

case WM_ERASEBACKGROUND:
return( TRUE );
break;

default:
return( WinDefWindowProc( hWnd, msg, mp1, mp2 ) );
break;
}
return(0L);
}


  3 Responses to “Category : OS/2 Files
Archive   : MYCTRL.ZIP
Filename : HELLO.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/