views:

137

answers:

3

Hi,

after some processing my program shows a messagebox saying you can read a log file to know more about what has been done. I would like to show a link to the file instead the name of it. How is this done?

Thanks a lot

UPDATE:

IDD_RESULT_DIALOG DIALOGEX 0, 0, 228, 58
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "Fax/Modem testing tool"
FONT 8, "Helv", 0, 0, 0x1
BEGIN
    PUSHBUTTON      "Cancelar",IDC_BUTTON1,174,38,50,14
    CONTROL         "<a>SysLink1</a>",IDC_SYSLINK1,"SysLink",WS_TABSTOP,105,22,32,14
END

This is the code on the rc file where the syslink control was created.

BOOL CALLBACK ResultDlg(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg)                  /* manipulador del mensaje */
    {
        case WM_INITDIALOG:
      SetWindowText(GetDlgItem(hDlg,IDC_SYSLINK1), (LPCSTR)"Visit my web site" );
           return TRUE;
        case WM_COMMAND:        
           EndDialog(hDlg, FALSE);
           return TRUE;
    }
    return FALSE;
}

This is where use SetWindowText ...

The dialog doesn't show up. If a Syslink control is embedded in the dialog. I'm not using MFC... can this be the problem?

A: 

You can provide a button that will invoke Win32 function ShellExecute to open a log file.

pingw33n
I suppose in this case I can't use a MessageBox but custom dialog.
deb
No you can. `if (MessageBox(0, "Do you want to open log file?", "Confirmation", MB_OKCANCEL | MB_ICONQUESTION) == IDOK) ShellExecute(0, NULL, "c:\\your_log_here.txt", NULL, NULL, SW_SHOWDEFAULT);`
pingw33n
Finally I made it your way because it was simpler and easier.
deb
+1  A: 

IMHO, you have two options:

A) Make your own dialog from scratch

B) Use a thread hook (SetWindowsHookEx) and catch the initialization of the MessageBox(), resize it a little bit and add your own controls (XP and later have a link control that supports basic html. This control also exists on 2000 but is undocumented and has a different class name)

Anders
So much of Windows programming is like this - step just a little outside the boundaries of what Microsoft provides, and the effort goes up by an order of magnitude.
Mark Ransom
A: 

It seems to me the most direct solution would be to have your own dialog box that looks like a standard message window box and use the link control (referenced by Anders in this thread) in place of the standard static text.

I think this is much saner than the SetWindowHookEx route.

Elemental
Is there any way of making this dialog showing the name of the log file... dinamically, I mean, show the log name ... that is not always the same name (it depends on the time of execution)
deb
should be easy enough just use setwindowtext on the link control to set the text on the control when the dialog starts up (perhaps in response to WM_INITDIALOG)
Elemental
It doesn't work either.
deb
some things I noticed from the MS-docs to use syslink you need to a) Call InitcommonControlsEx before openign the dialogb) Operating system must be Windows XP+
Elemental