X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=main.cpp;h=1bc49fc60285905d642bba45f416486c20de3c34;hb=HEAD;hp=7b7f0bd00fbacedca89f45293162b4d10217af89;hpb=a337956f09ed2c048589cb4674873817de3b6b48;p=ckw%2Fckw.git diff --git a/main.cpp b/main.cpp index 7b7f0bd..1bc49fc 100644 --- a/main.cpp +++ b/main.cpp @@ -587,6 +587,21 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) break; case WM_MOUSEMOVE: onMouseMove(hWnd, (short)LOWORD(lp),(short)HIWORD(lp)); + // scroll when mouse is outside (craftware) + { + short x = (short)LOWORD(lp); + short y = (short)HIWORD(lp); + + RECT rc; + GetClientRect(hWnd, &rc); + + if( y<0 ) { + PostMessage(gConWnd, WM_MOUSEWHEEL, WHEEL_DELTA<<16, y<<16|x ); + } + else if(y>=rc.bottom) { + PostMessage(gConWnd, WM_MOUSEWHEEL, -WHEEL_DELTA<<16, y<<16|x ); + } + } break; case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: @@ -702,7 +717,7 @@ static BOOL create_window(ckOpt& opt) }else{ title = new wchar_t[ strlen(conf_title)+1 ]; ZeroMemory(title, sizeof(wchar_t) * (strlen(conf_title)+1)); - MultiByteToWideChar(CP_ACP, 0, conf_title, strlen(conf_title), title, sizeof(wchar_t) * (strlen(conf_title)+1)); + MultiByteToWideChar(CP_ACP, 0, conf_title, (int)strlen(conf_title), title, (int)(sizeof(wchar_t) * (strlen(conf_title)+1)) ); } /* calc window size */ @@ -754,7 +769,7 @@ static BOOL create_window(ckOpt& opt) wc.hbrBackground = CreateSolidBrush(gColorTable[0]); wc.lpszMenuName = NULL; wc.lpszClassName = className; - wc.hIconSm = wc.hIcon; + wc.hIconSm = NULL; if(! RegisterClassEx(&wc)) return(FALSE); @@ -867,15 +882,47 @@ static BOOL create_font(const char* name, int height) return(TRUE); } +// for Windows SDK v7.0 ƒGƒ‰[‚ª”­¶‚·‚éê‡‚̓Rƒƒ“ƒgƒAƒEƒgB +#ifdef _MSC_VER +#include +#endif + /*----------*/ static void __hide_alloc_console() { + bool bResult = false; + /* * Open Console Window * hack StartupInfo.wShowWindow flag */ - DWORD* pflags = (DWORD*) 0x00020068; /* private memory */ - WORD* pshow = (WORD*) 0x0002006C; + +#ifdef _MSC_VER +#ifdef _WIN64 + INT_PTR peb = *(INT_PTR*)((INT_PTR)NtCurrentTeb() + 0x60); + INT_PTR param = *(INT_PTR*) (peb + 0x20); + DWORD* pflags = (DWORD*) (param + 0xa4); + WORD* pshow = (WORD*) (param + 0xa8); +#else +#ifndef _WINTERNL_ + INT_PTR peb = *(INT_PTR*)((INT_PTR)NtCurrentTeb() + 0x30); + INT_PTR param = *(INT_PTR*) (peb + 0x10); +#else + // for Windows SDK v7.0 + PPEB peb = *(PPEB*)((INT_PTR)NtCurrentTeb() + 0x30); + PRTL_USER_PROCESS_PARAMETERS param = peb->ProcessParameters; +#endif // _WINTERNL_ + + DWORD* pflags = (DWORD*)((INT_PTR)param + 0x68); + WORD* pshow = (WORD*)((INT_PTR)param + 0x6C); +#endif // _WIN64 +#else + // for gcc + INT_PTR peb = *(INT_PTR*)((INT_PTR)NtCurrentTeb() + 0x30); + PRTL_USER_PROCESS_PARAMETERS param = *(PRTL_USER_PROCESS_PARAMETERS*)(peb + 0x10); + DWORD* pflags = (DWORD*)&(param->dwFlags); + WORD* pshow = (WORD*)&(param->wShowWindow); +#endif // _MSC_VER DWORD backup_flags = *pflags; WORD backup_show = *pshow; @@ -885,8 +932,14 @@ static void __hide_alloc_console() /* check */ if(si.dwFlags == backup_flags && si.wShowWindow == backup_show) { + // Ú×‚Í•s–¾‚¾‚ªSTARTF_TITLEISLINKNAME‚ª—§‚Á‚Ä‚¢‚é‚ƁA + // Console‘‹‰B‚µ‚ÉŽ¸”s‚·‚é‚̂ŏœ‹Ž(Win7-64bit) + if (*pflags & STARTF_TITLEISLINKNAME) { + *pflags &= ~STARTF_TITLEISLINKNAME; + } *pflags |= STARTF_USESHOWWINDOW; *pshow = SW_HIDE; + bResult = true; } AllocConsole(); @@ -894,6 +947,20 @@ static void __hide_alloc_console() /* restore */ *pflags = backup_flags; *pshow = backup_show; + + while((gConWnd = GetConsoleWindow()) == NULL) { + Sleep(10); + } + + if (!bResult){ + while (!IsWindowVisible(gConWnd)) { + Sleep(10); + } + while(IsWindowVisible(gConWnd)) { + ShowWindow(gConWnd, SW_HIDE); + Sleep(10); + } + } } /*----------*/ @@ -909,26 +976,15 @@ static BOOL create_console(ckOpt& opt) conf_title = opt.getTitle(); if(!conf_title || !conf_title[0]){ - title = L"ckw"; - }else{ - title = new wchar_t[ strlen(conf_title)+1 ]; - ZeroMemory(title, sizeof(wchar_t) * (strlen(conf_title)+1)); - MultiByteToWideChar(CP_ACP, 0, conf_title, strlen(conf_title), title, sizeof(wchar_t) * (strlen(conf_title)+1)); - } + title = L"ckw"; + }else{ + title = new wchar_t[ strlen(conf_title)+1 ]; + ZeroMemory(title, sizeof(wchar_t) * (strlen(conf_title)+1)); + MultiByteToWideChar(CP_ACP, 0, conf_title, (int)strlen(conf_title), title, (int)(sizeof(wchar_t) * (strlen(conf_title)+1)) ); + } __hide_alloc_console(); - while((gConWnd = GetConsoleWindow()) == NULL) { - Sleep(10); - } - ShowWindow(gConWnd, SW_SHOW); - while (!IsWindowVisible(gConWnd)) { - Sleep(10); - } - while(IsWindowVisible(gConWnd)) { - ShowWindow(gConWnd, SW_HIDE); - Sleep(10); - } SetConsoleTitle(title); SetConsoleCtrlHandler(sig_handler, TRUE); @@ -1119,6 +1175,7 @@ static void _terminate() SAFE_DeleteObject(gFont); SAFE_DeleteObject(gBgBrush); SAFE_DeleteObject(gBgBmp); + ime_wrap_term(); } #ifdef _DEBUG