if(cols == CSI_WndCols(&csi) && rows == CSI_WndRows(&csi))
return;
- SMALL_RECT tmp = { 0,0,0,0 };
- SetConsoleWindowInfo(gStdOut, TRUE, &tmp);
+ //SMALL_RECT tmp = { 0,0,0,0 };
+ //SetConsoleWindowInfo(gStdOut, TRUE, &tmp);
csi.dwSize.X = (SHORT)cols;
csi.srWindow.Left = 0;
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:
}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 */
wc.hbrBackground = CreateSolidBrush(gColorTable[0]);
wc.lpszMenuName = NULL;
wc.lpszClassName = className;
- wc.hIconSm = wc.hIcon;
+ wc.hIconSm = NULL;
if(! RegisterClassEx(&wc))
return(FALSE);
si.hStdOutput = gStdOut;
si.hStdError = gStdErr;
+ if (curdir)
+ if (char *p = strstr((char*)curdir, ":\""))
+ *(p+1) = '\\';
+
if(! CreateProcessA(NULL, buf, NULL, NULL, TRUE,
0, NULL, curdir, &si, &pi)) {
delete [] buf;
return(TRUE);
}
+// for Windows SDK v7.0 \83G\83\89\81[\82ª\94\90¶\82·\82é\8fê\8d\87\82Í\83R\83\81\83\93\83g\83A\83E\83g\81B
+#ifdef _MSC_VER
+#include <winternl.h>
+#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;
/* check */
if(si.dwFlags == backup_flags && si.wShowWindow == backup_show) {
+ // \8fÚ\8d×\82Í\95s\96¾\82¾\82ªSTARTF_TITLEISLINKNAME\82ª\97§\82Á\82Ä\82¢\82é\82Æ\81A
+ // Console\91\8b\89B\82µ\82É\8e¸\94s\82·\82é\82Ì\82Å\8f\9c\8b\8e(Win7-64bit)
+ if (*pflags & STARTF_TITLEISLINKNAME) {
+ *pflags &= ~STARTF_TITLEISLINKNAME;
+ }
*pflags |= STARTF_USESHOWWINDOW;
*pshow = SW_HIDE;
+ bResult = true;
}
AllocConsole();
/* 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);
+ }
+ }
}
/*----------*/
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));
- }
-
- __hide_alloc_console();
-
- while((gConWnd = GetConsoleWindow()) == NULL) {
- Sleep(10);
- }
-
- while(!IsWindowVisible(gConWnd)) {
- Sleep(10);
+ 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)) );
}
- ShowWindow(gConWnd, SW_HIDE);
+ __hide_alloc_console();
SetConsoleTitle(title);
fonts = GetNumberOfConsoleFonts();
if (fonts > MAX_FONTS)
fonts = MAX_FONTS;
-
+
GetConsoleFontInfo(gStdOut, 0, fonts, font);
CONSOLE_FONT minimalFont = { 0, {0, 0}};
for(DWORD i=0;i<fonts;i++){
}
/*----------*/
-static BOOL init_options(ckOpt& opt)
+BOOL init_options(ckOpt& opt)
{
/* create argv */
int i, argc;
return(FALSE);
}
+ /*
wchar_t path[MAX_PATH+1];
GetSystemDirectory(path, MAX_PATH);
SetCurrentDirectory(path);
+ */
return(TRUE);
}
SAFE_DeleteObject(gFont);
SAFE_DeleteObject(gBgBrush);
SAFE_DeleteObject(gBgBmp);
+ ime_wrap_term();
}
#ifdef _DEBUG
return(0);
}
+/* \90V\8bK\83E\83C\83\93\83h\83E\82Ì\8dì\90¬ */
+void makeNewWindow()
+{
+ LPWSTR cd = new TCHAR[MAX_PATH+1];
+ GetCurrentDirectory(MAX_PATH, cd);
+
+ STARTUPINFO si;
+ ZeroMemory(&si, sizeof(si));
+ si.cb = sizeof(si);
+
+ PROCESS_INFORMATION pi;
+ ZeroMemory(&pi, sizeof(pi));
+ if(CreateProcess(NULL, GetCommandLine(), NULL, NULL, FALSE, 0,
+ NULL, NULL, &si, &pi)){
+ // \8eg\97p\82µ\82È\82¢\82Ì\82Å\81C\82·\82®\82É\83N\83\8d\81[\83Y\82µ\82Ä\82æ\82¢
+ CloseHandle(pi.hProcess);
+ CloseHandle(pi.hThread);
+ }
+}
+
/* EOF */