2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 #include <afs/param.h>
15 #include <WINNT/talocale.h>
19 * DEFINITIONS ________________________________________________________________
25 * PROTOTYPES _________________________________________________________________
29 int cdecl vMessage (UINT, LONG, LONG, LPCTSTR, va_list);
30 DWORD WINAPI Message_ThreadProc (PVOID lp);
34 * ROUTINES ___________________________________________________________________
38 HWND ModelessDialog (int idd, HWND hWndParent, DLGPROC lpDialogFunc)
40 return ModelessDialogParam (idd, hWndParent, lpDialogFunc, 0);
44 HWND ModelessDialogParam (int idd, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam)
47 LPCDLGTEMPLATE pTemplate;
48 if ((pTemplate = TaLocale_GetDialogResource (idd, &hInstFound)) == NULL)
51 return CreateDialogIndirectParam (hInstFound, pTemplate, hWndParent, lpDialogFunc, dwInitParam);
55 INT_PTR ModalDialog (int idd, HWND hWndParent, DLGPROC lpDialogFunc)
57 return ModalDialogParam (idd, hWndParent, lpDialogFunc, 0);
61 INT_PTR ModalDialogParam (int idd, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam)
64 LPCDLGTEMPLATE pTemplate;
65 if ((pTemplate = TaLocale_GetDialogResource (idd, &hInstFound)) == NULL)
68 return DialogBoxIndirectParam (hInstFound, pTemplate, hWndParent, lpDialogFunc, dwInitParam);
72 /*** Message() - generic-text dialog box
76 int cdecl Message (UINT type, LPCTSTR title, LPCTSTR text, LPCTSTR fmt, ...)
81 return vMessage (type, PtrToLong(title), PtrToLong(text), fmt, arg);
85 int cdecl Message (UINT type, LPCTSTR title, int text, LPCTSTR fmt, ...)
90 return vMessage (type, PtrToLong(title), (LONG)text, fmt, arg);
94 int cdecl Message (UINT type, int title, LPCTSTR text, LPCTSTR fmt, ...)
99 return vMessage (type, (LONG)title, PtrToLong(text), fmt, arg);
103 int cdecl Message (UINT type, int title, int text, LPCTSTR fmt, ...)
108 return vMessage (type, (LONG)title, (LONG)text, fmt, arg);
112 int cdecl vMessage (UINT type, LPCTSTR title, LPCTSTR text, LPCTSTR fmt, va_list arg)
114 return vMessage (type, PtrToLong(title), PtrToLong(text), fmt, arg);
118 int cdecl vMessage (UINT type, LPCTSTR title, int text, LPCTSTR fmt, va_list arg)
120 return vMessage (type, PtrToLong(title), (LONG)text, fmt, arg);
124 int cdecl vMessage (UINT type, int title, LPCTSTR text, LPCTSTR fmt, va_list arg)
126 return vMessage (type, (LONG)title, PtrToLong(text), fmt, arg);
130 int cdecl vMessage (UINT type, int title, int text, LPCTSTR fmt, va_list arg)
132 return vMessage (type, (LONG)title, (LONG)text, fmt, arg);
141 } MESSAGE_PARAMS, *LPMESSAGE_PARAMS;
143 int cdecl vMessage (UINT type, LONG title, LONG text, LPCTSTR fmt, va_list arg)
145 LPMESSAGE_PARAMS pmp = New(MESSAGE_PARAMS);
149 if ((pmp->pszTitle = FormatString (title, fmt, arg)) == NULL)
155 if ((pmp->pszText = vFormatString (text, fmt, arg)) == NULL)
157 FreeString (pmp->pszTitle);
162 if (!( pmp->dwType & 0xF0 )) // no icon requested? pick one.
164 pmp->dwType |= ((pmp->dwType & 0x0F) ? MB_ICONQUESTION : MB_ICONASTERISK);
167 if (pmp->dwType & MB_MODELESS)
169 pmp->dwType &= ~MB_MODELESS;
172 if ((hThread = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)Message_ThreadProc, pmp, 0, NULL)) != NULL)
173 SetThreadPriority (hThread, THREAD_PRIORITY_BELOW_NORMAL);
175 return -1; // threaded--who knows what button was hit.
178 return Message_ThreadProc (pmp);
182 DWORD WINAPI Message_ThreadProc (PVOID lp)
184 LPMESSAGE_PARAMS pmp = (LPMESSAGE_PARAMS)lp;
186 DWORD rc = MessageBox (NULL, pmp->pszText, pmp->pszTitle, pmp->dwType);
188 FreeString (pmp->pszText);
189 FreeString (pmp->pszTitle);