ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

main.c
Go to the documentation of this file.
00001 /*
00002  * Regedit main function
00003  *
00004  * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 #include <regedit.h>
00022 
00023 BOOL ProcessCmdLine(LPWSTR lpCmdLine);
00024 
00025 
00026 /*******************************************************************************
00027  * Global Variables:
00028  */
00029 
00030 HINSTANCE hInst;
00031 HWND hFrameWnd;
00032 HWND hStatusBar;
00033 HMENU hMenuFrame;
00034 HMENU hPopupMenus = 0;
00035 UINT nClipboardFormat;
00036 LPCTSTR strClipboardFormat = _T("TODO: SET CORRECT FORMAT");
00037 
00038 #define MAX_LOADSTRING  100
00039 TCHAR szTitle[MAX_LOADSTRING];
00040 TCHAR szFrameClass[MAX_LOADSTRING];
00041 TCHAR szChildClass[MAX_LOADSTRING];
00042 
00043 
00044 /*******************************************************************************
00045  *
00046  *
00047  *   FUNCTION: InitInstance(HANDLE, int)
00048  *
00049  *   PURPOSE: Saves instance handle and creates main window
00050  *
00051  *   COMMENTS:
00052  *
00053  *        In this function, we save the instance handle in a global variable and
00054  *        create and display the main program window.
00055  */
00056 
00057 BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
00058 {
00059     BOOL AclUiAvailable;
00060     HMENU hEditMenu;
00061 
00062     WNDCLASSEX wcFrame;
00063     WNDCLASSEX wcChild;
00064     ATOM hFrameWndClass;
00065 
00066     ZeroMemory(&wcFrame, sizeof(WNDCLASSEX));
00067     wcFrame.cbSize = sizeof(WNDCLASSEX);
00068     wcFrame.lpfnWndProc = FrameWndProc;
00069     wcFrame.hInstance = hInstance;
00070     wcFrame.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT));
00071     wcFrame.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT),
00072                                        IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
00073                                        GetSystemMetrics(SM_CYSMICON), LR_SHARED);
00074     wcFrame.hCursor = LoadCursor(0, IDC_ARROW);
00075     wcFrame.lpszClassName = szFrameClass;
00076 
00077     hFrameWndClass = RegisterClassEx(&wcFrame); /* register frame window class */
00078 
00079     ZeroMemory(&wcChild, sizeof(WNDCLASSEX));
00080     wcChild.cbSize = sizeof(WNDCLASSEX);
00081     wcChild.lpfnWndProc = ChildWndProc;
00082     wcChild.cbWndExtra = sizeof(HANDLE);
00083     wcChild.hInstance = hInstance;
00084     wcChild.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_REGEDIT));
00085     wcChild.hCursor = LoadCursor(0, IDC_ARROW),
00086             wcChild.lpszClassName =  szChildClass,
00087                     wcChild.hIconSm = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_REGEDIT), IMAGE_ICON,
00088                                       GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED);
00089 
00090     RegisterClassEx(&wcChild); /* register child windows class */
00091 
00092     RegisterHexEditorClass(hInstance);
00093 
00094     hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_REGEDIT_MENU));
00095     hPopupMenus = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_POPUP_MENUS));
00096 
00097     /* Initialize the Windows Common Controls DLL */
00098     InitCommonControls();
00099 
00100     hEditMenu = GetSubMenu(hMenuFrame, 1);
00101 
00102     AclUiAvailable = InitializeAclUiDll();
00103     if(!AclUiAvailable)
00104     {
00105         /* hide the Edit/Permissions... menu entry */
00106         if(hEditMenu != NULL)
00107         {
00108             RemoveMenu(hEditMenu, ID_EDIT_PERMISSIONS, MF_BYCOMMAND);
00109             /* remove the separator after the menu item */
00110             RemoveMenu(hEditMenu, 4, MF_BYPOSITION);
00111         }
00112     }
00113 
00114     if(hEditMenu != NULL)
00115         SetMenuDefaultItem(hEditMenu, ID_EDIT_MODIFY, MF_BYCOMMAND);
00116 
00117     nClipboardFormat = RegisterClipboardFormat(strClipboardFormat);
00118     /* if (nClipboardFormat == 0) {
00119         DWORD dwError = GetLastError();
00120     } */
00121 
00122     hFrameWnd = CreateWindowEx(WS_EX_WINDOWEDGE, (LPCTSTR)(UlongToPtr(hFrameWndClass)), szTitle,
00123                                WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
00124                                CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
00125                                NULL, hMenuFrame, hInstance, NULL/*lpParam*/);
00126 
00127     if (!hFrameWnd)
00128     {
00129         return FALSE;
00130     }
00131 
00132     /* Create the status bar */
00133     hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|SBT_NOBORDERS,
00134                                     _T(""), hFrameWnd, STATUS_WINDOW);
00135     if (hStatusBar)
00136     {
00137         /* Create the status bar panes */
00138         SetupStatusBar(hFrameWnd, FALSE);
00139         CheckMenuItem(GetSubMenu(hMenuFrame, ID_VIEW_MENU), ID_VIEW_STATUSBAR, MF_BYCOMMAND|MF_CHECKED);
00140     }
00141 
00142     LoadSettings();
00143     UpdateWindow(hFrameWnd);
00144     return TRUE;
00145 }
00146 
00147 /******************************************************************************/
00148 
00149 /* we need to destroy the main menu before destroying the main window
00150    to avoid a memory leak */
00151 
00152 void DestroyMainMenu()
00153 {
00154     DestroyMenu(hMenuFrame);
00155 }
00156 
00157 /******************************************************************************/
00158 
00159 void ExitInstance(HINSTANCE hInstance)
00160 {
00161     UnregisterHexEditorClass(hInstance);
00162 
00163     DestroyMenu(hPopupMenus);
00164     UnloadAclUiDll();
00165 }
00166 
00167 BOOL TranslateChildTabMessage(MSG *msg)
00168 {
00169     if (msg->message != WM_KEYDOWN) return FALSE;
00170 
00171     /* Allow Ctrl+A on address bar */
00172     if ((msg->hwnd == g_pChildWnd->hAddressBarWnd) &&
00173         (msg->message == WM_KEYDOWN) &&
00174         (msg->wParam == 'A') && (GetKeyState(VK_CONTROL) < 0))
00175     {
00176         SendMessage(msg->hwnd, EM_SETSEL, 0, -1);
00177         return TRUE;
00178     }
00179 
00180     if (msg->wParam != VK_TAB) return FALSE;
00181     if (GetParent(msg->hwnd) != g_pChildWnd->hWnd) return FALSE;
00182     PostMessage(g_pChildWnd->hWnd, WM_COMMAND, ID_SWITCH_PANELS, 0);
00183     return TRUE;
00184 }
00185 
00186 int APIENTRY wWinMain(HINSTANCE hInstance,
00187                       HINSTANCE hPrevInstance,
00188                       LPWSTR    lpCmdLine,
00189                       int       nCmdShow)
00190 {
00191     MSG msg;
00192     HACCEL hAccel;
00193 
00194     UNREFERENCED_PARAMETER(hPrevInstance);
00195 
00196     if (ProcessCmdLine(lpCmdLine))
00197     {
00198         return 0;
00199     }
00200 
00201     /* Initialize global strings */
00202     LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
00203     LoadString(hInstance, IDC_REGEDIT_FRAME, szFrameClass, MAX_LOADSTRING);
00204     LoadString(hInstance, IDC_REGEDIT, szChildClass, MAX_LOADSTRING);
00205 
00206     /* Store instance handle in our global variable */
00207     hInst = hInstance;
00208 
00209     /* Perform application initialization */
00210     if (!InitInstance(hInstance, nCmdShow))
00211     {
00212         return FALSE;
00213     }
00214     hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(ID_ACCEL));
00215 
00216     /* Main message loop */
00217     while (GetMessage(&msg, (HWND)NULL, 0, 0))
00218     {
00219         if (!TranslateAccelerator(hFrameWnd, hAccel, &msg)
00220                 && !TranslateChildTabMessage(&msg))
00221         {
00222             TranslateMessage(&msg);
00223             DispatchMessage(&msg);
00224         }
00225     }
00226 
00227     ExitInstance(hInstance);
00228     return (int) msg.wParam;
00229 }

Generated on Sun May 27 2012 04:16:38 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.