📄 wdefcust.c
字号:
SETCTL_STYLE( WdeDefaultCustom, style );
control = WdeDefaultCustom;
} else {
control = (WdeDialogBoxControl *) handle;
class_name = WdeControlClassToStr( GETCTL_CLASSID(control) );
if( class_name ) {
WdeFindClassInAllCustLibs( class_name, &info_list );
WdeMemFree( class_name );
}
if( info_list == NULL ) {
WdeWriteTrail("WdeMakeCustom: "
"There are no custom controls of this class!");
WdeSetStatusByID( -1, WDE_NOCUSTOMFORCLASS );
return( NULL );
}
WdeChooseCustControlFromList ( info_list, control,
&cust_info, &cust_type );
if ( cust_info == NULL ) {
WdeWriteTrail("WdeMakeCustom: "
"No custom control fits this class & style!");
WdeSetStatusByID( -1, WDE_CANTFINDCUSTOM );
return( NULL );
}
}
WdeCheckForSmallRect( parent, cust_info, cust_type, obj_rect );
ret = WdeCustomCreater ( parent, obj_rect, NULL,
( CUSTCNTL1_OBJ + which ),
control, cust_info, cust_type );
if ( handle == NULL ) {
WdeMemFree( GETCTL_TEXT(WdeDefaultCustom) );
WdeMemFree( GETCTL_CLASSID(WdeDefaultCustom) );
}
SETCTL_STYLE( WdeDefaultCustom, 0 );
SETCTL_TEXT( WdeDefaultCustom, NULL );
SETCTL_CLASSID( WdeDefaultCustom, NULL );
return ( ret );
}
void WdeFreeClassList ( void )
{
LIST *clist;
WdeCustClassNode *node;
for ( clist = WdeCustClassList; clist; clist = ListNext( clist ) ) {
node = (WdeCustClassNode *) ListElement ( clist );
WdeFreeClassNode ( node );
}
return;
}
void WdeFreeClassNode ( WdeCustClassNode *node )
{
if ( node != NULL ) {
if ( node->class != NULL ) {
WdeMemFree ( node->class );
}
if ( node->new_name != NULL ) {
WdeMemFree ( node->new_name );
}
WdeMemFree ( node );
}
}
Bool WdeAddNewClassToList ( char *class, char *new_name,
int win_extra, WNDPROC win_proc )
{
WdeCustClassNode *node;
char *str;
node = (WdeCustClassNode *) WdeMemAlloc ( sizeof (WdeCustClassNode) );
if ( node == NULL ) {
WdeWriteTrail("WdeAddNewClassToList: node alloc failed!");
return ( FALSE );
}
str = WdeStrDup ( class );
if ( str == NULL ) {
WdeWriteTrail("WdeAddNewClassToList: class strdup failed!");
WdeMemFree ( node );
return ( FALSE );
}
node->class = str;
str = WdeStrDup ( new_name );
if ( str == NULL ) {
WdeWriteTrail("WdeAddNewClassToList: new_name alloc failed!");
WdeMemFree ( node->class );
WdeMemFree ( node );
return ( FALSE );
}
node->new_name = str;
node->win_extra = win_extra;
node->win_proc = win_proc;
WdeInsertObject ( &WdeCustClassList, (void *)node );
return ( TRUE );
}
LIST *WdeFindClassInList ( char *class )
{
LIST *clist;
WdeCustClassNode *node;
for ( clist = WdeCustClassList; clist; clist = ListNext( clist ) ) {
node = (WdeCustClassNode *) ListElement ( clist );
if ( !strcmpi ( node->class, class ) ) {
break;
}
}
return ( clist );
}
Bool WdeCustomRegisterClass ( char *class, HINSTANCE inst, char **new_name,
int *win_extra, WNDPROC *win_proc )
{
WdeCustClassNode *node;
WNDCLASS wc;
LIST *clist;
if ( ( clist = WdeFindClassInList ( class ) ) != NULL ) {
node = (WdeCustClassNode *) ListElement ( clist );
*win_extra = node->win_extra;
*win_proc = node->win_proc;
*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,
WdeCustControl *cust_info, UINT cust_type )
{
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 );
}
if ( cust_info->ms_lib ) {
class = cust_info->control_info.ms.szClass;
} else {
class = cust_info->control_info.bor.szClass;
}
if ( !WdeCustomRegisterClass ( class, cust_info->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_info = cust_info;
new->cust_type = cust_type;
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());
WdeStr2ID = MakeProcInstance ( (FARPROC) WdeStrToID, WdeApplicationInstance );
WdeID2Str = MakeProcInstance ( (FARPROC) WdeIDToStr, WdeApplicationInstance );
return( TRUE );
}
void WdeCustomFini ( void )
{
WdeFreeClassList ();
WdeFreeDialogBoxControl ( &WdeDefaultCustom );
FreeProcInstance ( WdeCustomDispatch );
FreeProcInstance ( WdeStr2ID );
FreeProcInstance ( WdeID2Str );
}
BOOL WdeCustomDestroy ( WdeCustomObject *obj, BOOL *flag, void *p2 )
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -