jit_sco
asked on
Problem with CustomMessageBOX MFC
My task is to convert the background color of AfxMessageBox in MFC ,I have found lots of codiing in internet,all mentioned how to call customessageBox with button but i want to call
it anywhere in my proyect with a condition of if() else() as like normally we call AfxMessagebox,
Here by i posting my coding and funtion please tell me where how to call the following funtion in my proyect:
MsgBoxEx(hWnd, "Message test" , "title", MB_YESNOCANCEL | MB_ICONINFORMATION);
-----
Coding:
HHOOK hMsgBoxHook;
LRESULT CALLBACK MsgBoxProc(int nCode, WPARAM wParam, LPARAM lParam)
{
TCHAR ach[140];
HWND hwnd;
HWND YES;
HWND NO;
HWND CANCEL;
if(nCode < 0)
return CallNextHookEx(hMsgBoxHook , nCode, wParam, lParam);
switch(nCode)
{
case HCBT_ACTIVATE:
// Get handle to the message box!
hwnd = (HWND)wParam;
//Set the window title
SetWindowText(hwnd, _T("Activator"));
//Get IDYES button handle
YES = GetDlgItem(hwnd, IDYES);
SetWindowText(YES, _T("Full License"));
//Get IDNO button handle
NO = GetDlgItem(hwnd, IDNO);
//Set Button position, width and height
MoveWindow(NO, 185, 60, 100, 23, TRUE);
SetWindowText(NO, _T("Cancel"));
//Get IDCANCEL button handle
CANCEL = GetDlgItem(hwnd, IDCANCEL);
//Set Button position, width and height
MoveWindow(CANCEL, 290, 60, 100, 23, TRUE);
SetWindowText(CANCEL, _T("Cancel"));
return 0;
}
return CallNextHookEx(hMsgBoxHook , nCode, wParam, lParam);
}
int MsgBoxEx(HWND hwnd, TCHAR *szText, TCHAR *szCaption, UINT uType)
{
int retval;
// Install a window hook, so we can intercept the message-box
// creation, and customize it
hMsgBoxHook = SetWindowsHookEx(
WH_CBT,
MsgBoxProc,
NULL,
GetCurrentThreadId()
);
// Display a standard message box
retval = MessageBox(hwnd, szText, szCaption, uType);
// remove the window hook
UnhookWindowsHookEx(hMsgBo xHook);
return retval;
}
please help me its urgently
it anywhere in my proyect with a condition of if() else() as like normally we call AfxMessagebox,
Here by i posting my coding and funtion please tell me where how to call the following funtion in my proyect:
MsgBoxEx(hWnd, "Message test" , "title", MB_YESNOCANCEL | MB_ICONINFORMATION);
-----
Coding:
HHOOK hMsgBoxHook;
LRESULT CALLBACK MsgBoxProc(int nCode, WPARAM wParam, LPARAM lParam)
{
TCHAR ach[140];
HWND hwnd;
HWND YES;
HWND NO;
HWND CANCEL;
if(nCode < 0)
return CallNextHookEx(hMsgBoxHook
switch(nCode)
{
case HCBT_ACTIVATE:
// Get handle to the message box!
hwnd = (HWND)wParam;
//Set the window title
SetWindowText(hwnd, _T("Activator"));
//Get IDYES button handle
YES = GetDlgItem(hwnd, IDYES);
SetWindowText(YES, _T("Full License"));
//Get IDNO button handle
NO = GetDlgItem(hwnd, IDNO);
//Set Button position, width and height
MoveWindow(NO, 185, 60, 100, 23, TRUE);
SetWindowText(NO, _T("Cancel"));
//Get IDCANCEL button handle
CANCEL = GetDlgItem(hwnd, IDCANCEL);
//Set Button position, width and height
MoveWindow(CANCEL, 290, 60, 100, 23, TRUE);
SetWindowText(CANCEL, _T("Cancel"));
return 0;
}
return CallNextHookEx(hMsgBoxHook
}
int MsgBoxEx(HWND hwnd, TCHAR *szText, TCHAR *szCaption, UINT uType)
{
int retval;
// Install a window hook, so we can intercept the message-box
// creation, and customize it
hMsgBoxHook = SetWindowsHookEx(
WH_CBT,
MsgBoxProc,
NULL,
GetCurrentThreadId()
);
// Display a standard message box
retval = MessageBox(hwnd, szText, szCaption, uType);
// remove the window hook
UnhookWindowsHookEx(hMsgBo
return retval;
}
please help me its urgently
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.