📄 wdefcbox.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 "wderes.h"
#include "wdeobjid.h"
#include "wdefutil.h"
#include "wde_wres.h"
#include "wdeedit.h"
#include "wdemain.h"
#include "wdedefin.h"
#include "wdedebug.h"
#include "wdedefsz.h"
#include "wdeoinfo.h"
#include "wde_rc.h"
#include "wdecctl.h"
#include "wdefcbox.h"
/****************************************************************************/
/* type definitions */
/****************************************************************************/
typedef struct {
FARPROC dispatcher;
OBJPTR object_handle;
OBJ_ID object_id;
OBJPTR control;
} WdeCBoxObject;
/****************************************************************************/
/* external function prototypes */
/****************************************************************************/
extern BOOL WINEXPORT WdeCBoxDispatcher ( ACTION, WdeCBoxObject *, void *,
void * );
extern LRESULT WINEXPORT WdeCBoxSuperClassProc ( HWND, UINT, WPARAM, LPARAM);
/****************************************************************************/
/* static function prototypes */
/****************************************************************************/
static OBJPTR WdeMakeCBox ( OBJPTR, RECT *, OBJPTR, DialogStyle,
char *, OBJ_ID );
static OBJPTR WdeCBCreate ( OBJPTR, RECT *, OBJPTR,
OBJ_ID, WdeDialogBoxControl *);
static BOOL WdeCBoxDestroy ( WdeCBoxObject *, BOOL *, void *);
static BOOL WdeCBoxValidateAction ( WdeCBoxObject *, ACTION *, void *);
static BOOL WdeCBoxCopyObject ( WdeCBoxObject *, WdeCBoxObject **,
WdeCBoxObject *);
static BOOL WdeCBoxIdentify ( WdeCBoxObject *, OBJ_ID *, void *);
static BOOL WdeCBoxGetWndProc ( WdeCBoxObject *, WNDPROC *, void * );
static BOOL WdeCBoxGetWindowClass ( WdeCBoxObject *, char **, void *);
static BOOL WdeCBoxDefine ( WdeCBoxObject *, POINT *, void *);
static void WdeCBoxSetDefineInfo ( WdeDefineObjectInfo *, HWND );
static void WdeCBoxGetDefineInfo ( WdeDefineObjectInfo *, HWND );
static BOOL WdeCBoxDefineHook ( HWND, UINT, WPARAM, LPARAM,
DialogStyle );
/****************************************************************************/
/* static variables */
/****************************************************************************/
static HINSTANCE WdeApplicationInstance;
static FARPROC WdeCBoxDispatch;
static WdeDialogBoxControl *WdeDefaultCBox = NULL;
static int WdeCBoxWndExtra;
static WNDPROC WdeOriginalCBoxProc;
//static WNDPROC WdeCBoxProc;
static DISPATCH_ITEM WdeCBoxActions[] = {
{ DESTROY , (BOOL (*)(OBJPTR, void *, void *))WdeCBoxDestroy }
, { COPY , (BOOL (*)(OBJPTR, void *, void *))WdeCBoxCopyObject }
, { VALIDATE_ACTION , (BOOL (*)(OBJPTR, void *, void *))WdeCBoxValidateAction }
, { IDENTIFY , (BOOL (*)(OBJPTR, void *, void *))WdeCBoxIdentify }
, { GET_WINDOW_CLASS , (BOOL (*)(OBJPTR, void *, void *))WdeCBoxGetWindowClass }
, { DEFINE , (BOOL (*)(OBJPTR, void *, void *))WdeCBoxDefine }
, { GET_WND_PROC , (BOOL (*)(OBJPTR, void *, void *))WdeCBoxGetWndProc }
};
#define MAX_ACTIONS (sizeof(WdeCBoxActions)/sizeof (DISPATCH_ITEM))
OBJPTR WINEXPORT WdeCBoxCreate ( OBJPTR parent, RECT *obj_rect,
OBJPTR handle)
{
if ( handle == NULL ) {
return (WdeMakeCBox ( parent, obj_rect, handle,
CBS_DROPDOWN,
"",
COMBOBOX_OBJ));
} else {
return ( WdeCBCreate ( parent, obj_rect, NULL,
COMBOBOX_OBJ, (WdeDialogBoxControl *) handle) );
}
}
OBJPTR WdeMakeCBox ( 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( WdeDefaultCBox, style );
SETCTL_TEXT( WdeDefaultCBox, ResStrToNameOrOrd( text ) );
SETCTL_ID( WdeDefaultCBox, WdeGetNextControlID() );
WdeChangeSizeToDefIfSmallRect ( parent, id, obj_rect );
new = WdeCBCreate ( parent, obj_rect, handle, id, WdeDefaultCBox );
WdeMemFree( GETCTL_TEXT(WdeDefaultCBox) );
SETCTL_TEXT( WdeDefaultCBox, NULL );
return ( new );
}
OBJPTR WdeCBCreate ( OBJPTR parent, RECT *obj_rect, OBJPTR handle,
OBJ_ID id, WdeDialogBoxControl *info)
{
WdeCBoxObject *new;
WdeDebugCreate("CBox", parent, obj_rect, handle);
if ( parent == NULL ) {
WdeWriteTrail("WdeCBoxCreate: CBox has no parent!");
return ( NULL );
}
new = (WdeCBoxObject *) WdeMemAlloc ( sizeof(WdeCBoxObject) );
if ( new == NULL ) {
WdeWriteTrail("WdeCBoxCreate: Object malloc failed");
return ( NULL );
}
new->dispatcher = WdeCBoxDispatch;
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("WdeCBoxCreate: CONTROL_OBJ not created!");
WdeMemFree ( new );
return ( NULL );
}
if (!Forward ( (OBJPTR)new->object_handle, SET_OBJECT_INFO, info, NULL) ) {
WdeWriteTrail("WdeCBoxCreate: SET_OBJECT_INFO failed!");
Destroy ( new->control, FALSE );
WdeMemFree ( new );
return ( NULL );
}
if (!Forward ( (OBJPTR)new->object_handle, CREATE_WINDOW,
NULL, NULL) ) {
WdeWriteTrail("WdeCBoxCreate: CREATE_WINDOW failed!");
Destroy ( new->control, FALSE );
WdeMemFree ( new );
return ( NULL );
}
return ( new );
}
BOOL WINEXPORT WdeCBoxDispatcher ( ACTION act, WdeCBoxObject *obj,
void *p1, void *p2)
{
int i;
WdeDebugDispatch("CBox", act, obj, p1, p2);
for ( i = 0; i < MAX_ACTIONS; i++ ) {
if( WdeCBoxActions[i].id == act ) {
return( (WdeCBoxActions[i].rtn)( obj, p1, p2 ) );
}
}
return (Forward ((OBJPTR)obj->control, act, p1, p2));
}
Bool WdeCBoxInit( Bool first )
{
WNDCLASS wc;
WdeApplicationInstance = WdeGetAppInstance();
GetClassInfo( (HINSTANCE)NULL, "COMBOBOX", &wc );
WdeOriginalCBoxProc = wc.lpfnWndProc;
WdeCBoxWndExtra = 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 = "wdecombobox";
wc.cbWndExtra += sizeof( OBJPTR );
//wc.lpfnWndProc = WdeCBoxSuperClassProc;
if( !RegisterClass( &wc ) ) {
WdeWriteTrail("WdeCBoxInit: RegisterClass failed.");
}
#endif
}
WdeDefaultCBox = WdeAllocDialogBoxControl();
if( !WdeDefaultCBox ) {
WdeWriteTrail ("WdeCBoxInit: Alloc of control failed!");
return( FALSE );
}
/* set up the default control structure */
SETCTL_STYLE( WdeDefaultCBox, 0 );
SETCTL_ID( WdeDefaultCBox, 0 );
SETCTL_EXTRABYTES( WdeDefaultCBox, 0 );
SETCTL_SIZEX( WdeDefaultCBox, 0 );
SETCTL_SIZEY( WdeDefaultCBox, 0 );
SETCTL_SIZEW( WdeDefaultCBox, 0 );
SETCTL_SIZEH( WdeDefaultCBox, 0 );
SETCTL_TEXT( WdeDefaultCBox, NULL );
SETCTL_CLASSID( WdeDefaultCBox, ResNumToControlClass(CLASS_COMBOBOX) );
WdeCBoxDispatch = MakeProcInstance((FARPROC)WdeCBoxDispatcher,
WdeGetAppInstance());
return( TRUE );
}
void WdeCBoxFini ( void )
{
WdeFreeDialogBoxControl ( &WdeDefaultCBox );
FreeProcInstance ( WdeCBoxDispatch );
}
BOOL WdeCBoxDestroy ( WdeCBoxObject *obj, BOOL *flag, void *p2 )
{
/* touch unused vars to get rid of warning */
_wde_touch(p2);
if ( !Forward ( obj->control, DESTROY, flag, NULL ) ) {
WdeWriteTrail("WdeCBoxDestroy: Control DESTROY failed");
return ( FALSE );
}
WdeMemFree( obj );
return ( TRUE );
}
BOOL WdeCBoxValidateAction( WdeCBoxObject *obj, ACTION *act, void *p2 )
{
int i;
for ( i = 0; i < MAX_ACTIONS; i++ ) {
if( WdeCBoxActions[i].id == *act ) {
return ( TRUE );
}
}
return ( ValidateAction( (OBJPTR) obj->control, *act, p2 ) );
}
BOOL WdeCBoxCopyObject ( WdeCBoxObject *obj, WdeCBoxObject **new,
WdeCBoxObject *handle )
{
if (new == NULL) {
WdeWriteTrail("WdeCBoxCopyObject: Invalid new object!");
return ( FALSE );
}
*new = (WdeCBoxObject *) WdeMemAlloc ( sizeof(WdeCBoxObject) );
if ( *new == NULL ) {
WdeWriteTrail("WdeCBoxCopyObject: 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;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -