?? dialog.c
字號:
0, 0, 0, 0, 1, BUTTON, NULL, NULL},
{BS_PUSHBUTTON | WS_TABSTOP,
0, 0, 0, 0, 1, BUTTON, NULL, NULL}
};
Width = 80;
Height = 140;
MsgBoxData.lStyle = lStyle;
MsgBoxData.lpMsg = lpszText;
if(lpszCaption)
MsgBoxData.lpCaption = lpszCaption;
else
MsgBoxData.lpCaption = pGUIInfo->spCaption;
MsgBoxData.pCtrlData = &CtrlData[0];
switch(MsgBoxData.lStyle&0x000f)
{
case MB_OK:
MsgBoxData.NumOfCtrl = 1;
CtrlRet[0] = IDOK;
CtrlData[0].spItemText = "確定";
break;
case MB_OKCANCEL:
Width += 100;
MsgBoxData.NumOfCtrl = 2;
CtrlRet[0] = IDOK;
CtrlRet[1] = IDCANCEL;
CtrlData[0].spItemText = "確定";
CtrlData[1].spItemText = "取消";
iRetCtrl = 1;
break;
case MB_YESNO:
Width += 100;
MsgBoxData.NumOfCtrl = 2;
CtrlRet[0] = IDYES;
CtrlRet[1] = IDNO;
CtrlData[0].spItemText = "是(Y)";
CtrlData[1].spItemText = "否(N)";
iRetCtrl = 1;
break;
case MB_RETRYCANCEL:
Width += 100;
MsgBoxData.NumOfCtrl = 2;
CtrlRet[0] = IDRETRY;
CtrlRet[1] = IDCANCEL;
CtrlData[0].spItemText = "重試(R)";
CtrlData[1].spItemText = "取消";
break;
case MB_ABORTRETRYIGNORE:
Width += 200;
MsgBoxData.NumOfCtrl = 3;
CtrlRet[0] = IDABORT;
CtrlRet[1] = IDRETRY;
CtrlRet[2] = IDIGNORE;
CtrlData[0].spItemText = "中止(A)";
CtrlData[1].spItemText = "重試(R)";
CtrlData[2].spItemText = "忽略(I)";
break;
case MB_YESNOCANCEL:
Width += 200;
MsgBoxData.NumOfCtrl = 3;
CtrlRet[0] = IDYES;
CtrlRet[1] = IDNO;
CtrlRet[2] = IDCANCEL;
CtrlData[0].spItemText = "是(Y)";
CtrlData[1].spItemText = "否(N)";
CtrlData[2].spItemText = "取消";
break;
}
i = 0;
iNumOfRow = 1;
iMaxCol = 0;
iCol = 0;
while(*(MsgBoxData.lpMsg + i) != '\0')
{
if(*(MsgBoxData.lpMsg + i) == '\n')
{
iNumOfRow ++;
if(iCol > iMaxCol)
{
iMaxCol = iCol;
iCol = 1;
}
}
if(*(MsgBoxData.lpMsg + i) == '\t')
iCol += 4;
iCol++;
i++;
}
if(iCol > iMaxCol)
iMaxCol = iCol;
if((iMaxCol*8) > (Width - 20))
Width = iMaxCol*8 + 20;
if((size_t)Width < (_fstrlen(lpszCaption)*8 + 50))
Width = _fstrlen(lpszCaption)*8 + 50;
Height += iNumOfRow*16;
if((MsgBoxData.lStyle)&0x00f0)
Width += 100;
else
Width += 70;
MsgBoxData.lx = (vc.numxpixels - Width)/2;
MsgBoxData.ty = (vc.numypixels - Height)/2;
MsgBoxData.rx = MsgBoxData.lx + Width;
MsgBoxData.by = MsgBoxData.ty + Height;
SetPtrVis(HIDE);
SetFocus(NULL);
if(pGUIInfo)
{
do
{
if(GetMessageFromQueue(pGUIInfo, &Msg))
{
TranslateAccelerator(pGUIInfo, &Msg);
DisptchMessage(pGUIInfo, &Msg);
}
else
break;
}while(TRUE);
Msg.uMsg = MSG_KILLFOCUS;
Msg.wParam = 0;
Msg.lParam = 0L;
DisptchMessage(pGUIInfo, &Msg);
}
else
hdlImage = SaveImageUseVirtualMem(MsgBoxData.lx, MsgBoxData.ty,
Width, Height);
CreateMsgBox(&MsgBoxData);
if((MsgBoxData.lStyle)&0x00f0)
DisplayIcon(LoadMsgIcon(MsgBoxData.lStyle), MsgBoxData.lx + 20, MsgBoxData.ty + 70);
SetPtrVis(SHOW);
for(i=0; i<MsgBoxData.NumOfCtrl; i++)
{
CtrlData[i].lx = MsgBoxData.xfirst + i*100;
CtrlData[i].ty = MsgBoxData.by - 42;
CtrlData[i].by = MsgBoxData.by - 17;
CtrlData[i].rx = MsgBoxData.xfirst + i*100 + 80;
}
SetFocus(&CtrlData[iRetCtrl]);
fAlreadyUp = TRUE;
GetKey(CLEAR);
while(!fEND)
{
MSG Msg;
GetMessage(&Msg);
TranslateBoxMsg(FALSE, NULL, &Msg);
switch(Msg.uMsg)
{
case NEXTGROUP:
case NEXTTAB:
iRetCtrl++;
if(iRetCtrl == MsgBoxData.NumOfCtrl)
iRetCtrl = 0;
SetFocus(&CtrlData[iRetCtrl]);
break;
case LASTGROUP:
case LASTTAB:
iRetCtrl--;
if(iRetCtrl == -1)
iRetCtrl = MsgBoxData.NumOfCtrl - 1;
SetFocus(&CtrlData[iRetCtrl]);
break;
case ABORT:
switch(MsgBoxData.lStyle & 0x000f)
{
case MB_ABORTRETRYIGNORE:
RetValue = IDABORT;
fEND = TRUE;
break;
}
break;
case RETRY:
switch(MsgBoxData.lStyle & 0x000f)
{
case MB_RETRYCANCEL:
case MB_ABORTRETRYIGNORE:
RetValue = IDRETRY;
fEND = TRUE;
break;
}
break;
case IGNORE:
switch(MsgBoxData.lStyle & 0x000f)
{
case MB_ABORTRETRYIGNORE:
RetValue = IDIGNORE;
fEND = TRUE;
break;
}
break;
case CANCEL:
switch(MsgBoxData.lStyle & 0x000f)
{
case MB_OKCANCEL:
case MB_RETRYCANCEL:
case MB_YESNOCANCEL:
RetValue = IDCANCEL;
fEND = TRUE;
break;
}
break;
case YES:
switch(MsgBoxData.lStyle & 0x000f)
{
case MB_YESNO:
case MB_YESNOCANCEL:
RetValue = IDYES;
fEND = TRUE;
break;
}
break;
case NO:
switch(MsgBoxData.lStyle & 0x000f)
{
case MB_YESNO:
case MB_YESNOCANCEL:
RetValue = IDNO;
fEND = TRUE;
break;
}
break;
case CHECK:
PushButton(&CtrlData[iRetCtrl], TRUE);
Sleep(100);
PushButton(&CtrlData[iRetCtrl], FALSE);
case OK:
RetValue = CtrlRet[iRetCtrl];
fEND = TRUE;
break;
case MOUSEFOCUS:
SetFocus(((PCTRLDATA)Msg.pStr));
PushButton(((PCTRLDATA)Msg.pStr), TRUE);
break;
case MOUSECHECK:
PushButton(((PCTRLDATA)Msg.pStr), FALSE);
if(Msg.wParam)
{
RetValue = CtrlRet[Msg.wParam - 1];
fEND = TRUE;
break;
}
else
break;
case BEEP:
Beep(700, 50);
break;
default:
break;
}
}
SetFocus(NULL);
SetPtrVis(HIDE);
if(pGUIInfo)
{
RECT rect;
rect.left = MsgBoxData.lx;
rect.top = MsgBoxData.ty;
rect.right = MsgBoxData.rx;
rect.bottom = MsgBoxData.by;
SendMessage(pGUIInfo, MSG_ERASEBKGND, (WPARAM)(&rect), 0L);
PostMessage(pGUIInfo, MSG_SETFOCUS, 0, 0L);
}
else if(hdlImage != _VM_NULL)
RestoreImageUseVirtualMem(hdlImage, MsgBoxData.lx, MsgBoxData.ty);
SetPtrVis(SHOW);
return RetValue;
}
/*
* Function: static BOOL CreateMsgBox( PMSGBOXDATA pMsgBoxData ).
* This function Create a message box.
* Parameters:
* pMsgBoxData: the pointer to MSGBOXDATA struct;
* Return:
* success-----TRUE;
* failure-----FALSE.
*/
static BOOL CreateMsgBox( PMSGBOXDATA pMsgBoxData )
{
short buttonx;
short buttony;
BOOL Have3 = FALSE;
DrawBox(pMsgBoxData->lx, pMsgBoxData->ty, pMsgBoxData->rx, pMsgBoxData->by);
buttonx = (pMsgBoxData->lx + pMsgBoxData->rx)/2 - 35;
buttony = pMsgBoxData->by - 42;
switch((pMsgBoxData->lStyle)&0x000f)
{
case MB_YESNOCANCEL:
case MB_ABORTRETRYIGNORE:
DrawCtrl(BUTTON, BS_PUSHBUTTON, buttonx, buttony, buttonx + 80, buttony + 25);
buttonx += 100;
Have3 = TRUE;
case MB_RETRYCANCEL:
case MB_YESNO:
case MB_OKCANCEL:
if(!Have3)
buttonx = (pMsgBoxData->lx + pMsgBoxData->rx)/2 + 10;
DrawCtrl(BUTTON, BS_PUSHBUTTON, buttonx, buttony, buttonx + 80, buttony + 25);
if(Have3)
buttonx -=200;
else
buttonx -=100;
case MB_OK:
DrawCtrl(BUTTON, BS_PUSHBUTTON, buttonx, buttony, buttonx + 80, buttony + 25);
}
pMsgBoxData->xfirst = buttonx;
buttonx += 40;
buttony += 5;
set_color(0);
switch((pMsgBoxData->lStyle)&0x000f)
{
case MB_YESNOCANCEL:
cc_wt16(pMsgBoxData->pCtrlData->spItemText, buttonx - 20, buttony);
buttonx += 100;
cc_wt16((pMsgBoxData->pCtrlData + 1)->spItemText, buttonx - 20, buttony);
buttonx +=100;
cc_wt16((pMsgBoxData->pCtrlData + 2)->spItemText, buttonx - 16, buttony);
break;
case MB_ABORTRETRYIGNORE:
cc_wt16((pMsgBoxData->pCtrlData)->spItemText, buttonx - 28, buttony);
buttonx += 100;
cc_wt16((pMsgBoxData->pCtrlData + 1)->spItemText, buttonx - 28, buttony);
buttonx += 100;
cc_wt16((pMsgBoxData->pCtrlData + 2)->spItemText, buttonx - 28, buttony);
break;
case MB_RETRYCANCEL:
cc_wt16((pMsgBoxData->pCtrlData)->spItemText, buttonx - 28, buttony);
buttonx += 100;
cc_wt16((pMsgBoxData->pCtrlData + 1)-
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -