Exemplo n.º 1
0
int WINAPI MyMessageBoxIndirectW(
								 __in CONST MSGBOXPARAMSW * lpmbp
								 )
{
	CString strCaption;
	CString strText;

	strCaption = lpmbp->lpszCaption;
	strText = lpmbp->lpszText;

	
	g_loger.StatusOut(L"对话框拦截 MessageBoxIndirectW Caption:%s Text:%s Style:%d",strCaption,strText,lpmbp->dwStyle);

	if (
		strCaption.CompareNoCase(L"来自网页的消息") == 0 
		&& strText.CompareNoCase(L"您确实要退出理论培训吗?") == 0
		)
	{
		return IDOK;
	}

	int TReturn = pMessageBoxIndirectW(
		lpmbp
		);
	return TReturn;
};
Exemplo n.º 2
0
int BBMessageBox(int flg, const char *fmt, ...)
{
    const char *caption = BBAPPNAME;
    const char *message;
    char *p, *q;
    int r;
    va_list args;
    static int (WINAPI *pMessageBoxIndirectW)(CONST MSGBOXPARAMSW*);

    va_start(args, fmt);
    message = p = m_formatv(fmt, args);
    if ('#' == p[0] &&  NULL != (q = strchr(p+1, p[0])))
        // "#Title#Message" is wanted
        *q = 0, caption = p+1, message = q+1;

#ifdef BBTINY
    r = MessageBox (NULL, message, caption, flg | MB_SYSTEMMODAL);
#else

    MessageBeep(0);
    if (usingNT
     && load_imp(&pMessageBoxIndirectW, "user32.dll", "MessageBoxIndirectW")) {
        MSGBOXPARAMSW mp;
        int lc = 1+strlen(caption);
        int lm = 1+strlen(message);
        WCHAR *wcaption = (WCHAR*)m_alloc(lc * sizeof (WCHAR));
        WCHAR *wmessage = (WCHAR*)m_alloc(lm * sizeof (WCHAR));
        bbMB2WC(caption, wcaption, lc);
        bbMB2WC(message, wmessage, lm);

        memset(&mp, 0, sizeof mp);
        mp.cbSize = sizeof mp;
        mp.hInstance = hMainInstance;
        //mp.hwndOwner = NULL;
        mp.lpszText = wmessage;
        mp.lpszCaption = wcaption;
        mp.dwStyle = flg | MB_USERICON | MB_SYSTEMMODAL;
        mp.lpszIcon = MAKEINTRESOURCEW(IDI_BLACKBOX);
        r = pMessageBoxIndirectW(&mp);
        m_free(wcaption);
        m_free(wmessage);

    } else {
        MSGBOXPARAMSA mp;
        memset(&mp, 0, sizeof mp);
        mp.cbSize = sizeof mp;
        mp.hInstance = hMainInstance;
        //mp.hwndOwner = NULL;
        mp.lpszText = message;
        mp.lpszCaption = caption;
        mp.dwStyle = flg | MB_USERICON | MB_SYSTEMMODAL;
        mp.lpszIcon = MAKEINTRESOURCE(IDI_BLACKBOX);
        r = MessageBoxIndirectA(&mp);
    }
#endif

    m_free(p);
    return r;
}