fix msvc warnings
[reactos.git] / reactos / subsys / system / servman / servman.c
index 4339af8..1e774bc 100644 (file)
@@ -15,27 +15,93 @@ HINSTANCE hInstance;
 HWND hMainWnd;\r
 HWND hListView;\r
 HWND hStatus;\r
+HWND hTool;\r
 \r
 \r
 LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)\r
 {\r
-       switch(msg)\r
-       {\r
-               case WM_CREATE:\r
-               {\r
-                       //HFONT hfDefault;\r
+    switch(msg)\r
+    {\r
+        case WM_CREATE:\r
+        {\r
+             //HFONT hfDefault;\r
 \r
-                       HWND hTool;\r
-                       TBBUTTON tbb[7];\r
-                       TBADDBITMAP tbab;\r
+            TBADDBITMAP tbab;\r
+            INT iImageOffset;\r
+            INT statwidths[] = {110, -1}; /* widths of status bar */\r
+            TCHAR szTemp[256];\r
+            LVCOLUMN lvc = { 0 };\r
 \r
-                       int statwidths[] = {110, -1};\r
+            /* Toolbar buttons */\r
+            TBBUTTON tbb [NUM_BUTTONS] = \r
+            {   /* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */\r
+                {TBICON_PROP,    ID_PROP,    TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},    /* properties */\r
+                {TBICON_REFRESH, ID_REFRESH, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},    /* refresh */\r
+                {TBICON_EXPORT,  ID_EXPORT,  TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},    /* export */\r
 \r
-                       TCHAR szTemp[256];\r
+                /* Note: First item for a seperator is its width in pixels */\r
+                {25, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},                             /* separator */\r
 \r
-                       /* Create List View */\r
-            LVCOLUMN lvc = { 0 };\r
-            //LVITEM   lv  = { 0 };\r
+                {TBICON_START,   ID_START,   TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 },   /* start */ \r
+                {TBICON_STOP,    ID_STOP,    TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 },   /* stop */\r
+                {TBICON_PAUSE,   ID_PAUSE,   TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 },   /* pause */   \r
+                {TBICON_RESTART, ID_RESTART, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 },   /* restart */\r
+\r
+                {25, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},                             /* separator */\r
+\r
+                {TBICON_NEW,     ID_NEW,   TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 },   /* start */\r
+                {TBICON_HELP,    ID_HELP,    TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 },   /* stop */\r
+                {TBICON_EXIT,    ID_EXIT,   TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 },   /* pause */\r
+\r
+            };\r
+\r
+/* ======================== Create Toolbar ============================== */\r
+\r
+            /* Create Toolbar */\r
+            hTool = CreateWindowEx(0,\r
+                                   TOOLBARCLASSNAME,\r
+                                   NULL,\r
+                                   WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS,\r
+                                   0, 0, 0, 0,\r
+                                   hwnd,\r
+                                   (HMENU)IDC_TOOLBAR,\r
+                                   hInstance,\r
+                                   NULL);\r
+            if(hTool == NULL)\r
+                MessageBox(hwnd, _T("Could not create tool bar."), _T("Error"), MB_OK | MB_ICONERROR);\r
+\r
+            /* Send the TB_BUTTONSTRUCTSIZE message, which is required for backward compatibility */\r
+            SendMessage(hTool, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);\r
+\r
+            /* Add standard image list */\r
+            tbab.hInst = HINST_COMMCTRL;\r
+            tbab.nID = IDB_STD_SMALL_COLOR;\r
+            SendMessage(hTool, TB_ADDBITMAP, 0, (LPARAM) &tbab);\r
+\r
+            /* Add custom images */\r
+            tbab.hInst = hInstance;\r
+            tbab.nID = IDB_BUTTONS;\r
+            iImageOffset = (INT)SendMessage(hTool, TB_ADDBITMAP, 11, (LPARAM)&tbab);\r
+            tbb[0].iBitmap += iImageOffset; /* properties */\r
+            tbb[1].iBitmap += iImageOffset; /* refresh */\r
+            tbb[2].iBitmap += iImageOffset; /* export */\r
+            tbb[4].iBitmap += iImageOffset; /* start */\r
+            tbb[5].iBitmap += iImageOffset; /* stop */\r
+            tbb[6].iBitmap += iImageOffset; /* pause */\r
+            tbb[7].iBitmap += iImageOffset; /* restart */\r
+            tbb[9].iBitmap += iImageOffset; /* new */\r
+            tbb[10].iBitmap += iImageOffset; /* help */\r
+            tbb[11].iBitmap += iImageOffset; /* exit */\r
+\r
+            /* Add buttons to toolbar */\r
+            SendMessage(hTool, TB_ADDBUTTONS, NUM_BUTTONS, (LPARAM) &tbb);\r
+\r
+            /* Show toolbar */\r
+            ShowWindow(hTool, SW_SHOWNORMAL);\r
+\r
+\r
+\r
+/* ======================== Create List View ============================== */\r
 \r
             hListView = CreateWindow(WC_LISTVIEW,\r
                                      NULL,\r
@@ -46,99 +112,57 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                                      (HMENU) IDC_SERVLIST,\r
                                      hInstance,\r
                                      NULL);\r
+            if (hListView == NULL)\r
+                MessageBox(hwnd, _T("Could not create List View."), _T("Error"), MB_OK | MB_ICONERROR);\r
 \r
             ListView_SetExtendedListViewStyle(hListView, LVS_EX_FULLROWSELECT |\r
-                    /*LVS_EX_GRIDLINES |*/ LVS_EX_HEADERDRAGDROP);\r
+                    LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP);\r
 \r
             lvc.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH  | LVCF_FMT;\r
             lvc.fmt  = LVCFMT_LEFT;\r
 \r
-            /* Add columns to the list-view (first column contains check box). */\r
+            /* Add columns to the list-view */\r
+\r
+            /* name */\r
             lvc.iSubItem = 0;\r
             lvc.cx       = 160;\r
             LoadString(hInstance, IDS_FIRSTCOLUMN, szTemp, 256);\r
             lvc.pszText  = szTemp;\r
             ListView_InsertColumn(hListView, 0, &lvc);\r
 \r
+            /* description */\r
             lvc.iSubItem = 1;\r
             lvc.cx       = 260;\r
             LoadString(hInstance, IDS_SECONDCOLUMN, szTemp, 256);\r
             lvc.pszText  = szTemp;\r
             ListView_InsertColumn(hListView, 1, &lvc);\r
 \r
+            /* status */\r
             lvc.iSubItem = 2;\r
             lvc.cx       = 75;\r
             LoadString(hInstance, IDS_THIRDCOLUMN, szTemp, 256);\r
             lvc.pszText  = szTemp;\r
             ListView_InsertColumn(hListView, 2, &lvc);\r
 \r
+            /* startup type */\r
             lvc.iSubItem = 3;\r
             lvc.cx       = 80;\r
             LoadString(hInstance, IDS_FOURTHCOLUMN, szTemp, 256);\r
             lvc.pszText  = szTemp;\r
             ListView_InsertColumn(hListView, 3, &lvc);\r
 \r
+            /* logon as */\r
             lvc.iSubItem = 4;\r
             lvc.cx       = 100;\r
             LoadString(hInstance, IDS_FITHCOLUMN, szTemp, 256);\r
             lvc.pszText  = szTemp;\r
             ListView_InsertColumn(hListView, 4, &lvc);\r
 \r
-                       /* Create Toolbar */\r
-                       hTool = CreateWindowEx(0,\r
-                                   TOOLBARCLASSNAME,\r
-                                   NULL,\r
-                                   WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS,\r
-                                   0, 0, 0, 0,\r
-                                   hwnd,\r
-                                   (HMENU)IDC_TOOLBAR,\r
-                                   hInstance,\r
-                                   NULL);\r
-                       if(hTool == NULL)\r
-                               MessageBox(hwnd, _T("Could not create tool bar."), _T("Error"), MB_OK | MB_ICONERROR);\r
-\r
-                       // Send the TB_BUTTONSTRUCTSIZE message, which is required for\r
-                       // backward compatibility.\r
-                       SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);\r
-\r
-                       tbab.hInst = HINST_COMMCTRL;\r
-                       tbab.nID = IDB_STD_SMALL_COLOR;\r
-                       SendMessage(hTool, TB_ADDBITMAP, 0, (LPARAM)&tbab);\r
-\r
-            ZeroMemory(tbb, sizeof(tbb));\r
-            tbb[0].iBitmap = STD_PROPERTIES;\r
-            tbb[0].fsState = TBSTATE_ENABLED;\r
-            tbb[0].fsStyle = TBSTYLE_BUTTON;\r
-            tbb[0].idCommand = ID_PROP;\r
-            tbb[1].iBitmap = STD_FILENEW;\r
-            tbb[1].fsState = TBSTATE_ENABLED;\r
-            tbb[1].fsStyle = TBSTYLE_BUTTON;\r
-            tbb[1].idCommand = ID_REFRESH;\r
-            tbb[2].iBitmap = STD_FILENEW;\r
-            tbb[2].fsState = TBSTATE_ENABLED;\r
-            tbb[2].fsStyle = TBSTYLE_BUTTON;\r
-            tbb[2].idCommand = ID_EXPORT;\r
-            /* seperator */\r
-            tbb[3].iBitmap = STD_FILENEW;\r
-            tbb[3].fsState = TBSTATE_ENABLED;\r
-            tbb[3].fsStyle = TBSTYLE_BUTTON;\r
-            tbb[3].idCommand = ID_START;\r
-            tbb[4].iBitmap = STD_FILENEW;\r
-            tbb[4].fsState = TBSTATE_ENABLED;\r
-            tbb[4].fsStyle = TBSTYLE_BUTTON;\r
-            tbb[4].idCommand = ID_STOP;\r
-            tbb[5].iBitmap = STD_FILENEW;\r
-            tbb[5].fsState = TBSTATE_ENABLED;\r
-            tbb[5].fsStyle = TBSTYLE_BUTTON;\r
-            tbb[5].idCommand = ID_PAUSE;\r
-            tbb[6].iBitmap = STD_FILENEW;\r
-            tbb[6].fsState = TBSTATE_ENABLED;\r
-            tbb[6].fsStyle = TBSTYLE_BUTTON;\r
-            tbb[6].idCommand = ID_RESTART;\r
-            SendMessage(hTool, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb);\r
-\r
-                       /* Create Status bar */\r
-                       hStatus = CreateWindowEx(0,\r
+\r
+\r
+/* ======================== Create Status Bar ============================== */\r
+\r
+                   hStatus = CreateWindowEx(0,\r
                                      STATUSCLASSNAME,\r
                                      NULL,\r
                                      WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP,\r
@@ -148,66 +172,67 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                                      hInstance,\r
                                      NULL);\r
             if(hStatus == NULL)\r
-                               MessageBox(hwnd, _T("Could not create status bar."),\r
+                           MessageBox(hwnd, _T("Could not create status bar."),\r
                            _T("Error!"), MB_OK | MB_ICONERROR);\r
 \r
-                       SendMessage(hStatus, SB_SETPARTS, sizeof(statwidths)/sizeof(int), (LPARAM)statwidths);\r
+                   SendMessage(hStatus, SB_SETPARTS, sizeof(statwidths)/sizeof(int), (LPARAM)statwidths);\r
 \r
-                       /* populate the list view with all services */\r
-                       if (! RefreshServiceList() )\r
+\r
+/* ================= populate the list view with all services =================== */\r
+\r
+                   if (! RefreshServiceList() )\r
                 GetError();\r
-               }\r
-               break;\r
-               case WM_SIZE:\r
-               {\r
-                       HWND hTool;\r
-                       RECT rcTool;\r
-                       int iToolHeight;\r
 \r
-                       //HWND hStatus;\r
-                       RECT rcStatus;\r
-                       int iStatusHeight;\r
+           }\r
+           break;\r
+\r
+           case WM_SIZE:\r
+           {\r
+                   RECT rcTool;\r
+                   int iToolHeight;\r
 \r
-                       //HWND hListView;\r
-                       int lvHeight;\r
-                       RECT rcClient;\r
+                   RECT rcStatus;\r
+                   int iStatusHeight;\r
 \r
-                       /* Size toolbar and get height */\r
-                       hTool = GetDlgItem(hwnd, IDC_TOOLBAR);\r
-                       SendMessage(hTool, TB_AUTOSIZE, 0, 0);\r
+                   int lvHeight;\r
+                   RECT rcClient;\r
 \r
-                       GetWindowRect(hTool, &rcTool);\r
-                       iToolHeight = rcTool.bottom - rcTool.top;\r
+                   /* Size toolbar and get height */\r
+            hTool = GetDlgItem(hwnd, IDC_TOOLBAR);\r
+                   SendMessage(hTool, TB_AUTOSIZE, 0, 0);\r
 \r
-                       /* Size status bar and get height */\r
-                       hStatus = GetDlgItem(hwnd, IDC_STATUSBAR);\r
-                       SendMessage(hStatus, WM_SIZE, 0, 0);\r
+                   GetWindowRect(hTool, &rcTool);\r
+                   iToolHeight = rcTool.bottom - rcTool.top;\r
 \r
-                       GetWindowRect(hStatus, &rcStatus);\r
-                       iStatusHeight = rcStatus.bottom - rcStatus.top;\r
+                   /* Size status bar and get height */\r
+                   hStatus = GetDlgItem(hwnd, IDC_STATUSBAR);\r
+                   SendMessage(hStatus, WM_SIZE, 0, 0);\r
 \r
-                       /* Calculate remaining height and size list view */\r
-                       GetClientRect(hwnd, &rcClient);\r
+                   GetWindowRect(hStatus, &rcStatus);\r
+                   iStatusHeight = rcStatus.bottom - rcStatus.top;\r
 \r
-                       lvHeight = rcClient.bottom - iToolHeight - iStatusHeight;\r
+                   /* Calculate remaining height and size list view */\r
+                   GetClientRect(hwnd, &rcClient);\r
 \r
-                       hListView = GetDlgItem(hwnd, IDC_SERVLIST);\r
-                       SetWindowPos(hListView, NULL, 0, iToolHeight, rcClient.right, lvHeight, SWP_NOZORDER);\r
-               }\r
-               break;\r
+                   lvHeight = rcClient.bottom - iToolHeight - iStatusHeight;\r
 \r
-               case WM_NOTIFY:\r
+                   hListView = GetDlgItem(hwnd, IDC_SERVLIST);\r
+                   SetWindowPos(hListView, NULL, 0, iToolHeight, rcClient.right, lvHeight, SWP_NOZORDER);\r
+           }\r
+           break;\r
+\r
+           case WM_NOTIFY:\r
         {\r
             LPNMITEMACTIVATE item;\r
 \r
             switch (((LPNMHDR) lParam)->code)\r
             {\r
 \r
-                       case NM_DBLCLK:\r
-                               item = (LPNMITEMACTIVATE) lParam;\r
-                               PropSheets(hwnd);\r
+                   case NM_DBLCLK:\r
+                           item = (LPNMITEMACTIVATE) lParam;\r
+                           PropSheets(hwnd);\r
 \r
-                               break;\r
+                           break;\r
             \r
                 case TTN_GETDISPINFO:\r
                 {\r
@@ -219,7 +244,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 \r
                     // Specify the resource identifier of the descriptive\r
                     // text for the given button.\r
-                    idButton = lpttt->hdr.idFrom;\r
+                    idButton = (UINT)lpttt->hdr.idFrom;\r
                     switch (idButton)\r
                     {\r
                         case ID_PROP:\r
@@ -249,6 +274,18 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                         case ID_RESTART:\r
                             lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_RESTART);\r
                         break;\r
+                        \r
+                        case ID_NEW:\r
+                            lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_NEW);\r
+                        break;\r
+\r
+                        case ID_HELP:\r
+                            lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_HELP);\r
+                        break;\r
+\r
+                        case ID_EXIT:\r
+                            lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_EXIT);\r
+                        break;\r
 \r
                     }\r
                 }\r
@@ -260,23 +297,32 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
         }\r
         break;\r
 \r
-               case WM_CLOSE:\r
+           case WM_CLOSE:\r
             /* free the service array */\r
             FreeMemory();\r
-                       DestroyWindow(hwnd);\r
-               break;\r
-               case WM_DESTROY:\r
-                       PostQuitMessage(0);\r
-               break;\r
-               case WM_COMMAND:\r
-                       switch(LOWORD(wParam))\r
-                       {\r
-                               case ID_FILE_EXIT:\r
-                                       PostMessage(hwnd, WM_CLOSE, 0, 0);\r
-                               break;\r
-\r
-                               case ID_START:\r
-                               break;\r
+                   DestroyWindow(hwnd);\r
+           break;\r
+\r
+           case WM_DESTROY:\r
+                   PostQuitMessage(0);\r
+           break;\r
+\r
+           case WM_COMMAND:\r
+                   switch(LOWORD(wParam))\r
+                   {\r
+                case ID_PROP:\r
+                    PropSheets(hwnd);\r
+                break;\r
+                \r
+                case ID_REFRESH:\r
+                    if (! RefreshServiceList() )\r
+                        GetError();\r
+\r
+                case ID_EXPORT:\r
+                break;\r
+\r
+                case ID_START:\r
+                           break;\r
 \r
                 case ID_STOP:\r
                 break;\r
@@ -290,85 +336,89 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                 case ID_RESTART:\r
                 break;\r
 \r
-                case ID_REFRESH:\r
+                case ID_NEW:\r
                 break;\r
 \r
-                case ID_PROP:\r
-                    PropSheets(hwnd);\r
+                case ID_HELP:\r
+                    MessageBox(NULL, _T("Help is not yet implemented\n"), \r
+                        _T("Note!"), MB_OK | MB_ICONINFORMATION);\r
+                break;\r
+\r
+                case ID_EXIT:\r
+                    PostMessage(hwnd, WM_CLOSE, 0, 0);\r
                 break;\r
 \r
                 case ID_VIEW_CUSTOMIZE:\r
                 break;\r
 \r
                 case ID_HELP_ABOUT:\r
-                    DialogBox(GetModuleHandle(NULL),\r
+                    DialogBox(hInstance,\r
                               MAKEINTRESOURCE(IDD_ABOUTBOX),\r
                               hwnd,\r
                               AboutDialogProc);\r
                  break;\r
 \r
-                case ID_EXPORT:\r
-                break;\r
+                   }\r
+           break;\r
 \r
-                       }\r
-               break;\r
-               default:\r
-                       return DefWindowProc(hwnd, msg, wParam, lParam);\r
-       }\r
-       return 0;\r
+           default:\r
+                   return DefWindowProc(hwnd, msg, wParam, lParam);\r
+    }\r
+    return 0;\r
 }\r
 \r
-\r
-\r
+#ifdef _MSC_VER\r
+#pragma warning(disable : 4100)\r
+#endif\r
 int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance,\r
-       LPSTR lpCmdLine, int nCmdShow)\r
+    LPSTR lpCmdLine, int nCmdShow)\r
 {\r
-       WNDCLASSEX wc;\r
-       MSG Msg;\r
-       BOOL bRet;\r
-\r
-       hInstance = hThisInstance;\r
-\r
-       InitCommonControls();\r
-\r
-       wc.cbSize                = sizeof(WNDCLASSEX);\r
-       wc.style                 = 0;\r
-       wc.lpfnWndProc   = WndProc;\r
-       wc.cbClsExtra    = 0;\r
-       wc.cbWndExtra    = 0;\r
-       wc.hInstance     = hInstance;\r
-       wc.hIcon                 = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SM_ICON));\r
-       wc.hCursor               = LoadCursor(NULL, IDC_ARROW);\r
-       wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);\r
-       wc.lpszMenuName  = MAKEINTRESOURCE(IDR_MAINMENU);\r
-       wc.lpszClassName = ClassName;\r
-       wc.hIconSm               = (HICON)LoadImage(hInstance,\r
+    WNDCLASSEX wc;\r
+    MSG Msg;\r
+    BOOL bRet;\r
+\r
+    hInstance = hThisInstance;\r
+\r
+    InitCommonControls();\r
+\r
+    wc.cbSize           = sizeof(WNDCLASSEX);\r
+    wc.style            = 0;\r
+    wc.lpfnWndProc      = WndProc;\r
+    wc.cbClsExtra       = 0;\r
+    wc.cbWndExtra       = 0;\r
+    wc.hInstance        = hInstance;\r
+    wc.hIcon            = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_SM_ICON));\r
+    wc.hCursor          = LoadCursor(NULL, IDC_ARROW);\r
+    wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);\r
+    wc.lpszMenuName  = MAKEINTRESOURCE(IDR_MAINMENU);\r
+    wc.lpszClassName = ClassName;\r
+    wc.hIconSm          = (HICON)LoadImage(hInstance,\r
                         MAKEINTRESOURCE(IDI_SM_ICON), IMAGE_ICON, 16, 16, 0);\r
 \r
-       if(!RegisterClassEx(&wc))\r
-       {\r
-               MessageBox(NULL, _T("Window Registration Failed!"), _T("Error!"),\r
-                       MB_ICONEXCLAMATION | MB_OK);\r
-               return 0;\r
-       }\r
-\r
-       hMainWnd = CreateWindowEx(\r
-               0,\r
-               ClassName,\r
-               _T("ReactOS Service Manager"),\r
-               WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,\r
-               CW_USEDEFAULT, CW_USEDEFAULT, 700, 500,\r
-               NULL, NULL, hInstance, NULL);\r
-\r
-       if(hMainWnd == NULL)\r
-       {\r
-               MessageBox(NULL, _T("Window Creation Failed!"), _T("Error!"),\r
-                       MB_ICONEXCLAMATION | MB_OK);\r
-               return 0;\r
-       }\r
-\r
-       ShowWindow(hMainWnd, nCmdShow);\r
-       UpdateWindow(hMainWnd);\r
+    if(!RegisterClassEx(&wc))\r
+    {\r
+           MessageBox(NULL, _T("Window Registration Failed!"), _T("Error!"),\r
+                   MB_ICONEXCLAMATION | MB_OK);\r
+           return 0;\r
+    }\r
+\r
+    hMainWnd = CreateWindowEx(\r
+           0,\r
+           ClassName,\r
+           _T("ReactOS Service Manager"),\r
+           WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,\r
+           CW_USEDEFAULT, CW_USEDEFAULT, 700, 500,\r
+           NULL, NULL, hInstance, NULL);\r
+\r
+    if(hMainWnd == NULL)\r
+    {\r
+           MessageBox(NULL, _T("Window Creation Failed!"), _T("Error!"),\r
+                   MB_ICONEXCLAMATION | MB_OK);\r
+           return 0;\r
+    }\r
+\r
+    ShowWindow(hMainWnd, nCmdShow);\r
+    UpdateWindow(hMainWnd);\r
 \r
     while( (bRet = GetMessage( &Msg, NULL, 0, 0 )) != 0)\r
     {\r
@@ -382,7 +432,7 @@ int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance,
             DispatchMessage(&Msg);\r
         }\r
     }\r
-       return Msg.wParam;\r
+    return (int)Msg.wParam;\r
 }\r
 \r
 \r