Changeset 37165
- Timestamp:
- 04/07/10 12:42:10 (3 years ago)
- Location:
- lang/objective-cplusplus/i3/trunk/tmp
- Files:
-
- 3 modified
-
dwmtest.cpp (modified) (8 diffs)
-
dwmtest.vcxproj (modified) (1 diff)
-
ex.cpp (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/objective-cplusplus/i3/trunk/tmp/dwmtest.cpp
r36861 r37165 22 22 LRESULT CALLBACK BlurEditWndProc( 23 23 HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { 24 static bool blured = false;25 24 26 25 WNDPROC wp = BlurEditWndProc; … … 29 28 (WNDPROC)GetProp(hWnd, _T("my default wndproc")); 30 29 31 if (message == WM_SETFOCUS) {30 if (message == WM_SETFOCUS) { 32 31 InvalidateRect(hWnd, 0, FALSE); 33 32 } … … 85 84 } 86 85 } 86 87 87 88 88 if (message == WM_PAINT) { … … 148 148 (void)wp; 149 149 150 if (message = WM_SHOWWINDOW) { 151 bool show = (bool)wParam; 152 if (!show) { 153 // before hide 154 if (blured) { 155 blured = false; 156 DWM_BLURBEHIND bb = {}; 157 bb.dwFlags = DWM_BB_ENABLE; 158 bb.fEnable = FALSE; 159 DwmEnableBlurBehindWindow(hWnd, &bb); 160 } 161 } 162 } 163 164 if (message == WM_COMMAND) { 165 int wID = wParam & 0xFFFF; 166 int wNotifyCode = (wParam >> 16) & 0xFFFF; 167 HWND hwndControl = (HWND)lParam; 168 if (wNotifyCode == EN_UPDATE) { 169 InvalidateRect(hwndControl, 0, FALSE); 170 } else if (wNotifyCode == EN_KILLFOCUS) { 171 focused = false; 172 if (IsWindowVisible(hWnd) && !blured) { 173 blured = true; 174 DWM_BLURBEHIND bb = {}; 175 bb.dwFlags = DWM_BB_ENABLE; 176 bb.fEnable = TRUE; 177 DwmEnableBlurBehindWindow(hWnd, &bb); 178 InvalidateRect(hwndControl, NULL, FALSE); 179 } 180 } else if (wNotifyCode == EN_SETFOCUS) { 181 focused = true; 182 if (blured) { 183 blured = false; 184 DWM_BLURBEHIND bb = {}; 185 bb.dwFlags = DWM_BB_ENABLE; 186 bb.fEnable = FALSE; 187 DwmEnableBlurBehindWindow(hWnd, &bb); 188 InvalidateRect(hwndControl, NULL, FALSE); 189 } 190 } 191 } 150 if (message == WM_COMMAND) { 151 int wID = LOWORD(wParam); 152 int wNotifyCode = HIWORD(wParam); 153 HWND hwndControl = (HWND)lParam; 154 if (hwndControl == (HWND)GetProp(hWnd, _T("my editbox"))) { 155 if (wNotifyCode == EN_UPDATE) { 156 InvalidateRect(hwndControl, 0, FALSE); 157 } 158 } 159 } 192 160 193 161 if (message == WM_DESTROY) { … … 199 167 } 200 168 201 void ShowLastError() { 202 DWORD le = GetLastError(); 203 LPVOID lpMessageBuffer; 204 FormatMessage( 205 FORMAT_MESSAGE_ALLOCATE_BUFFER | 206 FORMAT_MESSAGE_FROM_SYSTEM, 207 NULL, 208 le, 209 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // �f�t�H���g ���[�U�[���� 210 (LPTSTR)&lpMessageBuffer, 211 0, 212 NULL); 213 214 MessageBox(NULL, (LPTSTR)lpMessageBuffer, _T("GetLastError"), MB_OK); 215 LocalFree(lpMessageBuffer); 216 DebugBreak(); 217 } 169 #define SET_DLL_ADDRESS(module, name) \ 170 { \ 171 dll.name = (decltype(&name))GetProcAddress(module, #name); \ 172 } 218 173 219 174 int APIENTRY _tWinMain(HINSTANCE hInstance, … … 224 179 UNREFERENCED_PARAMETER(lpCmdLine); 225 180 226 if (BufferedPaintInit() != S_OK) { 227 ShowLastError(); 228 return 1; 229 } 181 assert(LoadLibrary(_T("msftedit.dll"))); 182 assert(LoadLibrary(_T("riched20.dll"))); 183 assert(LoadLibrary(_T("riched32.dll"))); 230 184 231 185 HMODULE dwmapi_dll = LoadLibrary(_T("dwmapi.dll")); … … 238 192 SET_DLL_ADDRESS(dwmapi_dll, DwmGetWindowAttribute); 239 193 240 WNDCLASS wc; 241 wc.style = CS_HREDRAW | CS_VREDRAW; 242 wc.lpfnWndProc = WndProc; 243 wc.cbClsExtra = 0; 244 wc.cbWndExtra = 0; 245 wc.hInstance = hInstance; 246 wc.hIcon = NULL; 247 wc.hCursor = LoadCursor(NULL, IDC_ARROW); 248 wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); 249 wc.lpszMenuName = NULL; 250 wc.lpszClassName = szWindowClass; 251 252 if (!RegisterClass(&wc)) { 253 ShowLastError(); 254 return 1; 255 } 256 257 TCHAR szTitle[] = _T("hige"); 258 HWND hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, 259 CW_USEDEFAULT, 0, 200, 200, NULL, NULL, hInstance, NULL); 260 if (!hWnd) { 261 ShowLastError(); 262 return 1; 263 } 194 HMODULE uxtheme_dll = LoadLibrary(_T("uxtheme.dll")); 195 assert(uxtheme_dll); 196 SET_DLL_ADDRESS(uxtheme_dll, BeginBufferedPaint); 197 SET_DLL_ADDRESS(uxtheme_dll, BufferedPaintInit); 198 SET_DLL_ADDRESS(uxtheme_dll, BufferedPaintUnInit); 199 SET_DLL_ADDRESS(uxtheme_dll, EndBufferedPaint); 200 SET_DLL_ADDRESS(uxtheme_dll, BufferedPaintSetAlpha); 201 202 assert(dll.BufferedPaintInit() == S_OK); 264 203 265 204 MSG msg = {}; … … 322 261 NULL); 323 262 324 if (!hEdit) { 325 ShowLastError(); 326 return 1; 327 } 328 329 EditDefaultWndProc = (WNDPROC)GetWindowLongPtr(hEdit, GWLP_WNDPROC); 263 assert(hEdit); 264 assert(SetProp(hWnd, _T("my editbox"), (HANDLE)hEdit) != 0); 265 266 HANDLE wp = (HANDLE)GetWindowLongPtr(hEdit, GWLP_WNDPROC); 267 assert(SetProp(hEdit, _T("my default wndproc"), wp) != 0); 330 268 SetWindowLong(hEdit, GWLP_WNDPROC, (LONG_PTR)BlurEditWndProc); 331 269 -
lang/objective-cplusplus/i3/trunk/tmp/dwmtest.vcxproj
r36619 r37165 49 49 <PrecompiledHeader> 50 50 </PrecompiledHeader> 51 <WarningLevel>Level 3</WarningLevel>51 <WarningLevel>Level4</WarningLevel> 52 52 <MinimalRebuild>true</MinimalRebuild> 53 53 <DebugInformationFormat>EditAndContinue</DebugInformationFormat> -
lang/objective-cplusplus/i3/trunk/tmp/ex.cpp
r37162 r37165 1 2 1 ///////////////////////////////////////////////////////////////////// 3 2 // ex2.cpp … … 6 5 ///////////////////////////////////////////////////////////////////// 7 6 8 #define WIN32_LEAN_AND_MEAN9 7 #define STRICT 10 8 … … 14 12 #include <tlhelp32.h> 15 13 #include <dbghelp.h> 14 #include <windows.h> 15 #include <windowsx.h> 16 #include <tchar.h> 17 #include <uxtheme.h> 18 #include <dwmapi.h> 19 #include <assert.h> 20 #include <richedit.h> 16 21 17 22 // ImageDirectoryEntryToData … … 23 28 PROC pfnCurrent, 24 29 PROC pfnNew, 25 HMODULE hmodCaller) 30 HMODULE hmodCaller) 26 31 { 27 32 ULONG ulSize; 28 33 PIMAGE_IMPORT_DESCRIPTOR pImportDesc; 29 34 pImportDesc = (PIMAGE_IMPORT_DESCRIPTOR)ImageDirectoryEntryToData( 30 hmodCaller, TRUE, IMAGE_DIRECTORY_ENTRY_IMPORT, &ulSize);35 hmodCaller, TRUE, IMAGE_DIRECTORY_ENTRY_IMPORT, &ulSize); 31 36 32 37 if (pImportDesc == NULL) { … … 35 40 36 41 37 while (pImportDesc->Name) {42 while (pImportDesc->Name) { 38 43 PSTR pszModName = (PSTR) ((PBYTE) hmodCaller + pImportDesc->Name); 39 44 if (lstrcmpiA(pszModName, pszModuleName) == 0) { … … 47 52 } 48 53 49 PIMAGE_THUNK_DATA pThunk = (PIMAGE_THUNK_DATA) 50 ((PBYTE) hmodCaller + pImportDesc->FirstThunk);51 52 while (pThunk->u1.Function) {54 PIMAGE_THUNK_DATA pThunk = (PIMAGE_THUNK_DATA) 55 ((PBYTE) hmodCaller + pImportDesc->FirstThunk); 56 57 while (pThunk->u1.Function) { 53 58 PROC *ppfn = (PROC*) &pThunk->u1.Function; 54 59 BOOL fFound = (*ppfn == pfnCurrent); … … 66 71 // ���ׂẴ��W���[���ɑ���PI�t�b�N����� 67 72 void ReplaceIATEntryInAllMods( 68 PCSTR pszModuleName, 69 PROC pfnCurrent, 70 PROC pfnNew) 73 PCSTR pszModuleName, 74 PROC pfnCurrent, 75 PROC pfnNew) 71 76 { 72 77 // ���W���[�����X�g��� 73 78 HANDLE hModuleSnap = CreateToolhelp32Snapshot( 74 TH32CS_SNAPMODULE, GetCurrentProcessId());75 if (hModuleSnap == INVALID_HANDLE_VALUE) {79 TH32CS_SNAPMODULE, GetCurrentProcessId()); 80 if (hModuleSnap == INVALID_HANDLE_VALUE) { 76 81 return; 77 82 } … … 80 85 BOOL bModuleResult = Module32First(hModuleSnap, &me); 81 86 // ���ꂼ�����W���[���ɑ���eplaceIATEntryInOneMod��s 82 while (bModuleResult) {87 while (bModuleResult) { 83 88 ReplaceIATEntryInOneMod(pszModuleName, pfnCurrent, pfnNew, me.hModule); 84 89 bModuleResult = Module32Next(hModuleSnap, &me); … … 96 101 97 102 int WINAPI Hook_TextOutW( 98 HDC hdc, int x, int y, LPCWSTR str, int count99 ) {103 HDC hdc, int x, int y, LPCWSTR str, int count 104 ) { 100 105 OutputDebugString(_T("to")); 101 106 PROC pfnOrig = GetProcAddress(GetModuleHandleA("gdi32.dll"), "TextOutW"); … … 104 109 105 110 int WINAPI Hook_ExtTextOutW( 106 HDC hdc, int x, int y, UINT option, CONST RECT *rc, LPCWSTR str, UINT count, CONST INT *dx 107 ) {111 HDC hdc, int x, int y, UINT option, CONST RECT *rc, LPCWSTR str, UINT count, CONST INT *dx 112 ) { 108 113 OutputDebugString(_T("dw")); 109 114 PROC pfnOrig = GetProcAddress(GetModuleHandleA("gdi32.dll"), "ExtTextOutW"); … … 112 117 113 118 LONG WINAPI Hook_TabbedTextOutW( 114 HDC hdc, int x, int y, LPCWSTR str, int count, int ntabs, const INT* tabs, int origin ) {119 HDC hdc, int x, int y, LPCWSTR str, int count, int ntabs, const INT* tabs, int origin ) { 115 120 OutputDebugString(_T("dw")); 116 121 PROC pfnOrig = GetProcAddress(GetModuleHandleA("gdi32.dll"), "TabbedTextOutW"); … … 144 149 145 150 int WINAPI Hook_MessageBoxW( 146 HWND hWnd, 147 PCWSTR pszText, 148 PCWSTR pszCaption, 151 HWND hWnd, 152 PCWSTR pszText, 153 PCWSTR pszCaption, 149 154 UINT uType) 150 155 { … … 160 165 PFN_DrawTextW dt1 = DrawText; 161 166 PFN_DrawTextW dt2 = Hook_DrawTextW; 162 163 167 PFN_ExtTextOutW di1 = ExtTextOut; 164 168 PFN_ExtTextOutW di2 = Hook_ExtTextOutW; 165 166 169 PFN_TextOutW do1 = TextOut; 167 170 PFN_TextOutW do2 = Hook_TextOutW; 168 169 171 PFN_TabbedTextOutW dx1 = TabbedTextOut; 170 172 PFN_TabbedTextOutW dx2 = Hook_TabbedTextOutW; 171 173 172 //int APIENTRY _tWinMain(HINSTANCE hInstance,173 // HINSTANCE hPrevInstance,174 // LPTSTR lpCmdLine,175 // int nCmdShow)176 177 178 179 #include <windows.h>180 #include <windowsx.h>181 #include <tchar.h>182 #include <uxtheme.h>183 #include <dwmapi.h>184 #include <assert.h>185 #include <richedit.h>186 174 187 175 void ShowLastError() { 188 DWORD le = GetLastError(); 189 LPVOID lpMessageBuffer; 190 FormatMessage( 191 FORMAT_MESSAGE_ALLOCATE_BUFFER | 192 FORMAT_MESSAGE_FROM_SYSTEM, 193 NULL, 194 le, 195 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // �f�t�H���g ���[�U�[���� 196 (LPTSTR)&lpMessageBuffer, 197 0, 198 NULL); 199 200 //MessageBox(NULL, (LPTSTR)lpMessageBuffer, _T("GetLastError"), MB_OK); 176 DWORD le = GetLastError(); 177 LPVOID lpMessageBuffer; 178 FormatMessage( 179 FORMAT_MESSAGE_ALLOCATE_BUFFER | 180 FORMAT_MESSAGE_FROM_SYSTEM, 181 NULL, 182 le, 183 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // �f�t�H���g ���[�U�[���� (LPTSTR)&lpMessageBuffer, 184 0, 185 NULL); 186 187 //MessageBox(NULL, (LPTSTR)lpMessageBuffer, _T("GetLastError"), MB_OK); 201 188 OutputDebugString((LPTSTR)lpMessageBuffer); 202 LocalFree(lpMessageBuffer);203 DebugBreak();189 LocalFree(lpMessageBuffer); 190 DebugBreak(); 204 191 } 205 192 … … 212 199 213 200 if (message == WM_PAINT) { //�N���C�A���g�̈��ĕ`�揈�� 214 /* �f�o�C�X�R���e�L�X�g�̃n���h����� */201 /* �f�o�C�X�R���e�L�X�g�̃n���h����� */ 215 202 PAINTSTRUCT ps; 216 203 HDC hDC = BeginPaint(hWnd, &ps); … … 220 207 // TextOut(hDC, 100, 170, _T("���������Ή������ׂ���, 22); 221 208 // TextOut(hDC, 100, 200, _T("Hello World!"), 12); 222 209 223 210 /* �����̐F�Ɣw�i�F����������̕`��/ 224 211 SetTextColor(hDC, RGB(0,0,255)); //�����̐F��肷�� SetBkColor(hDC, RGB(255,255,0)); //�����̔w�i�F��肷�� _tcscpy(str, _T("abcde12345����������")); 225 212 // TextOut(hDC, 100, 230, str, _tcslen(str)); 226 213 227 214 /* �����/ 228 215 MoveToEx(hDC, 100, 190, NULL); //�P�{�ڂ̉���܂��u … … 230 217 MoveToEx(hDC, 100, 220, NULL); //�Q�{�ڂ̉���܂��u 231 218 LineTo(hDC, 185, 220); //�Q�{�ڂ̉�����ʒu 232 219 233 220 /* �n���h���̉�*/ 234 221 EndPaint(hWnd, &ps); … … 295 282 296 283 HWND hWnd = CreateWindow( 297 szWindowClass, szTitle, style,298 50, 50, r.right - r.left, r.bottom - r.top,299 NULL, NULL, hInstance, NULL);284 szWindowClass, szTitle, style, 285 50, 50, r.right - r.left, r.bottom - r.top, 286 NULL, NULL, hInstance, NULL); 300 287 assert(hWnd); 301 288 302 HWND hEdit = CreateWindow( 303 _T("EDIT"),304 _T("hage"),305 WS_CHILD | WS_VISIBLE /*| WS_BORDER */,306 50,307 100,308 200,309 100,310 hWnd,311 NULL,312 hInstance,313 NULL);314 315 if (!hEdit) {316 ShowLastError();317 return 1;318 }319 289 HWND hEdit = CreateWindow( 290 _T("EDIT"), 291 _T("hage"), 292 WS_CHILD | WS_VISIBLE /*| WS_BORDER */, 293 50, 294 100, 295 200, 296 100, 297 hWnd, 298 NULL, 299 hInstance, 300 NULL); 301 302 if (!hEdit) { 303 ShowLastError(); 304 return 1; 305 } 306 320 307 ShowWindow(hWnd, nCmdShow); 321 308 UpdateWindow(hWnd);
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)