home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
sftick.zip
/
beg
/
dialog
/
good
/
DIALOG.C
< prev
next >
Wrap
Text File
|
1994-01-01
|
4KB
|
149 lines
#define INCL_WIN
#include <os2.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dialog.h"
#define CLS_CLIENT "MyClass"
MRESULT EXPENTRY ClientWndProc ( HWND hwndWnd,
ULONG ulMsg,
MPARAM mpParm1,
MPARAM mpParm2 ) ;
MRESULT EXPENTRY DlgProc ( HWND hwndWnd,
ULONG ulMsg,
MPARAM mpParm1,
MPARAM mpParm2 ) ;
INT main ( VOID )
{
HAB habAnchor ;
HMQ hmqQueue ;
ULONG ulFlags ;
HWND hwndFrame ;
HWND hwndClient ;
QMSG qmMsg ;
/* initialization */
habAnchor = WinInitialize ( 0 ) ;
hmqQueue = WinCreateMsgQueue ( habAnchor, 0 ) ;
/* register class for client window */
WinRegisterClass ( habAnchor,
CLS_CLIENT,
ClientWndProc,
CS_SIZEREDRAW,
0 ) ;
ulFlags = FCF_STANDARD & ~FCF_ACCELTABLE &
~FCF_TASKLIST ;
/* create frame and others */
hwndFrame = WinCreateStdWindow ( HWND_DESKTOP,
WS_VISIBLE,
&ulFlags,
CLS_CLIENT,
"Dialog Box Example",
0,
NULLHANDLE,
IDR_CLIENT,
&hwndClient ) ;
if ( hwndFrame ) {
/* typical message processing loop */
while ( WinGetMsg ( habAnchor, &qmMsg, NULLHANDLE, 0, 0 ))
WinDispatchMsg ( habAnchor, &qmMsg ) ;
WinDestroyWindow ( hwndFrame ) ;
} /* endif */
WinDestroyMsgQueue ( hmqQueue ) ;
WinTerminate ( habAnchor ) ;
return 0 ;
}
MRESULT EXPENTRY DlgProc ( HWND hwndDlg,
ULONG ulMsg,
MPARAM mpParm1,
MPARAM mpParm2 )
{
switch ( ulMsg ) {
case WM_COMMAND:
switch ( SHORT1FROMMP ( mpParm1 )) {
case DID_OK:
case DID_CANCEL:
WinDismissDlg ( hwndDlg, FALSE ) ;
break ;
default:
return WinDefDlgProc ( hwndDlg,
ulMsg,
mpParm1,
mpParm2 ) ;
} /* endswitch */
break ;
default:
return WinDefDlgProc ( hwndDlg, ulMsg, mpParm1, mpParm2 ) ;
} /* endswitch */
return MRFROMSHORT ( FALSE ) ;
}
MRESULT EXPENTRY ClientWndProc ( HWND hwndWnd,
ULONG ulMsg,
MPARAM mpParm1,
MPARAM mpParm2 )
{
switch ( ulMsg ) {
/* not processing WM_PAINT, so process this instead */
case WM_ERASEBACKGROUND:
return MRFROMSHORT ( TRUE ) ;
case WM_COMMAND:
switch ( SHORT1FROMMP ( mpParm1 )) {
/* user hit LOAD DIALOG from menu */
case IDM_LOAD:
{
/* load dialog box */
WinDlgBox ( HWND_DESKTOP,
hwndWnd,
DlgProc,
NULLHANDLE,
IDD_EXAMPLE,
0 ) ;
}
break ;
/* user hit EXIT from menu */
case IDM_EXIT:
WinPostMsg ( hwndWnd, WM_CLOSE, 0, 0 ) ;
break ;
default:
return WinDefWindowProc ( hwndWnd,
ulMsg,
mpParm1,
mpParm2 ) ;
} /* endswitch mpParm1 */
break ;
default:
return WinDefWindowProc ( hwndWnd,
ulMsg,
mpParm1,
mpParm2 ) ;
} /* endswitch ulMsg */
return MRFROMSHORT ( FALSE ) ;
}