开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 676|回复: 9
收起左侧

[火山PC源码] 【2024开源大赛】消息框扩展类(SoftModalMessageBox)

[复制链接]

结帖率:100% (3/3)
发表于 2024-6-9 13:34:33 | 显示全部楼层 |阅读模式   广东省汕头市



参考微软文档

[C++] 纯文本查看 复制代码
int MessageBoxWorker(
    LPMSGBOXDATA pMsgBoxParams)
{
    DWORD  dwStyle = pMsgBoxParams->dwStyle;
    UINT   wBtnCnt;
    UINT   wDefButton;
    UINT   i;
    UINT   wBtnBeg;
    WCHAR  szErrorBuf[64];
    LPWSTR apstrButton[4];
    int    aidButton[4];
    BOOL   fCancel = FALSE;
    int    retValue;
 
#ifdef DEBUG
    if (dwStyle & ~MB_VALID) {
        RIPMSG2(RIP_WARNING, "MessageBoxWorker: Invalid flags, %#lx & ~%#lx != 0",
              dwStyle, MB_VALID);
    }
#endif
 
    /*
     * MB_SERVICE_NOTIFICATION had to be redefined because
     * Win95 defined MB_TOPMOST using the same value.
     * So for old apps, we map it to the new value
     */
 
    if((dwStyle & MB_TOPMOST) && (GetClientInfo()->dwExpWinVer < VER40)) {
        dwStyle &= ~MB_TOPMOST;
        dwStyle |= MB_SERVICE_NOTIFICATION;
        pMsgBoxParams->dwStyle = dwStyle;
 
        RIPMSG1(RIP_WARNING, "MessageBoxWorker: MB_SERVICE_NOTIFICATION flag mapped. New dwStyle:%#lx", dwStyle);
    }
 
    /*
     * For backward compatiblity, use MB_SERVICE_NOTIFICATION if
     * it's going to the default desktop.
     */
    if (dwStyle & (MB_DEFAULT_DESKTOP_ONLY | MB_SERVICE_NOTIFICATION)) {
 
        /*
         * Allow services to put up popups without getting
         * access to the current desktop.
         */
        if (pMsgBoxParams->hwndOwner != NULL) {
            RIPERR0(ERROR_INVALID_PARAMETER, RIP_VERBOSE, "");
            return 0;
        }
 
        return ServiceMessageBox(pMsgBoxParams->lpszText,
                                 pMsgBoxParams->lpszCaption,
                                 dwStyle & ~MB_SERVICE_NOTIFICATION,
                                 FALSE);
    }
 
    /*
     * Make sure we have a valid window handle.
     */
    if (pMsgBoxParams->hwndOwner && !IsWindow(pMsgBoxParams->hwndOwner)) {
        RIPERR0(ERROR_INVALID_WINDOW_HANDLE, RIP_VERBOSE, "");
        return 0;
    }
 
    /*
     * If lpszCaption is NULL, then use "Error!" string as the caption
     * string.
     * LATER: IanJa localize according to wLanguageId
     */
    if (pMsgBoxParams->lpszCaption == NULL) {
        if (pMsgBoxParams->wLanguageId == 0) {
            pMsgBoxParams->lpszCaption = szERROR;
        } else {
            RtlLoadStringOrError(hmodUser,
                                 STR_ERROR,
                                 szErrorBuf,
                                 sizeof(szErrorBuf)/sizeof(WCHAR),
                                 RT_STRING,
                                 prescalls,
                                 pMsgBoxParams->wLanguageId);
 
            /*
             *  If it didn't find the string, use the default language
             */
            if (*szErrorBuf) {
               pMsgBoxParams->lpszCaption = szErrorBuf;
            } else {
               pMsgBoxParams->lpszCaption = szERROR;
 
               RIPMSG1(RIP_WARNING, "MessageBoxWorker: STR_ERROR string resource for language %#lx not found",
                      pMsgBoxParams->wLanguageId);
            }
        }
    }
 
    /*
     * Validate the "type" of message box requested.
     */
    if ((dwStyle & MB_TYPEMASK) > MB_LASTVALIDTYPE) {
        RIPERR0(ERROR_INVALID_MSGBOX_STYLE, RIP_VERBOSE, "");
        return 0;
    }
 
    wBtnCnt = mpTypeCcmd[dwStyle & MB_TYPEMASK] +
                            ((dwStyle & MB_HELP) ? 1 : 0);
 
    /*
     * Set the default button value
     */
    wDefButton = (dwStyle & (UINT)MB_DEFMASK) / (UINT)(MB_DEFMASK & (MB_DEFMASK >> 3));
 
    if (wDefButton >= wBtnCnt)   /* Check if valid */
        wDefButton = 0;          /* Set the first button if error */
 
    /*
     * Calculate the strings to use in the message box
     */
    wBtnBeg = mpTypeIich[dwStyle & (UINT)MB_TYPEMASK];
    for (i=0; i<wBtnCnt; i++) {
 
        /*
         * Pick up the string for the button.
         */
        if (pMsgBoxParams->wLanguageId == 0) {
            apstrButton<i> = GETGPSIMBPSTR(SEBbuttons[wBtnBeg + i] - SEB_OK);
        } else {
            WCHAR szButtonBuf[64];
            // LATER is it possible to have button text greater than 64 chars
 
           /*
            *  BUG: gpsi->wMaxBtnSize might be too short for the length of this string...
            */
            RtlLoadStringOrError(hmodUser,
                    gpsi->mpAllMBbtnStringsToSTR[SEBbuttons[wBtnBeg + i] - SEB_OK],
                    szButtonBuf,
                    sizeof(szButtonBuf)/sizeof(WCHAR),
                    RT_STRING,
                    prescalls,
                    pMsgBoxParams->wLanguageId);
 
            /*
             *  If it didn't find the string, use the default language.
             */
            if (*szButtonBuf) {
               apstrButton<i> = TextAlloc(szButtonBuf);
            } else {
               apstrButton<i> = TextAlloc(GETGPSIMBPSTR(SEBbuttons[wBtnBeg + i] - SEB_OK));
 
               RIPMSG2(RIP_WARNING, "MessageBoxWorker: string resource %#lx for language %#lx not found",
                      gpsi->mpAllMBbtnStringsToSTR[SEBbuttons[wBtnBeg + i] - SEB_OK],
                      pMsgBoxParams->wLanguageId);
            }
        }
        aidButton<i> = rgReturn[wBtnBeg + i];
        if (aidButton<i> == IDCANCEL) {
            fCancel = TRUE;
        }
    }
 
    /*
     * Hackery: There are some apps that use MessageBox as initial error
     * indicators, such as mplay32, and we want this messagebox to be
     * visible regardless of waht was specified in the StartupInfo->wShowWindow
     * field.  ccMail for instance starts all of its embedded objects hidden
     * but on win 3.1 the error message would show because they don't have
     * the startup info.
     */
    NtUserSetUserStartupInfoFlags(NtUserGetUserStartupInfoFlags() & ~STARTF_USESHOWWINDOW);
 
    pMsgBoxParams->pidButton      = aidButton;
    pMsgBoxParams->ppszButtonText = apstrButton;
    pMsgBoxParams->DefButton      = wDefButton;
    pMsgBoxParams->cButtons       = wBtnCnt;
    pMsgBoxParams->CancelId      = ((dwStyle & MB_TYPEMASK) == 0) ? IDOK : (fCancel ? IDCANCEL : 0);
    retValue = SoftModalMessageBox(pMsgBoxParams);
 
    if (pMsgBoxParams->wLanguageId != 0) {
        for (i=0; i<wBtnCnt; i++)
           UserLocalFree(apstrButton<i>);
    }
 
    return retValue;
}


隔壁易语言源码底层核心自由的信息框-SoftModalMessageBox_精易论坛 (125.la)


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

点评

火山那么冷门吗???   广东省汕头市  发表于 2024-6-9 17:21

评分

参与人数 1好评 +1 精币 +2 收起 理由
zz1318 + 1 + 2 支持开源~!感谢分享

查看全部评分

结帖率:89% (54/61)

签到天数: 8 天

发表于 2024-7-5 15:56:49 | 显示全部楼层   福建省龙岩市
厉害了
回复 支持 反对

使用道具 举报

签到天数: 19 天

发表于 2024-6-25 21:55:20 | 显示全部楼层   江苏省苏州市
感谢分享
回复 支持 反对

使用道具 举报

结帖率:100% (27/27)

签到天数: 8 天

发表于 2024-6-21 12:43:11 | 显示全部楼层   浙江省宁波市
支持开源~!感谢分享
回复 支持 反对

使用道具 举报

签到天数: 8 天

发表于 2024-6-19 19:21:29 | 显示全部楼层   辽宁省营口市
66666666666666666
回复 支持 反对

使用道具 举报

签到天数: 2 天

发表于 2024-6-11 16:57:43 | 显示全部楼层   云南省昆明市
666支持开源~!感谢分享
回复 支持 反对

使用道具 举报

结帖率:100% (35/35)

签到天数: 6 天

发表于 2024-6-9 17:38:30 | 显示全部楼层   湖北省恩施土家族苗族自治州
好像快T6啦回个帖
回复 支持 反对

使用道具 举报

签到天数: 26 天

发表于 2024-6-9 17:13:54 | 显示全部楼层   河北省石家庄市
感谢分享
回复 支持 反对

使用道具 举报

结帖率:100% (10/10)

签到天数: 21 天

发表于 2024-6-9 14:33:28 | 显示全部楼层   广西壮族自治区百色市
2024开源大赛
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报电话0663-3422125,QQ: 793400750,邮箱:wp@125.la
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备12094385号-1) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

快速回复 返回顶部 返回列表