📄 semdiag.c
字号:
class = CLASS_SCROLLBAR;
defstyle_hi = DEF_SCROLLBAR_HI;
defstyle_lo = DEF_SCROLLBAR_LO;
break;
case Y_AUTO3STATE:
if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) {
class = CLASS_BUTTON;
defstyle_hi = DEF_AUTO3STATE_HI;
defstyle_lo = DEF_AUTO3STATE_LO;
} else {
RcWarning( ERR_NT_KEYWORD, SemTokenToString( token ) );
return( NULL );
}
break;
case Y_AUTOCHECKBOX:
if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) {
class = CLASS_BUTTON;
defstyle_hi = DEF_AUTOCHECKBOX_HI;
defstyle_lo = DEF_AUTOCHECKBOX_LO;
} else {
RcWarning( ERR_NT_KEYWORD, SemTokenToString( token ) );
return( NULL );
}
break;
case Y_AUTORADIOBUTTON:
if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) {
class = CLASS_BUTTON;
defstyle_hi = DEF_AUTORADIOBUTTON_HI;
defstyle_lo = DEF_AUTORADIOBUTTON_LO;
} else {
RcWarning( ERR_NT_KEYWORD, SemTokenToString( token ) );
return( NULL );
}
break;
// case Y_PUSHBOX:
// class = CLASS_BUTTON;
// defstyle_hi = DEF_PUSHBOX_HI;
// defstyle_lo = DEF_PUSHBOX_LO;
// break;
case Y_STATE3:
if( CmdLineParms.TargetOS == RC_TARGET_OS_WIN32 ) {
class = CLASS_BUTTON;
defstyle_hi = DEF_STATE3_HI;
defstyle_lo = DEF_STATE3_LO;
} else {
RcWarning( ERR_NT_KEYWORD, SemTokenToString( token ) );
return( NULL );
}
break;
}
newctrl = SemInitDiagCtrl();
cont_class = ResNumToControlClass( class );
style_mask = opts.Style.Mask;
style_value = opts.Style.Value;
switch( token ) {
case Y_COMBOBOX:
style_lo = defstyle_lo;
if( style_mask & LO_WORD ) {
style_lo = style_value;
}
break;
default:
tmp_mask = style_mask & LO_WORD;
style_lo = (tmp_mask & style_value) | (~tmp_mask & defstyle_lo);
break;
}
/* for the high word use the bits that were mentioned from style_value */
/* and all the other bits from defstyle_hi */
style_hi = (style_mask & style_value) | (~style_mask & defstyle_hi);
if( newctrl->Win32 ) {
newctrl->u.ctrl32.ID = opts.ID;
newctrl->u.ctrl32.Size = opts.Size;
newctrl->u.ctrl32.Text = opts.Text;
newctrl->u.ctrl32.ClassID = cont_class;
newctrl->u.ctrl32.Style = (style_lo & LO_WORD) | (style_hi & HI_WORD);
/* ExtraBytes and ExtendStyle are 0 for all controls */
/* that RC understands */
newctrl->u.ctrl32.ExtraBytes = 0;
newctrl->u.ctrl32.ExtendedStyle = opts.ExtendedStyle;
newctrl->u.ctrl32.HelpId = opts.HelpId;
newctrl->u.ctrl32.HelpIdDefined = opts.HelpIdDefined;
} else {
newctrl->u.ctrl.ID = opts.ID;
newctrl->u.ctrl.Size = opts.Size;
newctrl->u.ctrl.Text = opts.Text;
newctrl->u.ctrl.ClassID = cont_class;
newctrl->u.ctrl.Style = (style_lo & LO_WORD) | (style_hi & HI_WORD);
/* ExtraBytes is 0 for all controls that RC understands */
newctrl->u.ctrl.ExtraBytes = 0;
}
return( newctrl );
} /* SemNewDiagCtrl */
static void SemFreeDiagCtrlList( FullDiagCtrlList * list )
/********************************************************/
{
FullDialogBoxControl * ctrl;
FullDialogBoxControl * oldctrl;
ctrl = list->head;
while (ctrl != NULL) {
/* free the contents of pointers within the structure */
if( ctrl->Win32 ) {
if (ctrl->u.ctrl32.ClassID != NULL) {
RcMemFree( ctrl->u.ctrl32.ClassID );
}
if (ctrl->u.ctrl32.Text != NULL) {
RcMemFree( ctrl->u.ctrl32.Text );
}
} else {
if (ctrl->u.ctrl.ClassID != NULL) {
RcMemFree( ctrl->u.ctrl.ClassID );
}
if (ctrl->u.ctrl.Text != NULL) {
RcMemFree( ctrl->u.ctrl.Text );
}
}
oldctrl = ctrl;
ctrl = ctrl->next;
RcMemFree( oldctrl );
}
RcMemFree( list );
} /* SemFreeDiagCtrlList */
static void SemFreeDialogHeader( FullDialogBoxHeader * head )
/***********************************************************/
{
if( head->Win32 ) {
if (head->u.Head32.Head.MenuName != NULL) {
RcMemFree( head->u.Head32.Head.MenuName );
}
if (head->u.Head32.Head.ClassName != NULL) {
RcMemFree( head->u.Head32.Head.ClassName );
}
if (head->u.Head32.Head.Caption != NULL) {
RcMemFree( head->u.Head32.Head.Caption );
}
if (head->u.Head32.Head.FontName != NULL) {
RcMemFree( head->u.Head32.Head.FontName );
}
} else {
if (head->u.Head.MenuName != NULL) {
RcMemFree( head->u.Head.MenuName );
}
if (head->u.Head.ClassName != NULL) {
RcMemFree( head->u.Head.ClassName );
}
if (head->u.Head.Caption != NULL) {
RcMemFree( head->u.Head.Caption );
}
if (head->u.Head.FontName != NULL) {
RcMemFree( head->u.Head.FontName );
}
}
RcMemFree( head );
} /* SemFreeDialogHeader */
static int SemWriteDiagCtrlList( FullDiagCtrlList *list, int *err_code,
uint_16 tokentype )
/**********************************************************************/
{
int error;
FullDialogBoxControl * ctrl;
DialogBoxExControl32 controlex;
DialogBoxControl32 control;
for (ctrl = list->head, error = FALSE; ctrl != NULL && !error;
ctrl = ctrl->next) {
if( ctrl->Win32 ) {
if( tokentype == Y_DIALOG ) {
control.Style = ctrl->u.ctrl32.Style;
control.ExtendedStyle = ctrl->u.ctrl32.ExtendedStyle;
control.Size = ctrl->u.ctrl32.Size;
control.ID = ctrl->u.ctrl32.ID;
control.ClassID = ctrl->u.ctrl32.ClassID;
control.Text = ctrl->u.ctrl32.Text;
control.ExtraBytes = ctrl->u.ctrl32.ExtraBytes;
error = ResWriteDialogBoxControl32( &control, CurrResFile.handle );
} else if( tokentype == Y_DIALOG_EX ) {
controlex.HelpId = ctrl->u.ctrl32.HelpId;
controlex.ExtendedStyle = ctrl->u.ctrl32.ExtendedStyle;
controlex.Style = ctrl->u.ctrl32.Style;
controlex.Size = ctrl->u.ctrl32.Size;
controlex.ID = ctrl->u.ctrl32.ID;
controlex.ClassID = ctrl->u.ctrl32.ClassID;
controlex.Text = ctrl->u.ctrl32.Text;
controlex.ExtraBytes = ctrl->u.ctrl32.ExtraBytes;
error = ResWriteDialogExControl32( &controlex,
CurrResFile.handle);
if( ctrl->dataListHead != NULL ) {
SemFlushDataElemList( ctrl->dataListHead, FALSE );
}
}
if( !error ) {
error = ResPadDWord( CurrResFile.handle );
}
} else {
error = ResWriteDialogBoxControl( &(ctrl->u.ctrl),
CurrResFile.handle );
}
}
*err_code = LastWresErr();
return( error );
} /* SemWriteDiagCtrlList */
static uint_16 SemCountBytes( DataElemList *list )
/************************************************/
{
DataElemList *travptr;
uint_16 bytes = 0;
int i;
for( travptr = list; travptr != NULL; travptr = travptr->next ) {
for( i = 0; i < travptr->count; i++ ) {
if( travptr->data[i].IsString ) {
bytes += travptr->data[i].StrLen;
} else {
bytes += 2;
}
}
}
return( bytes );
}
static void SemCheckDialogBox( FullDialogBoxHeader *head, uint_16 tokentype,
DlgHelpId dlghelp, FullDiagCtrlList *ctrls )
/***************************************************************************/
{
FullDialogBoxControl *travptr;
if ( tokentype == Y_DIALOG && dlghelp.HelpIdDefined == TRUE ) {
RcError( ERR_DIALOG_HELPID );
} else if( tokentype == Y_DIALOG_EX && dlghelp.HelpIdDefined == TRUE ) {
head->u.Head32.ExHead.HelpId = dlghelp.HelpId;
}
if ( tokentype == Y_DIALOG ) {
if ( head->u.Head32.ExHead.FontItalicDefined == TRUE ) {
RcError( ERR_FONT_ITALIC );
}
if ( head->u.Head32.ExHead.FontWeightDefined == TRUE ) {
RcError( ERR_FONT_WEIGHT );
}
for ( travptr = ctrls->head; travptr != NULL; travptr = travptr->next ) {
if ( travptr->u.ctrl32.HelpIdDefined == TRUE ) {
RcError( ERR_DIALOG_CONTROL_HELPID );
}
if ( travptr->dataListHead != NULL ) {
SemFreeDataElemList( travptr->dataListHead );
RcError( ERR_DATA_ELEMENTS );
}
}
}
}
extern void SemWriteDialogBox( WResID *name, ResMemFlags flags,
DialogSizeInfo size, FullDialogBoxHeader *head,
FullDiagCtrlList *ctrls, DlgHelpId dlghelp,
uint_16 tokentype )
/******************************************************************/
{
ResLocation loc;
int err_code;
int error = 0;
FullDialogBoxControl *travptr;
if(head == NULL) {
head = NewDialogBoxHeader();
}
SemCheckDialogBox( head, tokentype, dlghelp, ctrls );
if( tokentype != Y_DIALOG ) {
for( travptr = ctrls->head; travptr != NULL; travptr = travptr->next ) {
if( travptr->dataListHead != NULL ) {
travptr->u.ctrl32.ExtraBytes = SemCountBytes( travptr->dataListHead );
}
}
}
if( head->Win32 ) {
if (!head->StyleGiven) {
head->u.Head32.Head.Style |= (WS_POPUP | WS_BORDER | WS_SYSMENU);
}
head->u.Head32.Head.NumOfItems = ctrls->numctrls;
head->u.Head32.Head.Size = size;
/* pad the start of the resource so that padding within the resource */
/* is easier */
error = ResPadDWord( CurrResFile.handle );
if (error) {
err_code = LastWresErr();
goto OutputWriteError;
}
} else {
if(!head->StyleGiven) {
head->u.Head.Style |= (WS_POPUP | WS_BORDER | WS_SYSMENU);
}
head->u.Head.NumOfItems = ctrls->numctrls;
head->u.Head.Size = size;
}
if(!ErrorHasOccured) {
loc.start = SemStartResource();
if( head->Win32 ) {
if( tokentype == Y_DIALOG ) {
error = ResWriteDialogBoxHeader32( &(head->u.Head32.Head),
CurrResFile.handle );
}
else if( tokentype == Y_DIALOG_EX ) {
error = ResWriteDialogExHeader32( &(head->u.Head32.Head),
&(head->u.Head32.ExHead), CurrResFile.handle );
}
if( !error ) {
error = ResPadDWord( CurrResFile.handle );
}
} else {
error = ResWriteDialogBoxHeader( &(head->u.Head),
CurrResFile.handle );
}
if( error ) {
err_code = LastWresErr();
goto OutputWriteError;
}
if( ctrls->head == NULL ) {
if( head->Win32 ) error = ResPadDWord( CurrResFile.handle );
} else {
error = SemWriteDiagCtrlList( ctrls, &err_code, tokentype );
}
if( error ) goto OutputWriteError;
loc.len = SemEndResource( loc.start );
SemAddResourceFree( name, WResIDFromNum( RT_DIALOG ), flags, loc );
} else {
RcMemFree( name );
}
SemFreeDialogHeader( head );
SemFreeDiagCtrlList( ctrls );
return;
OutputWriteError:
RcError( ERR_WRITTING_RES_FILE, CurrResFile.filename,
strerror( err_code ) );
ErrorHasOccured = TRUE;
SemFreeDialogHeader( head );
SemFreeDiagCtrlList( ctrls );
return;
} /* SemWriteDialogBox */
extern FullDialogBoxControl *SemSetControlData( IntMask ctrlstyle,
unsigned long cntlid, DialogSizeInfo sizeinfo, WResID *cntltext,
ResNameOrOrdinal *ctlclassname, uint_32 exstyle, DlgHelpId *help )
/***************************************************************************/
{
FullDialogBoxControl *control;
uint_32 mask;
uint_32 value;
uint_32 style;
mask = ctrlstyle.Mask;
value = ctrlstyle.Value;
style = (mask & value) | (~mask & (WS_CHILD|WS_VISIBLE));
control = SemInitDiagCtrl();
if( control->Win32 ) {
control->u.ctrl32.ID = cntlid;
control->u.ctrl32.Size = sizeinfo;
control->u.ctrl32.Text = WResIDToNameOrOrd( cntltext );
RcMemFree( cntltext );
control->u.ctrl32.ClassID = ResNameOrOrdToControlClass( ctlclassname );
control->u.ctrl32.Style = style;
/* ExtraBytes and ExtendStyle are 0 for all controls */
/* that RC understands */
control->u.ctrl32.ExtraBytes = 0;
control->u.ctrl32.ExtendedStyle = exstyle;
if( help != NULL ) {
control->u.ctrl32.HelpId = help->HelpId;
control->u.ctrl32.HelpIdDefined = help->HelpIdDefined;
} else {
control->u.ctrl32.HelpId = 0;
control->u.ctrl32.HelpIdDefined = FALSE;
}
RcMemFree( ctlclassname );
} else {
control->u.ctrl.ID = cntlid;
control->u.ctrl.Size = sizeinfo;
control->u.ctrl.Text = WResIDToNameOrOrd( cntltext );
RcMemFree( cntltext );
control->u.ctrl.ClassID = ResNameOrOrdToControlClass( ctlclassname );
control->u.ctrl.Style = style;
/* ExtraBytes is 0 for all controls that RC understands */
control->u.ctrl.ExtraBytes = 0;
RcMemFree( ctlclassname );
}
return( control );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -