[每日一码] 接受LISP参数,实现message box
#include "StdAfx.h"#include "MsgBox.h"
#pragma region //MsgBox
//(crpMsgBox "What the heck are you doing? " "Error" 5 4 )
int MsgBox(void)
{
//
int Button;
int Icon;
UINT ButtonF;
UINT IconF;
//
struct resbuf *pArgs = acedGetArgs();
if (pArgs == NULL)
return acedRetNil();
if (pArgs->restype != RTSTR )
return acedRetNil();
CString Text = pArgs->resval.rstring;
if((pArgs = pArgs->rbnext) == NULL)
return acedRetNil();
if (pArgs->restype != RTSTR)
return acedRetNil();
CString Caption = pArgs->resval.rstring;
if((pArgs = pArgs->rbnext) == NULL)
return acedRetNil();
if (pArgs->restype != RTSHORT)
return acedRetNil();
Button = (int)pArgs->resval.rint;
switch (Button)
{
case 0:
ButtonF = MB采用OK;
break;
case 1:
ButtonF = MB采用OKCANCEL;
break;
case 2:
ButtonF = MB采用ABORTRETRYIGNORE;
break;
case 3:
ButtonF = MB采用YESNOCANCEL;
break;
case 4:
ButtonF = MB采用YESNO;
break;
case 5:
ButtonF = MB采用RETRYCANCEL;
break;
default:
ButtonF = 0;
}
if((pArgs = pArgs->rbnext) == NULL)
return acedRetNil();
if (pArgs->restype != RTSHORT)
return acedRetNil();
Icon = (int)pArgs->resval.rint;
Button = (UINT)pArgs->resval.rint;
switch (Icon)
{
case 1:
IconF = MB采用ICONERROR;
break;
case 2:
IconF = MB采用ICONQUESTION;
break;
case 3:
IconF = MB采用ICONWARNING;
break;
case 4:
IconF = MB采用ICONINFORMATION;
break;
default:
IconF = 0;
}
//
HWND hwDocWnd = adsw采用acadDocWnd();
short res = MessageBox(hwDocWnd , Text , Caption ,ButtonF | IconF);
acedRetInt(res) ;
return (RSRSLT) ;
}
#pragma endregion
页:
[1]