• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 49
  • Last Modified:

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(hMsgBoxHook);
 
return retval;
}

please help me its urgently
0
jit_sco
Asked:
jit_sco
1 Solution
 
AndyAinscowCommented:
AfxMessagebox is basically a normal windows message box in disguise, it is just wrapped with some other code specific to MFC.
Changing the colour / customising it - forget it, as I said it is a normal windows message box.

If you want to have specific control such as changing background then use one of the custom ones you have found (or code your own).


ps.  Why did you ask this question in topic areas unrelated to the question - don't bother answering.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now