📄 wdeflbox.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 "wdedebug.h"
#include "wdedefsz.h"
#include "wdeoinfo.h"
#include "wde_rc.h"
#include "wdecctl.h"
#include "wdeflbox.h"
/****************************************************************************/
/* type definitions */
/****************************************************************************/
typedef struct {
FARPROC dispatcher;
OBJPTR object_handle;
OBJ_ID object_id;
OBJPTR control;
} WdeLBoxObject;
/****************************************************************************/
/* external function prototypes */
/****************************************************************************/
extern BOOL WINEXPORT WdeLBoxDispatcher ( ACTION, WdeLBoxObject *, void *,
void * );
extern LRESULT WINEXPORT WdeLBoxSuperClassProc ( HWND, UINT, WPARAM, LPARAM);
/****************************************************************************/
/* static function prototypes */
/****************************************************************************/
static OBJPTR WdeMakeLBox ( OBJPTR, RECT *, OBJPTR, DialogStyle,
char *, OBJ_ID );
static OBJPTR WdeLBCreate ( OBJPTR, RECT *, OBJPTR,
OBJ_ID, WdeDialogBoxControl *);
static BOOL WdeLBoxDestroy ( WdeLBoxObject *, BOOL *, void *);
static BOOL WdeLBoxValidateAction ( WdeLBoxObject *, ACTION *, void *);
static BOOL WdeLBoxCopyObject ( WdeLBoxObject *, WdeLBoxObject **,
WdeLBoxObject *);
static BOOL WdeLBoxIdentify ( WdeLBoxObject *, OBJ_ID *, void *);
static BOOL WdeLBoxGetWndProc ( WdeLBoxObject *, WNDPROC *, void *);
static BOOL WdeLBoxGetWindowClass ( WdeLBoxObject *, char **, void *);
static BOOL WdeLBoxDefine ( WdeLBoxObject *, POINT *, void *);
static void WdeLBoxSetDefineInfo ( WdeDefineObjectInfo *, HWND );
static void WdeLBoxGetDefineInfo ( WdeDefineObjectInfo *, HWND );
static BOOL WdeLBoxDefineHook ( HWND, UINT, WPARAM, LPARAM,
DialogStyle );
/****************************************************************************/
/* static variables */
/****************************************************************************/
static HINSTANCE WdeApplicationInstance;
static FARPROC WdeLBoxDispatch;
static WdeDialogBoxControl *WdeDefaultLBox = NULL;
static int WdeLBoxWndExtra;
static WNDPROC WdeOriginalLBoxProc;
//static WNDPROC WdeLBoxProc;
static DISPATCH_ITEM WdeLBoxActions[] = {
{ DESTROY , (BOOL (*)(OBJPTR, void *, void *))WdeLBoxDestroy }
, { COPY , (BOOL (*)(OBJPTR, void *, void *))WdeLBoxCopyObject }
, { VALIDATE_ACTION , (BOOL (*)(OBJPTR, void *, void *))WdeLBoxValidateAction }
, { IDENTIFY , (BOOL (*)(OBJPTR, void *, void *))WdeLBoxIdentify }
, { GET_WINDOW_CLASS , (BOOL (*)(OBJPTR, void *, void *))WdeLBoxGetWindowClass }
, { DEFINE , (BOOL (*)(OBJPTR, void *, void *))WdeLBoxDefine }
, { GET_WND_PROC , (BOOL (*)(OBJPTR, void *, void *))WdeLBoxGetWndProc }
};
#define MAX_ACTIONS (sizeof(WdeLBoxActions)/sizeof (DISPATCH_ITEM))
OBJPTR WINEXPORT WdeLBoxCreate ( OBJPTR parent, RECT *obj_rect,
OBJPTR handle)
{
if ( handle == NULL ) {
return (WdeMakeLBox ( parent, obj_rect, handle,
LBS_STANDARD,
"",
LISTBOX_OBJ));
} else {
return ( WdeLBCreate ( parent, obj_rect, NULL,
LISTBOX_OBJ, (WdeDialogBoxControl *) handle) );
}
}
OBJPTR WdeMakeLBox ( OBJPTR parent, RECT *obj_rect, OBJPTR handle,
DialogStyle style, char *text, OBJ_ID id )
{
OBJPTR new;
style |= WS_VISIBLE | WS_TABSTOP | WS_CHILD;
SETCTL_STYLE( WdeDefaultLBox, style );
SETCTL_TEXT( WdeDefaultLBox, ResStrToNameOrOrd(text) );
SETCTL_ID( WdeDefaultLBox, WdeGetNextControlID() );
WdeChangeSizeToDefIfSmallRect ( parent, id, obj_rect );
new = WdeLBCreate ( parent, obj_rect, handle, id, WdeDefaultLBox );
WdeMemFree( GETCTL_TEXT(WdeDefaultLBox) );
SETCTL_TEXT( WdeDefaultLBox, NULL );
return ( new );
}
OBJPTR WdeLBCreate ( OBJPTR parent, RECT *obj_rect, OBJPTR handle,
OBJ_ID id, WdeDialogBoxControl *info)
{
WdeLBoxObject *new;
WdeDebugCreate("LBox", parent, obj_rect, handle);
if ( parent == NULL ) {
WdeWriteTrail("WdeLBoxCreate: LBox has no parent!");
return ( NULL );
}
new = (WdeLBoxObject *) WdeMemAlloc ( sizeof(WdeLBoxObject) );
if ( new == NULL ) {
WdeWriteTrail("WdeLBoxCreate: Object malloc failed");
return ( NULL );
}
new->dispatcher = WdeLBoxDispatch;
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("WdeLBoxCreate: CONTROL_OBJ not created!");
WdeMemFree ( new );
return ( NULL );
}
if (!Forward ( (OBJPTR)new->object_handle, SET_OBJECT_INFO, info, NULL) ) {
WdeWriteTrail("WdeLBoxCreate: SET_OBJECT_INFO failed!");
Destroy ( new->control, FALSE );
WdeMemFree ( new );
return ( NULL );
}
if (!Forward ( (OBJPTR)new->object_handle, CREATE_WINDOW,
NULL, NULL) ) {
WdeWriteTrail("WdeLBoxCreate: CREATE_WINDOW failed!");
Destroy ( new->control, FALSE );
WdeMemFree ( new );
return ( NULL );
}
return ( new );
}
BOOL WINEXPORT WdeLBoxDispatcher ( ACTION act, WdeLBoxObject *obj,
void *p1, void *p2)
{
int i;
WdeDebugDispatch("LBox", act, obj, p1, p2);
for ( i = 0; i < MAX_ACTIONS; i++ ) {
if( WdeLBoxActions[i].id == act ) {
return( (WdeLBoxActions[i].rtn)( obj, p1, p2 ) );
}
}
return (Forward ((OBJPTR)obj->control, act, p1, p2));
}
Bool WdeLBoxInit( Bool first )
{
WNDCLASS wc;
WdeApplicationInstance = WdeGetAppInstance();
GetClassInfo( (HINSTANCE)NULL, "LISTBOX", &wc );
WdeOriginalLBoxProc = wc.lpfnWndProc;
WdeLBoxWndExtra = 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 = "wdelistbox";
wc.cbWndExtra += sizeof( OBJPTR );
//wc.lpfnWndProc = WdeLBoxSuperClassProc;
if( !RegisterClass( &wc ) ) {
WdeWriteTrail("WdeLBoxInit: RegisterClass failed.");
}
#endif
}
WdeDefaultLBox = WdeAllocDialogBoxControl ();
if( !WdeDefaultLBox ) {
WdeWriteTrail ("WdeLBoxInit: Alloc of control failed!");
return( FALSE );
}
/* set up the default control structure */
SETCTL_STYLE( WdeDefaultLBox, 0 );
SETCTL_ID( WdeDefaultLBox, 0 );
SETCTL_EXTRABYTES( WdeDefaultLBox, 0 );
SETCTL_SIZEX( WdeDefaultLBox, 0 );
SETCTL_SIZEY( WdeDefaultLBox, 0 );
SETCTL_SIZEW( WdeDefaultLBox, 0 );
SETCTL_SIZEH( WdeDefaultLBox, 0 );
SETCTL_TEXT( WdeDefaultLBox, NULL );
SETCTL_CLASSID( WdeDefaultLBox, ResNumToControlClass(CLASS_LISTBOX) );
WdeLBoxDispatch = MakeProcInstance( (FARPROC)WdeLBoxDispatcher,
WdeGetAppInstance() );
return( TRUE );
}
void WdeLBoxFini ( void )
{
WdeFreeDialogBoxControl ( &WdeDefaultLBox );
FreeProcInstance ( WdeLBoxDispatch );
}
BOOL WdeLBoxDestroy ( WdeLBoxObject *obj, BOOL *flag, void *p2 )
{
/* touch unused vars to get rid of warning */
_wde_touch(p2);
if ( !Forward ( obj->control, DESTROY, flag, NULL ) ) {
WdeWriteTrail("WdeLBoxDestroy: Control DESTROY failed");
return ( FALSE );
}
WdeMemFree( obj );
return ( TRUE );
}
BOOL WdeLBoxValidateAction ( WdeLBoxObject *obj, ACTION *act, void *p2 )
{
int i;
/* touch unused vars to get rid of warning */
_wde_touch(p2);
for ( i = 0; i < MAX_ACTIONS; i++ ) {
if( WdeLBoxActions[i].id == *act ) {
return ( TRUE );
}
}
return ( ValidateAction( (OBJPTR) obj->control, *act, p2 ) );
}
BOOL WdeLBoxCopyObject ( WdeLBoxObject *obj, WdeLBoxObject **new,
WdeLBoxObject *handle )
{
if (new == NULL) {
WdeWriteTrail("WdeLBoxCopyObject: Invalid new object!");
return ( FALSE );
}
*new = (WdeLBoxObject *) WdeMemAlloc ( sizeof(WdeLBoxObject) );
if ( *new == NULL ) {
WdeWriteTrail("WdeLBoxCopyObject: Object malloc failed");
return ( FALSE );
}
(*new)->dispatcher = obj->dispatcher;
(*new)->object_id = obj->object_id;
if ( handle == NULL ) {
(*new)->object_handle = *new;
} else {
(*new)->object_handle = handle;
}
if (!CopyObject(obj->control, &((*new)->control), (*new)->object_handle)) {
WdeWriteTrail("WdeLBoxCopyObject: Control not created!");
WdeMemFree ( (*new) );
return ( FALSE );
}
return ( TRUE );
}
BOOL WdeLBoxIdentify ( WdeLBoxObject *obj, OBJ_ID *id, void *p2 )
{
/* touch unused vars to get rid of warning */
_wde_touch(p2);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -