Refactored: Dropped unused code
[TortoiseGit.git] / src / touch / touch.cpp
blobcb5794a79e7e57d4fdf1c3731d5e495c06573c96
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2010-2011 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 // touch.cpp : Defines the entry point for the application.
23 #include "stdafx.h"
24 #include "touch.h"
26 #define MAX_LOADSTRING 100
28 // Global Variables:
29 HINSTANCE hInst; // current instance
30 TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
31 TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
33 // Forward declarations of functions included in this code module:
34 ATOM MyRegisterClass(HINSTANCE hInstance);
35 BOOL InitInstance(HINSTANCE, int);
36 LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
37 INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
39 TCHAR longname[MAX_PATH +1];
41 int APIENTRY _tWinMain(HINSTANCE hInstance,
42 HINSTANCE hPrevInstance,
43 LPTSTR lpCmdLine,
44 int nCmdShow)
46 UNREFERENCED_PARAMETER(hPrevInstance);
48 SetDllDirectory(L"");
50 if(_tcslen(lpCmdLine) == 0)
51 return -1;
53 //GetLongPathName(lpCmdLine,longname,MAX_PATH);
55 if(lpCmdLine[0] == '\"')
57 lpCmdLine ++;
58 for(size_t i=0;i<_tcslen(lpCmdLine);i++)
59 if(lpCmdLine[i]== '\"')
61 lpCmdLine[i]=0;
62 break;
65 HANDLE handle=CreateFile(lpCmdLine,GENERIC_READ | GENERIC_WRITE, 0,NULL,OPEN_ALWAYS,0,NULL);
66 if(handle == INVALID_HANDLE_VALUE)
67 return -1;
68 CloseHandle(handle);
70 DWORD attr=GetFileAttributes(lpCmdLine);
71 SetFileAttributes(lpCmdLine,attr);
72 return 0;
76 // FUNCTION: MyRegisterClass()
78 // PURPOSE: Registers the window class.
80 // COMMENTS:
82 // This function and its usage are only necessary if you want this code
83 // to be compatible with Win32 systems prior to the 'RegisterClassEx'
84 // function that was added to Windows 95. It is important to call this function
85 // so that the application will get 'well formed' small icons associated
86 // with it.
88 ATOM MyRegisterClass(HINSTANCE hInstance)
90 WNDCLASSEX wcex;
92 wcex.cbSize = sizeof(WNDCLASSEX);
94 wcex.style = CS_HREDRAW | CS_VREDRAW;
95 wcex.lpfnWndProc = WndProc;
96 wcex.cbClsExtra = 0;
97 wcex.cbWndExtra = 0;
98 wcex.hInstance = hInstance;
99 wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TOUCH));
100 wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
101 wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
102 wcex.lpszMenuName = MAKEINTRESOURCE(IDC_TOUCH);
103 wcex.lpszClassName = szWindowClass;
104 wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
106 return RegisterClassEx(&wcex);
110 // FUNCTION: InitInstance(HINSTANCE, int)
112 // PURPOSE: Saves instance handle and creates main window
114 // COMMENTS:
116 // In this function, we save the instance handle in a global variable and
117 // create and display the main program window.
119 BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
121 HWND hWnd;
123 hInst = hInstance; // Store instance handle in our global variable
125 hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
126 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
128 if (!hWnd)
130 return FALSE;
133 ShowWindow(hWnd, nCmdShow);
134 UpdateWindow(hWnd);
136 return TRUE;
140 // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
142 // PURPOSE: Processes messages for the main window.
144 // WM_COMMAND - process the application menu
145 // WM_PAINT - Paint the main window
146 // WM_DESTROY - post a quit message and return
149 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
151 int wmId, wmEvent;
152 PAINTSTRUCT ps;
153 HDC hdc;
155 switch (message)
157 case WM_COMMAND:
158 wmId = LOWORD(wParam);
159 wmEvent = HIWORD(wParam);
160 // Parse the menu selections:
161 switch (wmId)
163 case IDM_ABOUT:
164 DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
165 break;
166 case IDM_EXIT:
167 DestroyWindow(hWnd);
168 break;
169 default:
170 return DefWindowProc(hWnd, message, wParam, lParam);
172 break;
173 case WM_PAINT:
174 hdc = BeginPaint(hWnd, &ps);
175 // Add any drawing code here...
176 EndPaint(hWnd, &ps);
177 break;
178 case WM_DESTROY:
179 PostQuitMessage(0);
180 break;
181 default:
182 return DefWindowProc(hWnd, message, wParam, lParam);
184 return 0;
187 // Message handler for about box.
188 INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
190 UNREFERENCED_PARAMETER(lParam);
191 switch (message)
193 case WM_INITDIALOG:
194 return (INT_PTR)TRUE;
196 case WM_COMMAND:
197 if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
199 EndDialog(hDlg, LOWORD(wParam));
200 return (INT_PTR)TRUE;
202 break;
204 return (INT_PTR)FALSE;