📄 wdefupdn.c
字号:
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#include <windows.h>
#include <win1632.h>
#include "wdeglbl.h"
#include "wdemem.h"
#include "wderesin.h"
#include "wdeobjid.h"
#include "wdefutil.h"
#include "wde_wres.h"
#include "wdemain.h"
#include "wdeoinfo.h"
#include "wdedefsz.h"
#include "wdedebug.h"
#include "wde_rc.h"
#include "wdesdup.h"
#include "wdecctl.h"
#include "wdefupdn.h"
/****************************************************************************/
/* type definitions */
/****************************************************************************/
typedef struct {
FARPROC dispatcher;
OBJPTR object_handle;
OBJ_ID object_id;
OBJPTR control;
} WdeUpDnObject;
/****************************************************************************/
/* external function prototypes */
/****************************************************************************/
extern BOOL WINEXPORT WdeUpDnDispatcher ( ACTION, WdeUpDnObject *, void *,
void *);
extern LRESULT WINEXPORT WdeUpDnSuperClassProc ( HWND, UINT, WPARAM, LPARAM);
/****************************************************************************/
/* static function prototypes */
/****************************************************************************/
static OBJPTR WdeMakeUpDn ( OBJPTR, RECT *, OBJPTR, DialogStyle,
char *, OBJ_ID );
static OBJPTR WdeUDCreate ( OBJPTR, RECT *, OBJPTR,
OBJ_ID, WdeDialogBoxControl *);
static BOOL WdeUpDnDestroy ( WdeUpDnObject *, BOOL *, void *);
static BOOL WdeUpDnValidateAction ( WdeUpDnObject *, ACTION *, void *);
static BOOL WdeUpDnCopyObject ( WdeUpDnObject *, WdeUpDnObject **,
WdeUpDnObject *);
static BOOL WdeUpDnIdentify ( WdeUpDnObject *, OBJ_ID *, void *);
static BOOL WdeUpDnGetWndProc ( WdeUpDnObject *, WNDPROC *, void *);
static BOOL WdeUpDnGetWindowClass ( WdeUpDnObject *, char **, void *);
static BOOL WdeUpDnDefine ( WdeUpDnObject *, POINT *, void *);
static void WdeUpDnSetDefineInfo ( WdeDefineObjectInfo *, HWND );
static void WdeUpDnGetDefineInfo ( WdeDefineObjectInfo *, HWND );
static BOOL WdeUpDnDefineHook ( HWND, UINT, WPARAM, LPARAM,
DialogStyle );
/****************************************************************************/
/* static variables */
/****************************************************************************/
static HINSTANCE WdeApplicationInstance;
static FARPROC WdeUpDnDispatch;
static WdeDialogBoxControl *WdeDefaultUpDn = NULL;
static int WdeUpDnWndExtra;
static WNDPROC WdeOriginalUpDnProc;
//static WNDPROC WdeUpDnProc;
#define WUPDOWN_CLASS UPDOWN_CLASS
static DISPATCH_ITEM WdeUpDnActions[] = {
{ DESTROY , (BOOL (*)(OBJPTR, void *, void *))WdeUpDnDestroy }
, { COPY , (BOOL (*)(OBJPTR, void *, void *))WdeUpDnCopyObject }
, { VALIDATE_ACTION , (BOOL (*)(OBJPTR, void *, void *))WdeUpDnValidateAction }
, { IDENTIFY , (BOOL (*)(OBJPTR, void *, void *))WdeUpDnIdentify }
, { GET_WINDOW_CLASS , (BOOL (*)(OBJPTR, void *, void *))WdeUpDnGetWindowClass }
, { DEFINE , (BOOL (*)(OBJPTR, void *, void *))WdeUpDnDefine }
, { GET_WND_PROC , (BOOL (*)(OBJPTR, void *, void *))WdeUpDnGetWndProc }
};
#define MAX_ACTIONS (sizeof(WdeUpDnActions)/sizeof (DISPATCH_ITEM))
OBJPTR WINEXPORT WdeUpDnCreate( OBJPTR parent, RECT *obj_rect, OBJPTR handle)
{
if( handle == NULL ) {
return( WdeMakeUpDn( parent, obj_rect, handle,
0, "", UPDOWN_OBJ ) );
} else {
return( WdeUDCreate( parent, obj_rect, NULL, UPDOWN_OBJ,
(WdeDialogBoxControl *) handle) );
}
}
OBJPTR WdeMakeUpDn( OBJPTR parent, RECT *obj_rect, OBJPTR handle,
DialogStyle style, char *text, OBJ_ID id )
{
OBJPTR new;
style |= WS_BORDER | WS_VISIBLE | WS_TABSTOP | WS_CHILD;
SETCTL_STYLE( WdeDefaultUpDn, style );
SETCTL_TEXT( WdeDefaultUpDn, ResStrToNameOrOrd( text ) );
SETCTL_ID( WdeDefaultUpDn, WdeGetNextControlID() );
WdeChangeSizeToDefIfSmallRect ( parent, id, obj_rect );
new = WdeUDCreate ( parent, obj_rect, handle, id, WdeDefaultUpDn );
WdeMemFree( GETCTL_TEXT(WdeDefaultUpDn) );
SETCTL_TEXT( WdeDefaultUpDn, NULL );
return ( new );
}
OBJPTR WdeUDCreate( OBJPTR parent, RECT *obj_rect, OBJPTR handle,
OBJ_ID id, WdeDialogBoxControl *info)
{
WdeUpDnObject *new;
WdeDebugCreate("UpDn", parent, obj_rect, handle);
if ( parent == NULL ) {
WdeWriteTrail("WdeUpDnCreate: UpDn has no parent!");
return ( NULL );
}
new = (WdeUpDnObject *) WdeMemAlloc ( sizeof(WdeUpDnObject) );
if ( new == NULL ) {
WdeWriteTrail("WdeUpDnCreate: Object malloc failed");
return ( NULL );
}
new->dispatcher = WdeUpDnDispatch;
new->object_id = id;
if ( handle == NULL ) {
new->object_handle = new;
} else {
new->object_handle = handle;
}
new->control = Create( CONTROL_OBJ, parent, obj_rect, new->object_handle);
if (new->control == NULL) {
WdeWriteTrail("WdeUpDnCreate: CONTROL_OBJ not created!");
WdeMemFree ( new );
return ( NULL );
}
if (!Forward ( (OBJPTR)new->object_handle, SET_OBJECT_INFO, info, NULL) ) {
WdeWriteTrail("WdeUpDnCreate: SET_OBJECT_INFO failed!");
Destroy ( new->control, FALSE );
WdeMemFree ( new );
return ( NULL );
}
if (!Forward ( (OBJPTR)new->object_handle, CREATE_WINDOW,
NULL, NULL) ) {
WdeWriteTrail("WdeUpDnCreate: CREATE_WINDOW failed!");
Destroy ( new->control, FALSE );
WdeMemFree ( new );
return ( NULL );
}
return ( new );
}
BOOL WINEXPORT WdeUpDnDispatcher ( ACTION act, WdeUpDnObject *obj,
void *p1, void *p2)
{
int i;
WdeDebugDispatch("UpDn", act, obj, p1, p2);
for ( i = 0; i < MAX_ACTIONS; i++ ) {
if( WdeUpDnActions[i].id == act ) {
return( (WdeUpDnActions[i].rtn)( obj, p1, p2 ) );
}
}
return (Forward ((OBJPTR)obj->control, act, p1, p2));
}
Bool WdeUpDnInit( Bool first )
{
WNDCLASS wc;
WdeApplicationInstance = WdeGetAppInstance();
GetClassInfo( (HINSTANCE)NULL, WUPDOWN_CLASS, &wc );
WdeOriginalUpDnProc = wc.lpfnWndProc;
WdeUpDnWndExtra = wc.cbWndExtra;
if( first ) {
#if 0
if ( wc.style & CS_GLOBALCLASS ) {
wc.style ^= CS_GLOBALCLASS;
}
if ( wc.style & CS_PARENTDC ) {
wc.style ^= CS_PARENTDC;
}
wc.style |= ( CS_HREDRAW | CS_VREDRAW );
wc.hInstance = WdeApplicationInstance;
wc.lpszClassName = "wdeedit";
wc.cbWndExtra += sizeof( OBJPTR );
//wc.lpfnWndProc = WdeUpDnSuperClassProc;
if( !RegisterClass( &wc ) ) {
WdeWriteTrail("WdeUpDnInit: RegisterClass failed.");
}
#endif
}
WdeDefaultUpDn = WdeAllocDialogBoxControl ();
if( !WdeDefaultUpDn ) {
WdeWriteTrail ("WdeUpDnInit: Alloc of control failed!");
return( FALSE );
}
/* set up the default control structure */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -