📄 wdefcust.c
字号:
*new_name = WdeStrDup( node->new_name );
if( *new_name == NULL ) {
WdeWriteTrail("WdeCustomRegisterClass: new_name alloc failed!");
return( FALSE );
}
return( TRUE );
}
if( !GetClassInfo( inst, class, &wc ) ) {
WdeWriteTrail("WdeCustomRegisterClass: GetClassInfo failed!");
return( FALSE );
}
*new_name = (char *) WdeMemAlloc( strlen( class ) + 5 );
if( *new_name == NULL ) {
WdeWriteTrail("WdeCustomRegisterClass: new_name alloc failed!");
return( FALSE );
}
strcpy( *new_name, "WDE_" );
strcat( *new_name, class );
*win_extra = wc.cbWndExtra;
*win_proc = wc.lpfnWndProc;
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 = *new_name;
wc.cbWndExtra += sizeof( WNDPROC );
//wc.lpfnWndProc = WdeCustomSuperClassProc;
if( !RegisterClass( &wc ) ) {
WdeWriteTrail("WdeCustomRegisterClass: RegisterClass failed!");
//subclass controls instead of super classing them makes this
// much less fatal
//WdeMemFree ( *new_name );
//return ( FALSE );
}
if( !WdeAddNewClassToList(class, *new_name, *win_extra, *win_proc) ) {
WdeWriteTrail("WdeCustomRegisterClass: AddNewClass failed!");
WdeMemFree( *new_name );
return( FALSE );
}
return( TRUE );
}
OBJPTR WdeCustomCreater ( OBJPTR parent, RECT *obj_rect, OBJPTR handle,
OBJ_ID id, WdeDialogBoxControl *info,
WdeCustLib *cust_lib, UINT cust_index )
{
WdeCustomObject *new;
char *class;
WdeDebugCreate("Custom", parent, obj_rect, handle);
WdeMemValidate ( parent );
if ( parent == NULL ) {
WdeWriteTrail("WdeCustomCreate: Custom has no parent!");
return ( NULL );
}
new = (WdeCustomObject *) WdeMemAlloc ( sizeof(WdeCustomObject) );
if ( new == NULL ) {
WdeWriteTrail("WdeCustomCreate: Object malloc failed");
return ( NULL );
}
class = cust_lib->lpcci[cust_index].szClass;
if ( !WdeCustomRegisterClass ( class, cust_lib->inst,
&new->win_class,
&new->win_extra, &new->win_proc ) ) {
WdeWriteTrail("WdeCustomCreate: WdeCustomRegisterClass failed!");
WdeMemFree ( new );
return ( NULL );
}
new->dispatcher = WdeCustomDispatch;
new->object_id = id;
new->cust_lib = cust_lib;
new->cust_index = cust_index;
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("WdeCustomCreate: CONTROL_OBJ not created!");
WdeMemFree ( new );
return ( NULL );
}
if (!Forward ( (OBJPTR)new->object_handle, SET_OBJECT_INFO, info, NULL) ) {
WdeWriteTrail("WdeCustomCreate: SET_OBJECT_INFO failed!");
Destroy ( new->control, FALSE );
WdeMemFree ( new );
return ( NULL );
}
if (!Forward ( (OBJPTR)new->object_handle, CREATE_WINDOW,
NULL, NULL) ) {
WdeWriteTrail("WdeCustomCreate: CREATE_WINDOW failed!");
Destroy ( new->control, FALSE );
WdeMemFree ( new );
return ( NULL );
}
return ( new );
}
BOOL WINEXPORT WdeCustomDispatcher ( ACTION act, WdeCustomObject *obj,
void *p1, void *p2)
{
int i;
WdeDebugDispatch("Custom", act, obj, p1, p2);
WdeMemChkRange ( obj, sizeof(WdeCustomObject) );
for ( i = 0; i < MAX_ACTIONS; i++ ) {
if( WdeCustomActions[i].id == act ) {
return( (WdeCustomActions[i].rtn)( obj, p1, p2 ) );
}
}
return (Forward ((OBJPTR)obj->control, act, p1, p2));
}
Bool WdeCustomInit ( Bool first )
{
_wde_touch(first);
WdeApplicationInstance = WdeGetAppInstance();
WdeDefaultCustom = WdeAllocDialogBoxControl ();
if ( !WdeDefaultCustom ) {
WdeWriteTrail ("WdeCustomInit: Alloc of control failed!");
return( FALSE );
}
/* set up the default control structure */
SETCTL_STYLE( WdeDefaultCustom, 0 );
SETCTL_ID( WdeDefaultCustom, 0 );
SETCTL_EXTRABYTES( WdeDefaultCustom, 0 );
SETCTL_SIZEX( WdeDefaultCustom, 0 );
SETCTL_SIZEY( WdeDefaultCustom, 0 );
SETCTL_SIZEW( WdeDefaultCustom, 0 );
SETCTL_SIZEH( WdeDefaultCustom, 0 );
SETCTL_TEXT( WdeDefaultCustom, NULL );
SETCTL_CLASSID( WdeDefaultCustom, NULL );
WdeCustomDispatch = MakeProcInstance((FARPROC)WdeCustomDispatcher,
WdeGetAppInstance());
return( TRUE );
}
void WdeCustomFini ( void )
{
WdeFreeClassList ();
WdeFreeDialogBoxControl ( &WdeDefaultCustom );
FreeProcInstance ( WdeCustomDispatch );
}
BOOL WdeCustomDestroy ( WdeCustomObject *obj, BOOL *flag, void *p2 )
{
/* touch unused vars to get rid of warning */
_wde_touch(p2);
if ( !Forward ( obj->control, DESTROY, flag, NULL ) ) {
WdeWriteTrail("WdeCustomDestroy: Control DESTROY failed");
return ( FALSE );
}
if ( obj->win_class != NULL ) {
WdeMemFree( obj->win_class );
}
WdeMemFree( obj );
return ( TRUE );
}
BOOL WdeCustomValidateAction ( WdeCustomObject *obj, ACTION *act, void *p2 )
{
int i;
for ( i = 0; i < MAX_ACTIONS; i++ ) {
if( WdeCustomActions[i].id == *act ) {
return ( TRUE );
}
}
return ( ValidateAction( (OBJPTR) obj->control, *act, p2 ) );
}
BOOL WdeCustomCopyObject ( WdeCustomObject *obj, WdeCustomObject **new,
WdeCustomObject *handle )
{
if (new == NULL) {
WdeWriteTrail("WdeCustomCopyObject: Invalid new object!");
return ( FALSE );
}
*new = (WdeCustomObject *) WdeMemAlloc ( sizeof(WdeCustomObject) );
if ( *new == NULL ) {
WdeWriteTrail("WdeCustomCopyObject: Object malloc failed");
return ( FALSE );
}
(*new)->dispatcher = obj->dispatcher;
(*new)->win_proc = obj->win_proc;
(*new)->win_extra = obj->win_extra;
(*new)->object_id = obj->object_id;
(*new)->cust_lib = obj->cust_lib;
(*new)->cust_index = obj->cust_index;
(*new)->win_class = WdeStrDup ( obj->win_class );
if ( (*new)->win_class == NULL ) {
WdeWriteTrail("WdeCustomCopyObject: Class alloc failed!");
WdeMemFree ( (*new) );
return ( FALSE );
}
if ( handle == NULL ) {
(*new)->object_handle = *new;
} else {
(*new)->object_handle = handle;
}
if (!CopyObject(obj->control, &((*new)->control), (*new)->object_handle)) {
WdeWriteTrail("WdeCustomCopyObject: Control not created!");
WdeMemFree ( (*new) );
return ( FALSE );
}
return ( TRUE );
}
BOOL WdeCustomIdentify ( WdeCustomObject *obj, OBJ_ID *id, void *p2 )
{
/* touch unused vars to get rid of warning */
_wde_touch(p2);
*id = obj->object_id;
return ( TRUE );
}
BOOL WdeCustomGetWndProc( WdeCustomObject *obj, WNDPROC *proc, void *p2 )
{
/* touch unused vars to get rid of warning */
_wde_touch(obj);
_wde_touch(p2);
*proc = WdeCustomSuperClassProc;
return ( TRUE );
}
BOOL WdeCustomGetWindowClass ( WdeCustomObject *obj, char **class, void *p2 )
{
/* touch unused vars to get rid of warning */
_wde_touch(obj);
_wde_touch(p2);
*class = obj->win_class;
return ( TRUE );
}
BOOL WdeCustomDefine ( WdeCustomObject *obj, POINT *pnt, void *p2 )
{
BOOL redraw;
HWND dialog_owner;
LPCCINFO lpcci;
CCSTYLE ccs;
WdeDefineObjectInfo o_info;
WdeDialogBoxControl *info;
char *text;
int tlen;
LPFNCCSTYLE proc;
/* touch unused vars to get rid of warning */
_wde_touch(pnt);
_wde_touch(p2);
if ( !Forward ( (OBJPTR)obj, GET_WINDOW_HANDLE, &o_info.win, NULL ) ) {
WdeWriteTrail("WdeControlDefine: GET_WINDOW_HANDLE failed!");
return ( FALSE );
}
if ( !Forward ( obj->object_handle, GET_OBJECT_INFO,
&(o_info.info.c.info), &(o_info.symbol) ) ) {
WdeWriteTrail("WdeCustomDefine: GET_OBJECT_INFO failed!");
return ( FALSE );
}
if ( !WdeGetOption ( WdeOptUseDefDlg ) ) {
o_info.obj = obj->object_handle;
o_info.obj_id = obj->object_id;
o_info.mask = 0xffff;
o_info.hook_func = WdeWinStylesHook;
o_info.set_func = NULL;
o_info.get_func = NULL;
o_info.res_info = WdeGetCurrentRes();
return ( WdeGenericDefine ( &o_info ) );
}
info = o_info.info.c.info;
dialog_owner = WdeGetMainWindowHandle();
WdeSetStatusText( NULL, "", FALSE );
WdeSetStatusByID( WDE_DEFININGCUSTOM, -1 );
lpcci = &(obj->cust_lib->lpcci[obj->cust_index]);
ccs.flStyle = GETCTL_STYLE( info );
ccs.flExtStyle = 0L;
ccs.lgid = 0;
ccs.wReserved1 = 0;
if( text = WdeResNameOrOrdinalToStr( GETCTL_TEXT( info ), 10 ) ) {
tlen = strlen ( text );
if ( tlen < CCHCCTEXT ) {
strcpy ( ccs.szText, text );
} else {
memcpy ( ccs.szText, text, CCHCCTEXT );
ccs.szText[CCHCCTEXT-1] = '\0';
}
WdeMemFree ( text );
} else {
ccs.szText[0] = '\0';
}
proc = lpcci->lpfnStyle;
redraw = (BOOL) (*proc) ( dialog_owner, &ccs );
if ( redraw ) {
SETCTL_STYLE( info, ( DialogStyle ) ccs.flStyle );
if ( !Forward ( obj->object_handle, DESTROY_WINDOW, NULL, NULL ) ) {
WdeWriteTrail("WdeCustumDefine: DESTROY_WINDOW failed!");
return ( FALSE );
}
if (!Forward (obj->object_handle, CREATE_WINDOW, NULL, NULL)) {
WdeWriteTrail("WdeCustumDefine: CREATE_WINDOW failed!");
return ( FALSE );
}
Notify ( obj->object_handle, CURRENT_OBJECT, NULL );
}
WdeSetStatusReadyText();
return ( TRUE );
}
LRESULT WINEXPORT WdeCustomSuperClassProc( HWND hWnd, UINT message,
WPARAM wParam,
volatile LPARAM lParam )
{
WNDPROC wnd_proc;
int extra;
LIST *clist;
WdeCustClassNode *node;
if ( WdeProcessMouse ( hWnd, message, wParam, lParam ) ) {
return ( FALSE );
}
extra = (int) GET_CBWNDEXTRA( hWnd );
extra -= sizeof(WNDPROC);
wnd_proc = (WNDPROC) GetWindowLong ( hWnd, extra );
if ( wnd_proc == NULL ) {
if ( !GetClassName ( hWnd, WdeClassName, MAX_NAME ) ) {
WdeWriteTrail("WdeCustomSuperClassProc: GetClassName failed!");
return ( FALSE );
}
clist = WdeFindClassInList ( &(WdeClassName[4]) );
if ( clist == NULL ) {
WdeWriteTrail("WdeCustomSuperClassProc: FindClassInList failed!");
return ( FALSE );
}
node = (WdeCustClassNode *) ListElement ( clist );
wnd_proc = node->win_proc;
if ( wnd_proc == NULL ) {
WdeWriteTrail("WdeCustomSuperClassProc: NULL wnd_proc!");
return ( FALSE );
}
SetWindowLong ( hWnd, extra, (LONG) wnd_proc );
}
return ( CallWindowProc ( wnd_proc, hWnd, message, wParam, lParam ) );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -