windows-64-bit-type-safety-20051105
[openafs.git] / src / WINNT / afssvrmgr / svc_delete.cpp
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
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
8  */
9
10 extern "C" {
11 #include <afs/param.h>
12 #include <afs/stds.h>
13 }
14
15 #include "svrmgr.h"
16 #include "svc_delete.h"
17
18
19 /*
20  * PROTOTYPES _________________________________________________________________
21  *
22  */
23
24 BOOL CALLBACK Services_Delete_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
25 void Services_Delete_OnInitDialog (HWND hDlg, LPIDENT lpi);
26
27
28 /*
29  * ROUTINES ___________________________________________________________________
30  *
31  */
32
33 void Services_Delete (LPIDENT lpiService)
34 {
35    INT_PTR rc = ModalDialogParam (IDD_SVC_DELETE, GetActiveWindow(), (DLGPROC)Services_Delete_DlgProc, (LPARAM)lpiService);
36    if (rc == IDOK)
37       {
38       StartTask (taskSVC_DELETE, NULL, lpiService);
39       }
40 }
41
42
43
44 BOOL CALLBACK Services_Delete_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
45 {
46    if (AfsAppLib_HandleHelp (IDD_SVC_DELETE, hDlg, msg, wp, lp))
47       return TRUE;
48
49    static LPIDENT lpi = NULL;
50    if (msg == WM_INITDIALOG)
51       lpi = (LPIDENT)lp;
52
53    if (lpi != NULL)
54       {
55       switch (msg)
56          {
57          case WM_INITDIALOG:
58             Services_Delete_OnInitDialog (hDlg, lpi);
59             break;
60
61          case WM_COMMAND:
62             switch (LOWORD(wp))
63                {
64                case IDOK:
65                case IDCANCEL:
66                   EndDialog (hDlg, LOWORD(wp));
67                   break;
68                }
69             break;
70
71          case WM_DESTROY:
72             lpi = NULL;
73             break;
74          }
75       }
76
77    return FALSE;
78 }
79
80
81 void Services_Delete_OnInitDialog (HWND hDlg, LPIDENT lpi)
82 {
83    TCHAR szServer[ cchNAME ];
84    TCHAR szService[ cchNAME ];
85    lpi->GetServerName (szServer);
86    lpi->GetServiceName (szService);
87
88    TCHAR szOld[ cchRESOURCE ];
89    GetDlgItemText (hDlg, IDC_DELSVC_DESC, szOld, cchRESOURCE);
90
91    LPTSTR pszNew = FormatString (szOld, TEXT("%s%s"), szServer, szService);
92    SetDlgItemText (hDlg, IDC_DELSVC_DESC, pszNew);
93    FreeString (pszNew);
94 }
95