📄 wdesvdlg.c
字号:
tlen += 8; // size of the string PRELOAD and a space
}
if( !( flags & MEMFLAG_MOVEABLE ) ) {
tlen += 6; // size of the string FIXED and a space
}
if( flags & MEMFLAG_DISCARDABLE ) {
tlen += 12; // size of the string DISCARDABLE and a space
}
if( !( flags & MEMFLAG_PURE ) ) {
tlen += 7; // size of the string IMPURE and a space
}
if( tlen == 0 ) {
return( TRUE );
}
*text = (char *) WdeMemAlloc( tlen + 1 );
if( *text == NULL ) {
return( FALSE );
}
(*text)[0] = '\0';
if( flags & MEMFLAG_PRELOAD ) {
strcat( *text, "PRELOAD " );
}
if( !( flags & MEMFLAG_MOVEABLE ) ) {
strcat( *text, "FIXED " );
}
if( flags & MEMFLAG_DISCARDABLE ) {
strcat( *text, "DISCARDABLE " );
}
if( !( flags & MEMFLAG_PURE ) ) {
strcat( *text, "IMPURE " );
}
return( TRUE );
}
Bool WdeSetFlagText( flag_map *map, flag_style fs, unsigned long flags, char **text )
{
int tlen;
int new_tlen;
int slen;
int not_first;
if( ( map == NULL ) || ( text == NULL ) ) {
return( FALSE );
}
tlen = 0;
not_first = 0;
if( *text != NULL ) {
tlen = strlen( *text );
not_first = 1;
}
while( map->text ) {
if( ( ( flags & map->check_mask ) == map->flag ) && ( fs & map->style ) ) {
slen = strlen( map->text );
new_tlen = tlen + 3*not_first + slen + 1;
*text = (char *)WdeMemRealloc( *text, new_tlen );
if ( not_first == 1 ) {
strcat( *text, " | " );
strcat( *text, map->text );
} else {
strcpy( *text, map->text );
not_first = 1;
}
tlen = new_tlen;
flags &= ~map->erase_mask;
}
map++;
}
return( TRUE );
}
#ifdef NOT_NEEDED_CAUSE_NO_ONE_CALLS_IT
Bool WdeSetWindowFlagText( unsigned long flags, char **text )
{
if( text == NULL ) {
return( FALSE );
}
*text = NULL;
if( WdeSetFlagText( WindowMap, WindowStyle, flags, text ) ) {
return( TRUE );
}
if( *text ) {
WdeMemFree( *text );
*text = NULL;
}
return( FALSE );
}
#endif
static Bool WdeAddStyleString( char **text, char *str )
{
int slen;
int tlen;
if( !text || !str ) {
return( FALSE );
}
slen = strlen( str );
if( *text == NULL ) {
*text = WdeMemAlloc( slen + 1 );
if( *text ) {
strcpy( *text, str );
}
} else {
tlen = strlen( *text );
tlen += slen + 3 + 1;
*text = (char *)WdeMemRealloc( *text, tlen );
if( *text ) {
strcat( *text, " | " );
strcat( *text, str );
}
}
return( *text != NULL );
}
Bool WdeSetDialogFlagText( unsigned long flags, char **text )
{
if( text == NULL ) {
return( FALSE );
}
*text = NULL;
if( WdeSetFlagText( DialogMap, ControlStyle, flags, text ) ) {
if( ( flags & (WS_CHILD | WS_POPUP) ) == 0 ) {
WdeAddStyleString( text, "WS_OVERLAPPED" );
}
if( WdeSetFlagText( WindowMap, WindowStyle, flags, text ) ) {
return( TRUE );
}
}
if( *text ) {
WdeMemFree( *text );
*text = NULL;
}
return( FALSE );
}
Bool WdeSetEXFlagText( uint_32 flags, char **text )
{
uint_32 mask;
if( text == NULL ) {
return( FALSE );
}
*text = NULL;
mask = WS_EX_CLIENTEDGE | WS_EX_WINDOWEDGE;
if( (flags & mask) == mask ) {
WdeAddStyleString( text, "WS_EX_OVERLAPPEDWINDOW" );
} else {
if( flags & WS_EX_CLIENTEDGE ) {
WdeAddStyleString( text, "WS_EX_CLIENTEDGE" );
}
// WINDOWEDGE will be caught below
}
mask = WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
if( (flags & mask) == mask ) {
WdeAddStyleString( text, "WS_EX_PALETTEWINDOW" );
} else {
if( flags & WS_EX_WINDOWEDGE ) {
WdeAddStyleString( text, "WS_EX_WINDOWEDGE" );
}
if( flags & WS_EX_TOOLWINDOW ) {
WdeAddStyleString( text, "WS_EX_TOOLWINDOW" );
}
if( flags & WS_EX_TOPMOST ) {
WdeAddStyleString( text, "WS_EX_TOPMOST" );
}
}
if (flags & WS_EX_TRANSPARENT) {
WdeAddStyleString( text, "WS_EX_TRANSPARENT" );
}
if( WdeSetFlagText( WindowEXMap, WindowStyle, flags, text ) ) {
return( TRUE );
}
if( *text ) {
WdeMemFree( *text );
*text = NULL;
}
return( FALSE );
}
Bool WdeSetControlFlagText( uint_8 class, unsigned long flags, char **text )
{
Bool ok;
if( text == NULL ) {
return( FALSE );
}
*text = NULL;
ok = TRUE;
switch( class ) {
case CLASS_BUTTON:
ok = WdeSetFlagText( ButtonMap, ControlStyle, flags, text );
break;
case CLASS_EDIT:
if( ( flags & 0x3 ) == 0 ) {
ok = WdeAddStyleString( text, "ES_LEFT" );
}
ok = ok && WdeSetFlagText( EditMap, ControlStyle, flags, text );
break;
case CLASS_STATIC:
ok = WdeSetFlagText( StaticMap, ControlStyle, flags, text );
break;
case CLASS_LISTBOX:
ok = WdeSetFlagText( ListBoxMap, ControlStyle, flags, text );
break;
case CLASS_COMBOBOX:
ok = WdeSetFlagText( ComboBoxMap, ControlStyle, flags, text );
break;
case CLASS_SCROLLBAR:
if( flags & SBS_VERT ) {
ok = WdeSetFlagText( VScrollMap, ControlStyle, flags, text );
} else if( flags & SBS_SIZEBOX ) {
ok = WdeSetFlagText( SizeBoxMap, ControlStyle, flags, text );
} else {
ok = WdeSetFlagText( HScrollMap, ControlStyle, flags, text );
}
break;
default:
{
char msg[80];
sprintf(msg, "Class = 0x%2.2x ('m' = 0x%2.2x)", class, (int)'m');
MessageBox( (HWND)NULL, msg, "FYI", MB_OK);
}
break;
}
if( ok ) {
if( ( flags & (WS_CHILD | WS_POPUP) ) == 0 ) {
ok = WdeAddStyleString( text, "WS_OVERLAPPED" );
}
}
if( ok ) {
if( ( flags & WS_VISIBLE ) == 0 ) {
ok = WdeAddStyleString( text, "NOT WS_VISIBLE" );
}
}
if( ok ) {
ok = WdeSetFlagText( WindowMap, ControlStyle, flags, text );
}
if( !ok ) {
if( *text ) {
WdeMemFree( *text );
*text = NULL;
}
}
return( ok );
}
Bool WdeSetCommControlFlagText( char * control_class, unsigned long flags, char **text )
{
Bool ok;
if( text == NULL ) {
return( FALSE );
}
*text = NULL;
ok = TRUE;
if (stricmp(control_class, STATUSCLASSNAME) == 0) {
ok = WdeSetFlagText( StatusBarMap, ControlStyle, flags, text );
} else if (stricmp(control_class, WC_LISTVIEW) == 0) {
ok = WdeSetFlagText( ListViewMap, ControlStyle, flags, text );
} else if (stricmp(control_class, WC_TREEVIEW) == 0) {
ok = WdeSetFlagText( TreeViewMap, ControlStyle, flags, text );
} else if (stricmp(control_class, WC_TABCONTROL) == 0) {
ok = WdeSetFlagText( TabControlMap, ControlStyle, flags, text );
if (ok && !(flags & TCS_RAGGEDRIGHT)) { // default
ok = WdeAddStyleString( text, "TCS_RIGHTJUSTIFY" );
}
} else if (stricmp(control_class, ANIMATE_CLASS) == 0) {
ok = WdeSetFlagText( AnimateMap, ControlStyle, flags, text );
if (ok && (flags & ACS_TRANSPARENT)) {
ok = WdeAddStyleString( text, "ACS_TRANSPARENT" );
}
} else if (stricmp(control_class, UPDOWN_CLASS) == 0) {
ok = WdeSetFlagText( UpDownMap, ControlStyle, flags, text );
} else if (stricmp(control_class, TRACKBAR_CLASS) == 0) {
ok = WdeSetFlagText( TrackBarMap, ControlStyle, flags, text );
if (ok && (flags & TBS_LEFT)) { // same as TBS_TOP
if (flags & TBS_VERT) {
ok = WdeAddStyleString( text, "TBS_LEFT" );
} else {
ok = WdeAddStyleString( text, "TBS_TOP" );
}
}
} else if (stricmp(control_class, PROGRESS_CLASS) == 0) {
ok = WdeSetFlagText( ProgressMap, ControlStyle, flags, text );
} else if (stricmp(control_class, HOTKEY_CLASS) == 0) {
ok = WdeSetFlagText( HotkeyMap, ControlStyle, flags, text );
} else if (stricmp(control_class, WC_HEADER) == 0) {
ok = WdeSetFlagText( HeaderMap, ControlStyle, flags, text );
}
if( ok ) {
if( ( flags & (WS_CHILD | WS_POPUP) ) == 0 ) {
ok = WdeAddStyleString( text, "WS_OVERLAPPED" );
}
}
if( ok ) {
if( ( flags & WS_VISIBLE ) == 0 ) {
ok = WdeAddStyleString( text, "NOT WS_VISIBLE" );
}
}
if( ok ) {
ok = WdeSetFlagText( WindowMap, ControlStyle, flags, text );
}
if( !ok ) {
if( *text ) {
WdeMemFree( *text );
*text = NULL;
}
}
return( ok );
}
Bool WdeWriteDlgControl( WdeResInfo *rinfo, WdeDialogBoxControl *control,
Bool is32bitEx, FILE *fp, uint_16 nlength )
{
char *ctext;
char *n;
Bool ctext_alloc;
char *cid;
Bool cid_alloc;
char *cclass;
char *cstyle;
char *ExStyle;
ControlClass *control_class;
uint_8 class_type;
uint_16 nlen;
char *ControlStr;
int len;
Bool ok;
cid = NULL;
n = NULL;
ctext = NULL;
cclass = NULL;
cstyle = NULL;
ExStyle = NULL;
ctext_alloc = FALSE;
cid_alloc = FALSE;
ok = ( rinfo && control && GETCTL_CLASSID(control) && fp );
if( ok ) {
if( GETCTL_TEXT(control) ) {
ctext = WdeResNameOrOrdinalToStr( GETCTL_TEXT(control), 10 );
ctext_alloc = TRUE;
}
if( ctext == NULL ) {
ctext = "";
ctext_alloc = FALSE;
}
ok = ( ctext != NULL );
}
if( ok ) {
n = WRConvertStringFrom( ctext, "\t\n\"", "tn\"" );
ok = ( n != NULL );
}
if( ok ) {
control_class = GETCTL_CLASSID(control);
cclass = WdeControlClassToStr( control_class );
ok = ( cclass != NULL );
}
if( ok ) {
class_type = 0;
if( control_class ) {
if( control_class->Class & 0x80 ) {
class_type = control_class->Class;
}
}
if (class_type) {
ok = WdeSetControlFlagText( class_type, GETCTL_STYLE(control), &cstyle );
} else {
ok = WdeSetCommControlFlagText( control_class->ClassName, GETCTL_STYLE(control), &cstyle );
}
ok = ok && cstyle;
}
if( ok ) {
if( control->symbol ) {
cid = control->symbol;
} else if( rinfo->hash_table ) {
cid = WdeResolveValue( rinfo->hash_table, GETCTL_ID(control) );
if( cid ) {
cid_alloc = TRUE;
}
}
}
if( ok ) {
nlen = nlength + 12; // 12 is length of 'CONTROL..." string
ControlStr = WdeMemAlloc(nlen+1);
sprintf( ControlStr,"\tCONTROL \"%s\",", n );
for (len = strlen(ControlStr) ; len < nlen; len++) {
strcat(ControlStr, " ");
}
if( is32bitEx ) {
/* extended control ==> need extended style and help id */
char *helpsymbol;
/* build a help symbol for the DialogEx line */
if (control->helpsymbol) {
helpsymbol = WdeStrDup(control->helpsymbol);
} else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -