home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
sibdemo3.zip
/
SAMPLES.DAT
/
SAMPLES
/
TUTORIAL
/
CHAP03
/
WELCOME4.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1997-08-01
|
7KB
|
160 lines
PROGRAM WELCOME4;
/*-------------------------------------------------------------
WELCOME4.PAS -- Creates a Top-Level Window and Three Children
(c) Charles Petzold, 1993
-------------------------------------------------------------*/
/*-------------------------------------------------------
from the book "OS/2 Presentation Manager Programming"
by Charles Petzold, Ziff-Davis Press 1994
(c) Ziff Davis Press, All rights reserved.
Restricted rights, duplication, disclosure and
commericially distribution prohibited.
Translated to Speed-Pascal/2 by Rene Nürnberger
(c) SpeedSoft GbR, 1995
-------------------------------------------------------*/
USES Os2Def,PMWIN;
CONST
ID_BUTTON = 1;
ID_SCROLL = 2;
ID_ENTRY = 3;
szClientClass:STRING = 'Welcome4' ;
flFrameFlags:ULONG = FCF_TITLEBAR OR FCF_SYSMENU OR
FCF_BORDER OR FCF_MINBUTTON OR
FCF_SHELLPOSITION OR FCF_TASKLIST ;
VAR
ahab : HAB ;
ahmq : HMQ ;
hwndFrame, hwndClient : HWND;
aqmsg : QMSG;
rcl : RECTL;
FUNCTION ClientWndProc (ahwnd:HWND;msg:ULONG;mp1:MPARAM;mp2:MPARAM):MRESULT; CDECL;
BEGIN
CASE msg OF
WM_COMMAND:
BEGIN
CASE lo(mp1) OF
ID_BUTTON:
BEGIN
WinAlarm (HWND_DESKTOP, WA_NOTE) ;
ClientWndProc:=0;
exit;
END;
END; {case}
END;
WM_ERASEBACKGROUND:
BEGIN
ClientWndProc:=MRFROMSHORT (1) ;
exit;
END;
ELSE ClientWndProc:=WinDefWindowProc (ahwnd, msg, mp1, mp2) ;
END; {case}
END;
BEGIN
ahab := WinInitialize (0) ;
ahmq := WinCreateMsgQueue (ahab, 0) ;
WinRegisterClass (
ahab, { 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 }
NIL, { Title bar text }
0, { Style of client window }
0, { Module handle for resources }
0, { ID of resources }
hwndClient) ; { Pointer to client window handle }
/*--------------------------------------------------------
Find dimensions of client window for sizes of children
--------------------------------------------------------*/
WinQueryWindowRect (hwndClient, rcl) ;
rcl.xRight := rcl.xright DIV 3 ; { divide width in thirds }
/*---------------------------
Create push button window
---------------------------*/
WinCreateWCWindow (
hwndClient, { Parent window handle }
WC_BUTTON, { Window class }
'Big Button', { Window text }
WS_VISIBLE OR BS_PUSHBUTTON , { Window style }
10, { Window position }
10,
rcl.xRight - 20, { Window size }
rcl.yTop - 20,
hwndClient, { Owner window handle }
HWND_BOTTOM, { Placement window handle}
ID_BUTTON, { Child window ID }
NIL, { Control data }
NIL) ; { Presentation parameters}
/*--------------------------
Create scroll bar window
--------------------------*/
WinCreateWCWindow (
hwndClient, { Parent window handle }
WC_SCROLLBAR, { Window class }
NIL, { Window text }
WS_VISIBLE OR SBS_VERT, { Window style }
rcl.xRight + 10, { Window position }
10,
rcl.xRight - 20, { Window size }
rcl.yTop - 20,
hwndClient, { Owner window handle }
HWND_BOTTOM, { Placement window handle}
ID_SCROLL, { Child window ID }
NIL, { Control data }
NIL) ; { Presentation parameters}
/*-------------------------------------
Create multiline entry field window
-------------------------------------*/
WinCreateWCWindow (
hwndClient, { Parent window handle }
WC_MLE, { Window class }
NIL, { Window text }
WS_VISIBLE OR MLS_BORDER { Window style }
OR MLS_VSCROLL
OR MLS_WORDWRAP,
2 * rcl.xRight + 10, { Window position }
10,
rcl.xRight - 20, { Window size }
rcl.yTop - 20,
hwndClient, { Owner window handle }
HWND_BOTTOM, { Placement window handle}
ID_ENTRY, { Child window ID }
NIL, { Control data }
NIL) ; { Presentation parameters}
WHILE WinGetMsg (ahab, aqmsg, NULLHANDLE, 0, 0) DO
WinDispatchMsg (ahab, aqmsg) ;
WinDestroyWindow (hwndFrame) ;
WinDestroyMsgQueue (ahmq) ;
WinTerminate (ahab) ;
END.