LRESULT CALLBACK funcProc(HWND hwnd, UINT iMessage, WPARAM wParam, LPARAM lParam) { static EDITDATA *ptr; static CCFUNCDATA **funcs[100]; static int funcpos[100]; static int nesting[100]; static int curarg[100]; static int index; static HFONT normal, bold, oldfont; static POINT origin[100]; static HBITMAP leftarrow, rightarrow; int offset; int oldbk, oldfg; LOGFONT lf; PAINTSTRUCT ps; HPEN pen; HBRUSH brush; HDC dc; SIZE size1, size2; RECT r; char * fragments[4]; switch(iMessage) { case WM_CREATE: leftarrow = LoadBitmap(hInstance, "ID_CCLEFTARR"); rightarrow = LoadBitmap(hInstance, "ID_CCRIGHTARR"); lf = systemDialogFont; normal = (HFONT)CreateFontIndirect(&lf); lf.lfWeight = FW_BOLD; bold = CreateFontIndirect(&lf); SetLayeredWindowAttributes(hwnd, TRANSPARENT_COLOR, 0xff, LWA_COLORKEY); break; case WM_USER: funcs[index] = (CCFUNCDATA *)lParam; funcpos[index] = 0; nesting[index] = 0; curarg[index] = 0; index++; if (IsWindowVisible(hwnd)) SetFuncWindowSize(hwnd, normal, bold, origin[index-1], funcs[index-1], funcpos[index-1], curarg[index-1]); break; case WM_USER + 1: { POINTL pt; ptr = (EDITDATA *)lParam; posfromchar((HWND)wParam, ptr, &pt,ptr->selendcharpos); origin[index-1].x = pt.x; origin[index-1].y = pt.y; MapWindowPoints((HWND)wParam, hwndFrame, &origin[index-1], 1); origin[index-1].y += ptr->cd->txtFontHeight; } break; case WM_USER + 2: curarg[index-1] = wParam; SetFuncWindowSize(hwnd, normal, bold, origin[index-1], funcs[index-1], funcpos[index-1], curarg[index-1]); break; case WM_SHOWWINDOW: { if (wParam) { SetFuncWindowSize(hwnd, normal, bold, origin[index-1], funcs[index-1], funcpos[index-1], curarg[index-1]); } else { ccFreeFunctionList(funcs[--index]); if (index) ShowWindow(hwnd, SW_SHOW); } } case WM_USER + 3: if (IsWindowVisible(hwnd)) { switch(wParam) { case VK_DOWN: if (GetFuncCount(funcs[index-1]) > 1) { funcpos[index-1] ++; if (funcpos[index-1] >= GetFuncCount(funcs[index-1])) funcpos[index-1] = 0; SetFuncWindowSize(hwnd, normal, bold, origin[index-1], funcs[index-1], funcpos[index-1], curarg[index-1]); return 0; } case VK_UP: if (GetFuncCount(funcs[index-1]) > 1) { funcpos[index-1] --; if (funcpos[index-1] < 0) funcpos[index-1] = GetFuncCount(funcs[index-1]); SetFuncWindowSize(hwnd, normal, bold, origin[index-1], funcs[index-1], funcpos[index-1], curarg[index-1]); return 0; } case VK_HOME: case VK_END: case VK_PRIOR: case VK_NEXT: if (index == 1) ShowWindow(hwnd, SW_HIDE); else { ccFreeFunctionList(funcs[--index]); SetFuncWindowSize(hwnd, normal, bold, origin[index-1], funcs[index-1], funcpos[index-1], curarg[index-1]); } return 1; case VK_BACK: if (ptr->selendcharpos) switch(ptr->cd->text[ptr->selendcharpos - 1].ch) { case ',': --curarg[index-1]; SetFuncWindowSize(hwnd, normal, bold, origin[index-1], funcs[index-1], funcpos[index-1], curarg[index-1]); return 1; case '(': if (--nesting[index-1] < 0) { if (index == 1) ShowWindow(hwnd, SW_HIDE); else { ccFreeFunctionList(funcs[--index]); SetFuncWindowSize(hwnd, normal, bold, origin[index-1], funcs[index-1], funcpos[index-1], curarg[index-1]); } } break; case ')': ++nesting[index-1]; break; } return 1; break; default: { int key = KeyboardToAscii(wParam, lParam, TRUE); switch(key) { case ',': ++curarg[index-1]; SetFuncWindowSize(hwnd, normal, bold, origin[index-1], funcs[index-1], funcpos[index-1], curarg[index-1]); break; case '(': ++nesting[index-1]; break; case ')': if (--nesting[index-1] < 0) { if (index == 1) ShowWindow(hwnd, SW_HIDE); else { ccFreeFunctionList(funcs[--index]); SetFuncWindowSize(hwnd, normal, bold, origin[index-1], funcs[index-1], funcpos[index-1], curarg[index-1]); } } break; } return 1; break; } } } break; case WM_PAINT: dc = BeginPaint(hwnd, &ps); GetClientRect(hwnd, &r); brush = CreateSolidBrush(TRANSPARENT_COLOR); FillRect(dc, &r, brush); DeleteObject(brush); brush = CreateSolidBrush(RetrieveSysColor(COLOR_INFOBK)); brush = SelectObject(dc, brush); pen = CreatePen(PS_SOLID, 0, 0); pen = SelectObject(dc, pen); RoundRect(dc, r.left, r.top, r.right, r.bottom, 5, 5); brush = SelectObject(dc, brush); DeleteObject(brush); pen = SelectObject(dc, pen); DeleteObject(pen); if (GetFragments(funcs[index-1], funcpos[index-1], curarg[index-1], fragments)) { SIZE sz; HDC *memDC = CreateCompatibleDC(dc); int offset = 3 + GetSystemMetrics(SM_CXBORDER); normal = SelectObject(dc, normal); oldbk = SetBkColor(dc, RetrieveSysColor(COLOR_INFOBK)); oldfg = SetTextColor(dc, RetrieveSysColor(COLOR_INFOTEXT)); GetTextExtentPoint32(dc, fragments[0], strlen(fragments[0]), &sz); TextOut(dc, offset+12, 2, fragments[0], strlen(fragments[0])); leftarrow = SelectObject(memDC, leftarrow); TransparentBlt(dc, offset+2, ((sz.cy+3)-10)/2, 10, 10, memDC, 0, 0, 10, 10, 0xc0c0c0); offset += 12 + sz.cx; leftarrow = SelectObject(memDC, leftarrow); rightarrow = SelectObject(memDC, rightarrow); TransparentBlt(dc, offset+2, ((sz.cy+3)-10)/2, 10, 10, memDC, 0, 0, 10, 10, 0xc0c0c0); rightarrow = SelectObject(memDC, rightarrow); offset += 12 + 4; GetTextExtentPoint32(dc, fragments[1], strlen(fragments[1]), &sz); TextOut(dc, offset, 2, fragments[1], strlen(fragments[1])); offset += sz.cx; if (fragments[2]) { normal = SelectObject(dc, normal); bold = SelectObject(dc, bold); GetTextExtentPoint32(dc, fragments[2], strlen(fragments[2]), &sz); TextOut(dc, offset, 2, fragments[2], strlen(fragments[2])); offset += sz.cx; bold = SelectObject(dc, bold); normal = SelectObject(dc, normal); } GetTextExtentPoint32(dc, fragments[3], strlen(fragments[3]), &sz); TextOut(dc, offset, 2, fragments[3], strlen(fragments[3])); offset += sz.cx; DeleteDC(memDC); normal = SelectObject(dc, normal); oldbk = SetBkColor(dc, oldbk); oldfg = SetTextColor(dc, oldfg); FreeFragments(fragments); } EndPaint(hwnd, &ps); return 0; } return DefWindowProc(hwnd, iMessage, wParam, lParam); }
static void ProcessException( EXCEPTION_POINTERS* pExceptionPtrs ) { int rc; UINT uiMBFlags = 0 | MB_SYSTEMMODAL | MB_TOPMOST | MB_SETFOREGROUND ; HWND hwndMBOwner = FindConsoleHandle(); if (!hwndMBOwner || !IsWindowVisible(hwndMBOwner)) hwndMBOwner = GetDesktopWindow(); if ( !g_pfnMiniDumpWriteDumpFunc ) { MsgBox ( hwndMBOwner, _T("The creation of a crash dump for analysis by the Hercules ") _T("development team is NOT possible\nbecause the required 'DbgHelp.dll' ") _T("is missing or is not installed or was otherwise not located.") ,_T("OOPS! Hercules has crashed!"), uiMBFlags | MB_ICONERROR | MB_OK ,0 // (default/neutral language) ,(15 * 1000) // (timeout == 15 seconds) ); return; } if ( IDYES == ( rc = MsgBox ( hwndMBOwner, _T("The creation of a crash dump for further analysis by ") _T("the Hercules development team is strongly suggested.\n\n") _T("Would you like to create a crash dump for ") _T("the Hercules development team to analyze?") ,_T("OOPS! Hercules has crashed!"), uiMBFlags | MB_ICONERROR | MB_YESNO ,0 // (default/neutral language) ,(10 * 1000) // (timeout == 10 seconds) )) || MB_TIMEDOUT == rc ) { if ( CreateMiniDump( pExceptionPtrs ) && MB_TIMEDOUT != rc ) { MsgBox ( hwndMBOwner, _T("Please send the dump to the Hercules development team for analysis.") ,_T("Dump Complete"), uiMBFlags | MB_ICONEXCLAMATION | MB_OK ,0 // (default/neutral language) ,(5 * 1000) // (timeout == 5 seconds) ); } } }
int fnGetWindowVisibleState(HWND hWnd, int iStepX, int iStepY) { RECT rc, rcWin, rcWorkArea; POINT pt; register int i, j, width, height, iCountedDots = 0, iNotCoveredDots = 0; BOOL bPartiallyCovered = FALSE; HWND hAux = 0; if (hWnd == NULL) { SetLastError(0x00000006); //Wrong handle return -1; } //Some defaults now. The routine is designed for thin and tall windows. if (iStepX <= 0) iStepX = 4; if (iStepY <= 0) iStepY = 16; if (IsIconic(hWnd) || !IsWindowVisible(hWnd)) return GWVS_HIDDEN; if (CallService(MS_CLIST_DOCKINGISDOCKED, 0, 0)) return GWVS_VISIBLE; GetWindowRect(hWnd, &rcWin); SystemParametersInfo(SPI_GETWORKAREA, 0, &rcWorkArea, FALSE); HMONITOR hMon = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); MONITORINFO mi; mi.cbSize = sizeof(mi); if (GetMonitorInfo(hMon, &mi)) rcWorkArea = mi.rcWork; IntersectRect(&rc, &rcWin, &rcWorkArea); width = rc.right - rc.left; height = rc.bottom - rc.top; for (i = rc.top; i < rc.bottom; i += (height / iStepY)) { pt.y = i; for (j = rc.left; j < rc.right; j += (width / iStepX)) { pt.x = j; hAux = WindowFromPoint(pt); while (GetParent(hAux) != NULL) hAux = GetParent(hAux); if (hAux != hWnd && hAux != NULL) //There's another window! bPartiallyCovered = TRUE; else iNotCoveredDots++; //Let's count the not covered dots. iCountedDots++; //Let's keep track of how many dots we checked. } } if (iNotCoveredDots == iCountedDots) //Every dot was not covered: the window is visible. return GWVS_VISIBLE; if (iNotCoveredDots == 0) //They're all covered! return GWVS_COVERED; //There are dots which are visible, but they are not as many as the ones we counted: it's partially covered. return GWVS_PARTIALLY_COVERED; }
static void test_word_wrap(void) { HWND hwnd; POINTL point = {0, 60}; /* This point must be below the first line */ const char *text = "Must be long enough to test line wrapping"; DWORD dwCommonStyle = WS_VISIBLE|WS_POPUP|WS_VSCROLL|ES_MULTILINE; int res, pos, lines, prevlines, reflines[3]; /* Test the effect of WS_HSCROLL and ES_AUTOHSCROLL styles on wrapping * when specified on window creation and set later. */ hwnd = CreateWindow(RICHEDIT_CLASS10A, NULL, dwCommonStyle, 0, 0, 200, 80, NULL, NULL, hmoduleRichEdit, NULL); ok(hwnd != NULL, "error: %d\n", (int) GetLastError()); res = SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) text); ok(res, "WM_SETTEXT failed.\n"); pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point); ok(pos, "pos=%d indicating no word wrap when it is expected.\n", pos); lines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); ok(lines > 1, "Line was expected to wrap (lines=%d).\n", lines); SetWindowLong(hwnd, GWL_STYLE, dwCommonStyle|WS_HSCROLL|ES_AUTOHSCROLL); pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point); ok(pos, "pos=%d indicating no word wrap when it is expected.\n", pos); DestroyWindow(hwnd); hwnd = CreateWindow(RICHEDIT_CLASS10A, NULL, dwCommonStyle|WS_HSCROLL, 0, 0, 200, 80, NULL, NULL, hmoduleRichEdit, NULL); ok(hwnd != NULL, "error: %d\n", (int) GetLastError()); res = SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) text); ok(res, "WM_SETTEXT failed.\n"); pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point); ok(pos, "pos=%d indicating no word wrap when it is expected.\n", pos); lines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); ok(lines > 1, "Line was expected to wrap (lines=%d).\n", lines); SetWindowLong(hwnd, GWL_STYLE, dwCommonStyle|WS_HSCROLL|ES_AUTOHSCROLL); pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point); ok(pos, "pos=%d indicating no word wrap when it is expected.\n", pos); DestroyWindow(hwnd); hwnd = CreateWindow(RICHEDIT_CLASS10A, NULL, dwCommonStyle|ES_AUTOHSCROLL, 0, 0, 200, 80, NULL, NULL, hmoduleRichEdit, NULL); ok(hwnd != NULL, "error: %d\n", (int) GetLastError()); res = SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) text); ok(res, "WM_SETTEXT failed.\n"); pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point); ok(!pos || broken(pos == lstrlen(text)), /* Win9x, WinME and NT4 */ "pos=%d indicating word wrap when none is expected.\n", pos); lines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); ok(lines == 1, "Line was not expected to wrap (lines=%d).\n", lines); SetWindowLong(hwnd, GWL_STYLE, dwCommonStyle); pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point); ok(!pos || broken(pos == lstrlen(text)), /* Win9x, WinME and NT4 */ "pos=%d indicating word wrap when none is expected.\n", pos); lines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); ok(lines == 1, "Line was not expected to wrap (lines=%d).\n", lines); DestroyWindow(hwnd); hwnd = CreateWindow(RICHEDIT_CLASS10A, NULL, dwCommonStyle|WS_HSCROLL|ES_AUTOHSCROLL, 0, 0, 200, 80, NULL, NULL, hmoduleRichEdit, NULL); ok(hwnd != NULL, "error: %d\n", (int) GetLastError()); res = SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) text); ok(res, "WM_SETTEXT failed.\n"); pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point); ok(!pos || broken(pos == lstrlen(text)), /* Win9x, WinME and NT4 */ "pos=%d indicating word wrap when none is expected.\n", pos); lines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); ok(lines == 1, "Line was not expected to wrap (lines=%d).\n", lines); SetWindowLong(hwnd, GWL_STYLE, dwCommonStyle); pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point); ok(!pos || broken(pos == lstrlen(text)), /* Win9x, WinME and NT4 */ "pos=%d indicating word wrap when none is expected.\n", pos); lines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); ok(lines == 1, "Line was not expected to wrap (lines=%d).\n", lines); /* Test the effect of EM_SETTARGETDEVICE on word wrap. */ res = SendMessage(hwnd, EM_SETTARGETDEVICE, 0, 1); ok(res, "EM_SETTARGETDEVICE failed (returned %d).\n", res); pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point); ok(!pos || broken(pos == lstrlen(text)), /* Win9x, WinME and NT4 */ "pos=%d indicating word wrap when none is expected.\n", pos); lines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); ok(lines == 1, "Line was not expected to wrap (lines=%d).\n", lines); res = SendMessage(hwnd, EM_SETTARGETDEVICE, 0, 0); ok(res, "EM_SETTARGETDEVICE failed (returned %d).\n", res); pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point); ok(pos, "pos=%d indicating no word wrap when it is expected.\n", pos); DestroyWindow(hwnd); /* First lets see if the text would wrap normally (needed for reference) */ hwnd = CreateWindow(RICHEDIT_CLASS10A, NULL, dwCommonStyle, 0, 0, 200, 80, NULL, NULL, hmoduleRichEdit, NULL); ok(hwnd != NULL, "error: %d\n", (int) GetLastError()); ok(IsWindowVisible(hwnd), "Window should be visible.\n"); res = SendMessage(hwnd, EM_REPLACESEL, FALSE, (LPARAM) text); ok(res, "EM_REPLACESEL failed.\n"); /* Should have wrapped */ reflines[0] = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); ok(reflines[0] > 1, "Line was expected to wrap (%d lines).\n", reflines[0]); /* Resize the window to fit the line */ MoveWindow(hwnd, 0, 0, 600, 80, TRUE); /* Text should not be wrapped */ reflines[1] = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); ok(reflines[1] == 1, "Line wasn't expected to wrap (%d lines).\n", reflines[1]); /* Resize the window again to make sure the line wraps again */ MoveWindow(hwnd, 0, 0, 10, 80, TRUE); reflines[2] = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); ok(reflines[2] > 1, "Line was expected to wrap (%d lines).\n", reflines[2]); DestroyWindow(hwnd); /* Same test with redraw disabled */ hwnd = CreateWindow(RICHEDIT_CLASS10A, NULL, dwCommonStyle, 0, 0, 200, 80, NULL, NULL, hmoduleRichEdit, NULL); ok(hwnd != NULL, "error: %d\n", (int) GetLastError()); ok(IsWindowVisible(hwnd), "Window should be visible.\n"); /* Redraw is disabled by making the window invisible. */ SendMessage(hwnd, WM_SETREDRAW, FALSE, 0); ok(!IsWindowVisible(hwnd), "Window shouldn't be visible.\n"); res = SendMessage(hwnd, EM_REPLACESEL, FALSE, (LPARAM) text); ok(res, "EM_REPLACESEL failed.\n"); /* Should have wrapped */ prevlines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); ok(prevlines == reflines[0], "Line was expected to wrap (%d lines).\n", prevlines); /* Resize the window to fit the line, no change to the number of lines */ MoveWindow(hwnd, 0, 0, 600, 80, TRUE); lines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); todo_wine ok(lines == prevlines || broken(lines == reflines[1]), /* Win98, WinME and NT4 */ "Expected no change in the number of lines\n"); /* Resize the window again to make sure the line wraps again */ MoveWindow(hwnd, 0, 0, 10, 80, TRUE); lines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0); todo_wine ok(lines == prevlines || broken(lines == reflines[2]), /* Win98, WinME and NT4 */ "Expected no change in the number of lines\n"); DestroyWindow(hwnd); }
INT_PTR CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_INITDIALOG: { char tmp[32]; SetWindowLongPtr(hwnd,GWLP_USERDATA,(LPARAM)lParam); switch (((struct DBsetting*)lParam)->dbv.type) { case DBVT_BYTE: ShowWindow(GetDlgItem(hwnd, IDC_STRING),SW_HIDE); if (!((struct DBsetting*)lParam)->setting[0]) { SetWindowText(hwnd, Translate("New BYTE value")); } else { SetWindowText(hwnd, Translate("Edit BYTE value")); SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); SetDlgItemText(hwnd, IDC_SETTINGVALUE, itoa(((struct DBsetting*)lParam)->dbv.bVal, tmp, 10)); } CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, CHK_DECIMAL); CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, CHK_BYTE); break; case DBVT_WORD: ShowWindow(GetDlgItem(hwnd, IDC_STRING),SW_HIDE); if (!((struct DBsetting*)lParam)->setting[0]) { SetWindowText(hwnd, Translate("New WORD value")); } else { SetWindowText(hwnd, Translate("Edit WORD value")); SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); SetDlgItemText(hwnd, IDC_SETTINGVALUE, itoa(((struct DBsetting*)lParam)->dbv.wVal, tmp, 10)); } CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, CHK_DECIMAL); CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, CHK_WORD); break; case DBVT_DWORD: ShowWindow(GetDlgItem(hwnd, IDC_STRING),SW_HIDE); if (!((struct DBsetting*)lParam)->setting[0]) { SetWindowText(hwnd, Translate("New DWORD value")); } else { char text[32]; SetWindowText(hwnd, Translate("Edit DWORD value")); SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); mir_snprintf(text, SIZEOF(text), "%X", ((struct DBsetting*)lParam)->dbv.dVal); SetDlgItemText(hwnd, IDC_SETTINGVALUE, text); } CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, CHK_HEX); CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, CHK_DWORD); break; case DBVT_ASCIIZ: ShowWindow(GetDlgItem(hwnd, IDC_STRING),SW_SHOW); ShowWindow(GetDlgItem(hwnd, IDC_SETTINGVALUE),SW_HIDE); ShowWindow(GetDlgItem(hwnd, CHK_HEX),SW_HIDE); ShowWindow(GetDlgItem(hwnd, CHK_DECIMAL),SW_HIDE); ShowWindow(GetDlgItem(hwnd, GRP_BASE),SW_HIDE); ShowWindow(GetDlgItem(hwnd, GRP_TYPE),SW_HIDE); ShowWindow(GetDlgItem(hwnd, CHK_BYTE),SW_HIDE); ShowWindow(GetDlgItem(hwnd, CHK_WORD),SW_HIDE); ShowWindow(GetDlgItem(hwnd, CHK_DWORD),SW_HIDE); ShowWindow(GetDlgItem(hwnd, CHK_STRING),SW_HIDE); if (!((struct DBsetting*)lParam)->setting[0]) { SetWindowText(hwnd, Translate("New STRING value")); } else { SetWindowText(hwnd, Translate("Edit STRING value")); SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); SetDlgItemText(hwnd, IDC_STRING, ((struct DBsetting*)lParam)->dbv.pszVal); } break; case DBVT_UTF8: ShowWindow(GetDlgItem(hwnd, IDC_STRING),SW_SHOW); ShowWindow(GetDlgItem(hwnd, IDC_SETTINGVALUE),SW_HIDE); ShowWindow(GetDlgItem(hwnd, CHK_HEX),SW_HIDE); ShowWindow(GetDlgItem(hwnd, CHK_DECIMAL),SW_HIDE); ShowWindow(GetDlgItem(hwnd, GRP_BASE),SW_HIDE); ShowWindow(GetDlgItem(hwnd, GRP_TYPE),SW_HIDE); ShowWindow(GetDlgItem(hwnd, CHK_BYTE),SW_HIDE); ShowWindow(GetDlgItem(hwnd, CHK_WORD),SW_HIDE); ShowWindow(GetDlgItem(hwnd, CHK_DWORD),SW_HIDE); ShowWindow(GetDlgItem(hwnd, CHK_STRING),SW_HIDE); if (!((struct DBsetting*)lParam)->setting[0]) { SetWindowText(hwnd, Translate("New UNICODE value")); } else { char *tmp = (((struct DBsetting*)lParam)->dbv.pszVal); if (UOS) { int length = (int)strlen(tmp) + 1; WCHAR *wc = (WCHAR*)_malloca(length*sizeof(WCHAR)); MultiByteToWideChar(CP_UTF8, 0, tmp, -1, wc, length); SendMessageW(GetDlgItem(hwnd, IDC_STRING), WM_SETTEXT, 0, (LPARAM)wc); } else { // convert from UTF8 SetDlgItemText(hwnd, IDC_STRING, tmp); } SetWindowText(hwnd, Translate("Edit UNICODE value")); SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); } break; case DBVT_BLOB: { ShowWindow(GetDlgItem(hwnd, IDC_STRING),SW_HIDE); ShowWindow(GetDlgItem(hwnd, IDC_SETTINGVALUE),SW_HIDE); ShowWindow(GetDlgItem(hwnd, IDC_BLOB),SW_SHOW); if (!((struct DBsetting*)lParam)->setting[0]) { SetWindowText(hwnd, Translate("New BLOB value")); } else { int j; char tmp[16]; int len = ((struct DBsetting*)lParam)->dbv.cpbVal; char *data = (char*)_malloca(3*(len+1)+10); BYTE *p = ((struct DBsetting*)lParam)->dbv.pbVal; if (!data) return TRUE; data[0] = '\0'; for(j=0; j<len; j++) { mir_snprintf(tmp, SIZEOF(tmp), "%02X ", (BYTE)p[j]); strcat(data, tmp); } SetWindowText(hwnd, Translate("Edit BLOB value")); SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); SetDlgItemText(hwnd, IDC_BLOB, data); } ShowWindow(GetDlgItem(hwnd, CHK_HEX),SW_HIDE); ShowWindow(GetDlgItem(hwnd, CHK_DECIMAL),SW_HIDE); ShowWindow(GetDlgItem(hwnd, GRP_BASE),SW_HIDE); ShowWindow(GetDlgItem(hwnd, GRP_TYPE),SW_HIDE); ShowWindow(GetDlgItem(hwnd, CHK_BYTE),SW_HIDE); ShowWindow(GetDlgItem(hwnd, CHK_WORD),SW_HIDE); ShowWindow(GetDlgItem(hwnd, CHK_DWORD),SW_HIDE); ShowWindow(GetDlgItem(hwnd, CHK_STRING),SW_HIDE); } break; default: return TRUE; } TranslateDialogDefault(hwnd); } return TRUE; case WM_COMMAND: switch(LOWORD(wParam)) { case CHK_BYTE: case CHK_WORD: case CHK_DWORD: EnableWindow(GetDlgItem(hwnd, CHK_HEX),1); EnableWindow(GetDlgItem(hwnd, CHK_DECIMAL),1); CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, LOWORD(wParam)); break; case CHK_STRING: EnableWindow(GetDlgItem(hwnd, CHK_HEX),0); EnableWindow(GetDlgItem(hwnd, CHK_DECIMAL),0); CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, LOWORD(wParam)); break; case CHK_HEX: case CHK_DECIMAL: CheckRadioButton(hwnd,CHK_HEX, CHK_DECIMAL, LOWORD(wParam)); { char *setting, temp[32]; int settingLength, tmp; settingLength = GetWindowTextLength(GetDlgItem(hwnd, IDC_SETTINGVALUE)); if (settingLength) { setting = (char*)_malloca(settingLength + 1); if (setting) { // havta convert it with sprintf() GetWindowText(GetDlgItem(hwnd, IDC_SETTINGVALUE), setting, settingLength+1); if (LOWORD(wParam) == CHK_DECIMAL && IsDlgButtonChecked(hwnd, CHK_DECIMAL)) { sscanf(setting, "%X", &tmp); mir_snprintf(temp, SIZEOF(temp), "%ld", tmp); } else { sscanf(setting, "%d", &tmp); mir_snprintf(temp, SIZEOF(temp), "%X", tmp); } SetWindowText(GetDlgItem(hwnd, IDC_SETTINGVALUE), temp); } } } break; case IDOK: { struct DBsetting *dbsetting = (struct DBsetting*)GetWindowLongPtr(hwnd,GWLP_USERDATA); char *setting, *value; int settingLength, valueLength, valueID = IDC_SETTINGVALUE; settingLength = GetWindowTextLength(GetDlgItem(hwnd, IDC_SETTINGNAME)); if (IsWindowVisible(GetDlgItem(hwnd,IDC_STRING))) valueID = IDC_STRING; else if (IsWindowVisible(GetDlgItem(hwnd,IDC_SETTINGVALUE))) valueID = IDC_SETTINGVALUE; else if (IsWindowVisible(GetDlgItem(hwnd,IDC_BLOB))) valueID = IDC_BLOB; else break; valueLength = GetWindowTextLength(GetDlgItem(hwnd, valueID)); if (dbsetting->dbv.type == DBVT_UTF8 && UOS) valueLength *= sizeof(WCHAR); if (settingLength) { int settingValue; setting = (char*)_malloca(settingLength + 1); if (valueLength) value = (char*)_malloca(valueLength + 2); else value = (char*)_malloca(2); if (!setting || !value) { msg(Translate("Couldnt allocate enough memory!"), modFullname); DestroyWindow(hwnd); break; } GetWindowText(GetDlgItem(hwnd, IDC_SETTINGNAME), setting, settingLength+1); if (valueLength) { if (dbsetting->dbv.type == DBVT_UTF8 && UOS) SendMessageW(GetDlgItem(hwnd, valueID), WM_GETTEXT, valueLength+2, (LPARAM)value); else GetWindowText(GetDlgItem(hwnd, valueID), value, valueLength+1); } else if (IsWindowVisible(GetDlgItem(hwnd,IDC_STRING)) || (saveAsType(hwnd)==3)) memcpy(value,"\0\0",2); else strcpy(value,"0"); // delete the old setting if (mir_strcmp(setting, dbsetting->setting) && dbsetting->setting && (dbsetting->setting)[0] != 0) DBDeleteContactSetting(dbsetting->hContact, dbsetting->module, dbsetting->setting); // delete the setting if we are saving as a different type switch (dbsetting->dbv.type) { case DBVT_BYTE: if (saveAsType(hwnd) != 0) DBDeleteContactSetting(dbsetting->hContact, dbsetting->module, setting); break; case DBVT_WORD: if (saveAsType(hwnd) != 1) DBDeleteContactSetting(dbsetting->hContact, dbsetting->module, setting); break; case DBVT_DWORD: if (saveAsType(hwnd) != 2) DBDeleteContactSetting(dbsetting->hContact, dbsetting->module, setting); break; //case DBVT_ASCIIZ: //DBWriteContactSettingString(dbsetting->hContact, dbsetting->module, setting, value); //break; } // write the setting switch (saveAsType(hwnd)) { case 0: if (IsDlgButtonChecked(hwnd, CHK_HEX)) sscanf(value, "%x", &settingValue); else sscanf(value, "%d", &settingValue); DBWriteContactSettingByte(dbsetting->hContact, dbsetting->module, setting, (BYTE)settingValue); break; case 1: if (IsDlgButtonChecked(hwnd, CHK_HEX)) sscanf(value, "%x", &settingValue); else sscanf(value, "%d", &settingValue); DBWriteContactSettingWord(dbsetting->hContact, dbsetting->module, setting, (WORD)settingValue); break; case 2: if (IsDlgButtonChecked(hwnd, CHK_HEX)) sscanf(value, "%x", &settingValue); else sscanf(value, "%d", &settingValue); DBWriteContactSettingDword(dbsetting->hContact, dbsetting->module, setting, (DWORD)settingValue); break; case 3: if (dbsetting->dbv.type == DBVT_UTF8) { if (UOS) DBWriteContactSettingWString(dbsetting->hContact, dbsetting->module, setting, (WCHAR*)value); else DBWriteContactSettingStringUtf(dbsetting->hContact, dbsetting->module, setting, value); } else if (dbsetting->dbv.type == DBVT_BLOB) WriteBlobFromString(dbsetting->hContact,dbsetting->module,setting,value,valueLength); else if (dbsetting->dbv.type == DBVT_ASCIIZ) DBWriteContactSettingString(dbsetting->hContact, dbsetting->module, setting, value); break; } } } // fall through case IDCANCEL: { struct DBsetting *dbsetting = (struct DBsetting*)GetWindowLongPtr(hwnd,GWLP_USERDATA); mir_free(dbsetting->module); mir_free(dbsetting->setting); mir_free(dbsetting); DestroyWindow(hwnd); } break; } break; } return 0; }
BOOL IsSipButtonVisible() { return IsWindowVisible(FindWindow(L"MS_SIPBUTTON", NULL)); };
INT_PTR CALLBACK WepWindowsPageProc( _In_ HWND hwndDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) { PWINDOWS_CONTEXT context; LPPROPSHEETPAGE propSheetPage; PPH_PROCESS_PROPPAGECONTEXT propPageContext; PPH_PROCESS_ITEM processItem; if (PhPropPageDlgProcHeader(hwndDlg, uMsg, lParam, &propSheetPage, &propPageContext, &processItem)) { context = propPageContext->Context; } else { return FALSE; } switch (uMsg) { case WM_INITDIALOG: { context->TreeNewHandle = GetDlgItem(hwndDlg, IDC_LIST); context->SearchBoxHandle = GetDlgItem(hwndDlg, IDC_SEARCHEDIT); PhCreateSearchControl(hwndDlg, context->SearchBoxHandle, L"Search Windows (Ctrl+K)"); WeInitializeWindowTree(hwndDlg, context->TreeNewHandle, &context->TreeContext); PhRegisterDialog(hwndDlg); PhInitializeLayoutManager(&context->LayoutManager, hwndDlg); PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDC_SEARCHEDIT), NULL, PH_ANCHOR_TOP | PH_ANCHOR_RIGHT); PhAddLayoutItem(&context->LayoutManager, GetDlgItem(hwndDlg, IDC_LIST), NULL, PH_ANCHOR_ALL); WepRefreshWindows(context); } break; case WM_SHOWWINDOW: { if (PhBeginPropPageLayout(hwndDlg, propPageContext)) PhEndPropPageLayout(hwndDlg, propPageContext); } break; case WM_DESTROY: { PhDeleteLayoutManager(&context->LayoutManager); PhUnregisterDialog(hwndDlg); WeDeleteWindowTree(&context->TreeContext); WepDeleteWindowSelector(&context->Selector); PhFree(context); } break; case WM_COMMAND: { switch (GET_WM_COMMAND_CMD(wParam, lParam)) { case EN_CHANGE: { PPH_STRING newSearchboxText; if (GET_WM_COMMAND_HWND(wParam, lParam) != context->SearchBoxHandle) break; newSearchboxText = PH_AUTO(PhGetWindowText(context->SearchBoxHandle)); if (!PhEqualString(context->TreeContext.SearchboxText, newSearchboxText, FALSE)) { PhSwapReference(&context->TreeContext.SearchboxText, newSearchboxText); if (!PhIsNullOrEmptyString(context->TreeContext.SearchboxText)) WeExpandAllWindowNodes(&context->TreeContext, TRUE); PhApplyTreeNewFilters(&context->TreeContext.FilterSupport); TreeNew_NodesStructured(context->TreeNewHandle); // PhInvokeCallback(&SearchChangedEvent, SearchboxText); } } break; } switch (GET_WM_COMMAND_ID(wParam, lParam)) { case IDC_REFRESH: WepRefreshWindows(context); break; case ID_SHOWCONTEXTMENU: { PPH_TREENEW_CONTEXT_MENU contextMenuEvent = (PPH_TREENEW_CONTEXT_MENU)lParam; PWE_WINDOW_NODE *windows; ULONG numberOfWindows; PPH_EMENU menu; PPH_EMENU selectedItem; WeGetSelectedWindowNodes( &context->TreeContext, &windows, &numberOfWindows ); if (numberOfWindows != 0) { menu = PhCreateEMenu(); PhLoadResourceEMenuItem(menu, PluginInstance->DllBase, MAKEINTRESOURCE(IDR_WINDOW), 0); PhInsertCopyCellEMenuItem(menu, ID_WINDOW_COPY, context->TreeNewHandle, contextMenuEvent->Column); PhSetFlagsEMenuItem(menu, ID_WINDOW_PROPERTIES, PH_EMENU_DEFAULT, PH_EMENU_DEFAULT); if (numberOfWindows == 1) { WINDOWPLACEMENT placement = { sizeof(placement) }; BYTE alpha; ULONG flags; ULONG i; ULONG id; // State GetWindowPlacement(windows[0]->WindowHandle, &placement); if (placement.showCmd == SW_MINIMIZE) PhSetFlagsEMenuItem(menu, ID_WINDOW_MINIMIZE, PH_EMENU_DISABLED, PH_EMENU_DISABLED); else if (placement.showCmd == SW_MAXIMIZE) PhSetFlagsEMenuItem(menu, ID_WINDOW_MAXIMIZE, PH_EMENU_DISABLED, PH_EMENU_DISABLED); else if (placement.showCmd == SW_NORMAL) PhSetFlagsEMenuItem(menu, ID_WINDOW_RESTORE, PH_EMENU_DISABLED, PH_EMENU_DISABLED); // Visible PhSetFlagsEMenuItem(menu, ID_WINDOW_VISIBLE, PH_EMENU_CHECKED, (GetWindowLong(windows[0]->WindowHandle, GWL_STYLE) & WS_VISIBLE) ? PH_EMENU_CHECKED : 0); // Enabled PhSetFlagsEMenuItem(menu, ID_WINDOW_ENABLED, PH_EMENU_CHECKED, !(GetWindowLong(windows[0]->WindowHandle, GWL_STYLE) & WS_DISABLED) ? PH_EMENU_CHECKED : 0); // Always on Top PhSetFlagsEMenuItem(menu, ID_WINDOW_ALWAYSONTOP, PH_EMENU_CHECKED, (GetWindowLong(windows[0]->WindowHandle, GWL_EXSTYLE) & WS_EX_TOPMOST) ? PH_EMENU_CHECKED : 0); // Opacity if (GetLayeredWindowAttributes(windows[0]->WindowHandle, NULL, &alpha, &flags)) { if (!(flags & LWA_ALPHA)) alpha = 255; } else { alpha = 255; } if (alpha == 255) { id = ID_OPACITY_OPAQUE; } else { id = 0; // Due to integer division, we cannot use simple arithmetic to calculate which menu item to check. for (i = 0; i < 10; i++) { if (alpha == (BYTE)(255 * (i + 1) / 10)) { id = ID_OPACITY_10 + i; break; } } } if (id != 0) { PhSetFlagsEMenuItem(menu, id, PH_EMENU_CHECKED | PH_EMENU_RADIOCHECK, PH_EMENU_CHECKED | PH_EMENU_RADIOCHECK); } } else { PhSetFlagsAllEMenuItems(menu, PH_EMENU_DISABLED, PH_EMENU_DISABLED); PhSetFlagsEMenuItem(menu, ID_WINDOW_COPY, PH_EMENU_DISABLED, 0); } selectedItem = PhShowEMenu( menu, hwndDlg, PH_EMENU_SHOW_SEND_COMMAND | PH_EMENU_SHOW_LEFTRIGHT, PH_ALIGN_LEFT | PH_ALIGN_TOP, contextMenuEvent->Location.x, contextMenuEvent->Location.y ); if (selectedItem && selectedItem->Id != -1) { BOOLEAN handled = FALSE; handled = PhHandleCopyCellEMenuItem(selectedItem); } PhDestroyEMenu(menu); } } break; case ID_WINDOW_BRINGTOFRONT: { PWE_WINDOW_NODE selectedNode; if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext)) { WINDOWPLACEMENT placement = { sizeof(placement) }; GetWindowPlacement(selectedNode->WindowHandle, &placement); if (placement.showCmd == SW_MINIMIZE) ShowWindowAsync(selectedNode->WindowHandle, SW_RESTORE); else SetForegroundWindow(selectedNode->WindowHandle); } } break; case ID_WINDOW_RESTORE: { PWE_WINDOW_NODE selectedNode; if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext)) { ShowWindowAsync(selectedNode->WindowHandle, SW_RESTORE); } } break; case ID_WINDOW_MINIMIZE: { PWE_WINDOW_NODE selectedNode; if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext)) { ShowWindowAsync(selectedNode->WindowHandle, SW_MINIMIZE); } } break; case ID_WINDOW_MAXIMIZE: { PWE_WINDOW_NODE selectedNode; if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext)) { ShowWindowAsync(selectedNode->WindowHandle, SW_MAXIMIZE); } } break; case ID_WINDOW_CLOSE: { PWE_WINDOW_NODE selectedNode; if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext)) { PostMessage(selectedNode->WindowHandle, WM_CLOSE, 0, 0); } } break; case ID_WINDOW_VISIBLE: { PWE_WINDOW_NODE selectedNode; if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext)) { if (IsWindowVisible(selectedNode->WindowHandle)) { selectedNode->WindowVisible = FALSE; ShowWindowAsync(selectedNode->WindowHandle, SW_HIDE); } else { selectedNode->WindowVisible = TRUE; ShowWindowAsync(selectedNode->WindowHandle, SW_SHOW); } PhInvalidateTreeNewNode(&selectedNode->Node, TN_CACHE_COLOR); TreeNew_InvalidateNode(context->TreeNewHandle, &selectedNode->Node); } } break; case ID_WINDOW_ENABLED: { PWE_WINDOW_NODE selectedNode; if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext)) { EnableWindow(selectedNode->WindowHandle, !IsWindowEnabled(selectedNode->WindowHandle)); } } break; case ID_WINDOW_ALWAYSONTOP: { PWE_WINDOW_NODE selectedNode; if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext)) { LOGICAL topMost; topMost = GetWindowLong(selectedNode->WindowHandle, GWL_EXSTYLE) & WS_EX_TOPMOST; SetWindowPos(selectedNode->WindowHandle, topMost ? HWND_NOTOPMOST : HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); } } break; case ID_OPACITY_10: case ID_OPACITY_20: case ID_OPACITY_30: case ID_OPACITY_40: case ID_OPACITY_50: case ID_OPACITY_60: case ID_OPACITY_70: case ID_OPACITY_80: case ID_OPACITY_90: case ID_OPACITY_OPAQUE: { PWE_WINDOW_NODE selectedNode; if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext)) { ULONG opacity; opacity = ((ULONG)LOWORD(wParam) - ID_OPACITY_10) + 1; if (opacity == 10) { // Remove the WS_EX_LAYERED bit since it is not needed. PhSetWindowExStyle(selectedNode->WindowHandle, WS_EX_LAYERED, 0); RedrawWindow(selectedNode->WindowHandle, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); } else { // Add the WS_EX_LAYERED bit so opacity will work. PhSetWindowExStyle(selectedNode->WindowHandle, WS_EX_LAYERED, WS_EX_LAYERED); SetLayeredWindowAttributes(selectedNode->WindowHandle, 0, (BYTE)(255 * opacity / 10), LWA_ALPHA); } } } break; case ID_WINDOW_HIGHLIGHT: { PWE_WINDOW_NODE selectedNode; if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext)) { if (context->HighlightingWindow) { if (context->HighlightingWindowCount & 1) WeInvertWindowBorder(context->HighlightingWindow); } context->HighlightingWindow = selectedNode->WindowHandle; context->HighlightingWindowCount = 10; SetTimer(hwndDlg, 9, 100, NULL); } } break; case ID_WINDOW_GOTOTHREAD: { PWE_WINDOW_NODE selectedNode; PPH_PROCESS_ITEM processItem; PPH_PROCESS_PROPCONTEXT propContext; if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext)) { if (processItem = PhReferenceProcessItem(selectedNode->ClientId.UniqueProcess)) { if (propContext = PhCreateProcessPropContext(WE_PhMainWndHandle, processItem)) { PhSetSelectThreadIdProcessPropContext(propContext, selectedNode->ClientId.UniqueThread); PhShowProcessProperties(propContext); PhDereferenceObject(propContext); } PhDereferenceObject(processItem); } else { PhShowError(hwndDlg, L"The process does not exist."); } } } break; case ID_WINDOW_PROPERTIES: { PWE_WINDOW_NODE selectedNode; if (selectedNode = WeGetSelectedWindowNode(&context->TreeContext)) WeShowWindowProperties(hwndDlg, selectedNode->WindowHandle); } break; case ID_WINDOW_COPY: { PPH_STRING text; text = PhGetTreeNewText(context->TreeNewHandle, 0); PhSetClipboardString(hwndDlg, &text->sr); PhDereferenceObject(text); } break; } } break; case WM_TIMER: { switch (wParam) { case 9: { WeInvertWindowBorder(context->HighlightingWindow); if (--context->HighlightingWindowCount == 0) KillTimer(hwndDlg, 9); } break; } } break; case WM_SIZE: PhLayoutManagerLayout(&context->LayoutManager); break; case WM_NOTIFY: { LPNMHDR header = (LPNMHDR)lParam; switch (header->code) { case PSN_QUERYINITIALFOCUS: SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, (LPARAM)GetDlgItem(hwndDlg, IDC_REFRESH)); return TRUE; } } break; } return FALSE; }
bool CConEmuInside::InsideFindShellView(HWND hFrom) { wchar_t szClass[128]; wchar_t szParent[128]; wchar_t szRoot[128]; HWND hChild = NULL; // Для WinXP HWND hXpView = NULL, hXpPlace = NULL; while ((hChild = FindWindowEx(hFrom, hChild, NULL, NULL)) != NULL) { // Нас интересуют только видимые окна! if (!IsWindowVisible(hChild)) continue; // Windows 7, Windows 8. GetClassName(hChild, szClass, countof(szClass)); if (lstrcmp(szClass, L"SHELLDLL_DefView") == 0) { GetClassName(hFrom, szParent, countof(szParent)); if (lstrcmp(szParent, L"CtrlNotifySink") == 0) { HWND hParent = GetParent(hFrom); if (hParent) { GetClassName(hParent, szRoot, countof(szRoot)); _ASSERTE(lstrcmp(szRoot, L"DirectUIHWND") == 0); mh_InsideParentWND = hParent; mh_InsideParentRel = hFrom; m_InsideIntegration = ii_Explorer; return true; } } else if ((gnOsVer < 0x600) && (lstrcmp(szParent, L"ExploreWClass") == 0)) { _ASSERTE(mh_InsideParentRoot == hFrom); hXpView = hChild; } } else if ((gnOsVer < 0x600) && (lstrcmp(szClass, L"BaseBar") == 0)) { RECT rcBar = {}; GetWindowRect(hChild, &rcBar); MapWindowPoints(NULL, hFrom, (LPPOINT)&rcBar, 2); RECT rcParent = {}; GetClientRect(hFrom, &rcParent); if ((-10 <= (rcBar.right - rcParent.right)) && ((rcBar.right - rcParent.right) <= 10)) { // Нас интересует область, прилепленная к правому-нижнему углу hXpPlace = hChild; } } // Путь в этом (hChild) хранится в формате "Address: D:\users\max" else if ((gnOsVer >= 0x600) && lstrcmp(szClass, L"ToolbarWindow32") == 0) { GetClassName(hFrom, szParent, countof(szParent)); if (lstrcmp(szParent, L"Breadcrumb Parent") == 0) { HWND hParent = GetParent(hFrom); if (hParent) { GetClassName(hParent, szRoot, countof(szRoot)); _ASSERTE(lstrcmp(szRoot, L"msctls_progress32") == 0); mh_InsideParentPath = hChild; // Остается ComboBox/Edit, в который можно запихнуть путь, чтобы заставить эксплорер по нему перейти // Но есть проблема. Этот контрол не создается при открытии окна! return true; } } } if ((hChild != hXpView) && (hChild != hXpPlace)) { if (InsideFindShellView(hChild)) { if (mh_InsideParentRel && mh_InsideParentPath) return true; else break; } } if (hXpView && hXpPlace) { mh_InsideParentRel = FindWindowEx(hXpPlace, NULL, L"ReBarWindow32", NULL); if (!mh_InsideParentRel) { _ASSERTE(mh_InsideParentRel && L"ReBar must be found on XP & 2k3"); return true; // закончить поиск } mh_InsideParentWND = hXpPlace; mh_InsideParentPath = mh_InsideParentRoot; m_InsideIntegration = ii_Explorer; return true; } } return false; }
void CPlayerSubresyncBar::UpdatePreview() { if (m_mode == VOBSUB || m_mode == TEXTSUB) { if (0/*m_bUnlink*/) { for (int i = 0, j = (int)m_sts.GetCount(); i < j; i++) { bool bStartMod, bEndMod, bStartAdj, bEndAdj; GetCheck(i, bStartMod, bEndMod, bStartAdj, bEndAdj); m_sts[i].start = (bStartMod || bStartAdj) ? m_subtimes[i].newStart : m_subtimes[i].orgStart; m_sts[i].end = (bEndMod || bEndAdj) ? m_subtimes[i].newEnd : m_subtimes[i].orgEnd; } } else { CAtlArray<int> schk; for (int i = 0, j = (int)m_sts.GetCount(); i < j;) { schk.RemoveAll(); int start = i, end; for (end = i; end < j; end++) { int data = m_displayData[end].flags; if ((data & TSEP) && end > i) { break; } if (data & (TSMOD | TSADJ)) { schk.Add(end); } } if (schk.IsEmpty()) { for (; start < end; start++) { m_sts[start].start = m_subtimes[start].orgStart; m_sts[start].end = m_subtimes[start].orgEnd; } } else if (schk.GetCount() == 1) { int k = schk[0]; int dt = m_subtimes[k].newStart - m_subtimes[k].orgStart; for (; start < end; start++) { m_sts[start].start = m_subtimes[start].orgStart + dt; m_sts[start].end = (m_displayData[start].flags & TEMOD) ? m_subtimes[start].newEnd : (m_subtimes[start].orgEnd + dt); } } else if (schk.GetCount() >= 2) { int i0 = 0; int i1 = 0; int ti0 = 0; int ds = 0; double m = 0; int k, l; for (k = 0, l = (int)schk.GetCount() - 1; k < l; k++) { i0 = schk[k]; i1 = schk[k + 1]; ti0 = m_subtimes[i0].orgStart; ds = m_subtimes[i1].orgStart - ti0; if (ds == 0) { SetSTS0(start, i1, ti0); } else { m = double(m_subtimes[i1].newStart - m_subtimes[i0].newStart) / ds; SetSTS1(start, i1, ti0, m, i0); } } ASSERT(k > 0); if (ds == 0) { SetSTS0(start, end, ti0); } else { SetSTS1(start, end, ti0, m, i0); } } i = end; } } m_sts.CreateSegments(); for (size_t i = 0, j = m_sts.GetCount(); i < j; i++) { m_displayData[i].tPrevStart = m_sts[i].start; m_displayData[i].tPrevEnd = m_sts[i].end; } m_list.Invalidate(); if (IsWindowVisible()) { SaveSubtitle(); } } }
static int lua_Focus(lua_State *L){ if (IsWindowVisible(ASWN->TC->hwnd)) SwitchToThisWindow(ASWN->TC->hwnd,0); return 0; }
static INT_PTR CALLBACK FtMgrDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { struct TFtMgrData *dat = (struct TFtMgrData *)GetWindowLongPtr(hwnd, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: { TCITEM tci = {0}; HWND hwndTab = GetDlgItem(hwnd, IDC_TABS); TranslateDialogDefault(hwnd); Window_SetIcon_IcoLib(hwnd, SKINICON_EVENT_FILE); dat = (struct TFtMgrData *)mir_calloc(sizeof(struct TFtMgrData)); SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)dat); dat->hhkPreshutdown = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwnd, M_PRESHUTDOWN); dat->hwndIncoming = CreateDialog(hInst, MAKEINTRESOURCE(IDD_FTPAGE), hwnd, FtMgrPageDlgProc); dat->hwndOutgoing = CreateDialog(hInst, MAKEINTRESOURCE(IDD_FTPAGE), hwnd, FtMgrPageDlgProc); ShowWindow(dat->hwndIncoming, SW_SHOW); tci.mask = TCIF_PARAM|TCIF_TEXT; tci.pszText = TranslateT("Incoming"); tci.lParam = (LPARAM)dat->hwndIncoming; TabCtrl_InsertItem(hwndTab, 0, &tci); tci.pszText = TranslateT("Outgoing"); tci.lParam = (LPARAM)dat->hwndOutgoing; TabCtrl_InsertItem(hwndTab, 1, &tci); // Utils_RestoreWindowPosition(hwnd, NULL, "SRFile", "FtMgrDlg_"); SAVEWINDOWPOS swp; swp.hwnd = hwnd; swp.hContact = NULL; swp.szModule = "SRFile"; swp.szNamePrefix = "FtMgrDlg_"; CallService(MS_UTILS_RESTOREWINDOWPOSITION, RWPF_NOACTIVATE, (LPARAM)&swp); // Fall through to setup initial placement } case WM_SIZE: { RECT rc, rcButton; HDWP hdwp; HWND hwndTab = GetDlgItem(hwnd, IDC_TABS); GetWindowRect(GetDlgItem(hwnd, IDCANCEL), &rcButton); OffsetRect(&rcButton, -rcButton.left, -rcButton.top); GetClientRect(hwnd, &rc); InflateRect(&rc, -6, -6); hdwp = BeginDeferWindowPos(3); hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDC_CLEAR), NULL, rc.left, rc.bottom-rcButton.bottom, 0, 0, SWP_NOZORDER|SWP_NOSIZE); hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, IDCANCEL), NULL, rc.right-rcButton.right, rc.bottom-rcButton.bottom, 0, 0, SWP_NOZORDER|SWP_NOSIZE); rc.bottom -= rcButton.bottom + 5; hdwp = DeferWindowPos(hdwp, hwndTab, NULL, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, SWP_NOZORDER); EndDeferWindowPos(hdwp); GetWindowRect(hwndTab, &rc); MapWindowPoints(NULL, hwnd, (LPPOINT)&rc, 2); TabCtrl_AdjustRect(hwndTab, FALSE, &rc); InflateRect(&rc, -5, -5); hdwp = BeginDeferWindowPos(2); hdwp = DeferWindowPos(hdwp, dat->hwndIncoming, HWND_TOP, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, 0); hdwp = DeferWindowPos(hdwp, dat->hwndOutgoing, HWND_TOP, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, 0); EndDeferWindowPos(hdwp); break; } case WM_MOUSEWHEEL: if (IsWindowVisible(dat->hwndIncoming)) SendMessage(dat->hwndIncoming, msg, wParam, lParam); if (IsWindowVisible(dat->hwndOutgoing)) SendMessage(dat->hwndOutgoing, msg, wParam, lParam); break; case WM_FT_SELECTPAGE: { TCITEM tci = {0}; HWND hwndTab = GetDlgItem(hwnd, IDC_TABS); if (TabCtrl_GetCurSel(hwndTab) == (int)wParam) break; tci.mask = TCIF_PARAM; TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci); ShowWindow((HWND)tci.lParam, SW_HIDE); TabCtrl_SetCurSel(hwndTab, wParam); TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci); ShowWindow((HWND)tci.lParam, SW_SHOW); } break; case WM_GETMINMAXINFO: { LPMINMAXINFO lpmmi = (LPMINMAXINFO)lParam; lpmmi->ptMinTrackSize.x = 300; lpmmi->ptMinTrackSize.y = 400; return 0; } case WM_COMMAND: switch (LOWORD(wParam)) { case IDCANCEL: PostMessage(hwnd, WM_CLOSE , 0, 0); break; case IDC_CLEAR: PostMessage(dat->hwndIncoming, WM_FT_CLEANUP, 0, 0); PostMessage(dat->hwndOutgoing, WM_FT_CLEANUP, 0, 0); break; } break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->idFrom) { case IDC_TABS: { HWND hwndTab = GetDlgItem(hwnd, IDC_TABS); switch (((LPNMHDR)lParam)->code) { case TCN_SELCHANGING: { TCITEM tci = {0}; tci.mask = TCIF_PARAM; TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci); ShowWindow((HWND)tci.lParam, SW_HIDE); break; } case TCN_SELCHANGE: { TCITEM tci = {0}; tci.mask = TCIF_PARAM; TabCtrl_GetItem(hwndTab, TabCtrl_GetCurSel(hwndTab), &tci); ShowWindow((HWND)tci.lParam, SW_SHOW); break; } } break; } } break; case M_PRESHUTDOWN: SendMessage(dat->hwndIncoming, M_PRESHUTDOWN, 0, 0); SendMessage(dat->hwndOutgoing, M_PRESHUTDOWN, 0, 0); DestroyWindow(hwnd); break; case WM_CLOSE: ShowWindow(hwnd, SW_HIDE); if (db_get_b(NULL, "SRFile", "AutoClear", 1)) { PostMessage(dat->hwndIncoming, WM_FT_CLEANUP, 0, 0); PostMessage(dat->hwndOutgoing, WM_FT_CLEANUP, 0, 0); } return TRUE; /* Disable default IDCANCEL notification */ case WM_DESTROY: UnhookEvent(dat->hhkPreshutdown); Window_FreeIcon_IcoLib(hwnd); DestroyWindow(dat->hwndIncoming); DestroyWindow(dat->hwndOutgoing); mir_free(dat); SetWindowLongPtr(hwnd, GWLP_USERDATA, 0); Utils_SaveWindowPosition(hwnd, NULL, "SRFile", "FtMgrDlg_"); break; case WM_ACTIVATE: dat->errorState = TBPF_NOPROGRESS; wParam = 1; break; case WM_SHOWWINDOW: if ( !wParam) { // hiding KillTimer(hwnd, 1); break; } lParam = 0; case WM_TIMER: if (pTaskbarInterface) { SetTimer(hwnd, 1, 400, NULL); if ((lParam == ACKRESULT_FAILED) || (lParam == ACKRESULT_DENIED)) dat->errorState = TBPF_ERROR; TFtProgressData prg = {0}; SendMessage(dat->hwndIncoming, M_CALCPROGRESS, (WPARAM)&prg, 0); SendMessage(dat->hwndOutgoing, M_CALCPROGRESS, (WPARAM)&prg, 0); if (dat->errorState) { pTaskbarInterface->SetProgressState(hwnd, dat->errorState); if ( !prg.run) pTaskbarInterface->SetProgressValue(hwnd, 1, 1); } else if (prg.run) pTaskbarInterface->SetProgressState(hwnd, TBPF_NORMAL); else if (prg.init || prg.scan) pTaskbarInterface->SetProgressState(hwnd, TBPF_INDETERMINATE); else { pTaskbarInterface->SetProgressState(hwnd, TBPF_NOPROGRESS); KillTimer(hwnd, 1); } if (prg.run) pTaskbarInterface->SetProgressValue(hwnd, prg.totalProgress, prg.totalBytes); } break; } return FALSE; }
static int lua_GetVisible(lua_State *L){ lua_pushinteger(L, IsWindowVisible(ASWN->TC->hwnd)); return 1; }
/** * Tries to switch to the main window of the VM process. * * @return true if successfully switched and false otherwise. */ bool UIVMItem::switchTo() { #ifdef Q_WS_MAC ULONG64 id = m_machine.ShowConsoleWindow(); #else WId id = (WId) m_machine.ShowConsoleWindow(); #endif AssertWrapperOk(m_machine); if (!m_machine.isOk()) return false; /* winId = 0 it means the console window has already done everything * necessary to implement the "show window" semantics. */ if (id == 0) return true; #if defined (Q_WS_WIN32) || defined (Q_WS_X11) return vboxGlobal().activateWindow(id, true); #elif defined (Q_WS_MAC) /* * This is just for the case were the other process cannot steal * the focus from us. It will send us a PSN so we can try. */ ProcessSerialNumber psn; psn.highLongOfPSN = id >> 32; psn.lowLongOfPSN = (UInt32)id; OSErr rc = ::SetFrontProcess(&psn); if (!rc) Log(("GUI: %#RX64 couldn't do SetFrontProcess on itself, the selector (we) had to do it...\n", id)); else Log(("GUI: Failed to bring %#RX64 to front. rc=%#x\n", id, rc)); return !rc; #endif return false; /// @todo Below is the old method of switching to the console window // based on the process ID of the console process. It should go away // after the new (callback-based) method is fully tested. #if 0 if (!canSwitchTo()) return false; #if defined (Q_WS_WIN32) HWND hwnd = mWinId; /* if there are blockers (modal and modeless dialogs, etc), find the * topmost one */ HWND hwndAbove = NULL; do { hwndAbove = GetNextWindow(hwnd, GW_HWNDPREV); HWND hwndOwner; if (hwndAbove != NULL && ((hwndOwner = GetWindow(hwndAbove, GW_OWNER)) == hwnd || hwndOwner == hwndAbove)) hwnd = hwndAbove; else break; } while (1); /* first, check that the primary window is visible */ if (IsIconic(mWinId)) ShowWindow(mWinId, SW_RESTORE); else if (!IsWindowVisible(mWinId)) ShowWindow(mWinId, SW_SHOW); #if 0 LogFlowFunc(("mWinId=%08X hwnd=%08X\n", mWinId, hwnd)); #endif /* then, activate the topmost in the group */ AllowSetForegroundWindow(m_pid); SetForegroundWindow(hwnd); return true; #elif defined (Q_WS_X11) return false; #elif defined (Q_WS_MAC) ProcessSerialNumber psn; OSStatus rc = ::GetProcessForPID(m_pid, &psn); if (!rc) { rc = ::SetFrontProcess(&psn); if (!rc) { ShowHideProcess(&psn, true); return true; } } return false; #else return false; #endif #endif }
void showFunction(HWND hwnd, EDITDATA *p, int ch) { sqlite3_int64 id, baseid; CCFUNCDATA *functionData = NULL; char name[2046], *q = name; int end = p->selstartcharpos; int pos = p->selstartcharpos - 1; POINT cpos; SIZE size; int curArg = 0; if (instring(p->cd->text, &p->cd->text[p->selstartcharpos])) return; p->cd->selecting = FALSE; if (pos <= 0 || PropGetInt(NULL, "CODE_COMPLETION") == 0) return ; if (ch == '(' || ch == ',' && !IsWindowVisible(hwndShowFunc)) { char name[512], *p1; int pos; int i; int commaCount = 0; DWINFO *info = (DWINFO *)GetWindowLong(GetParent(hwnd), 0); int lineno = SendMessage(hwnd, EM_EXLINEFROMCHAR, 0, p->selstartcharpos)+1; CCFUNCDATA * functionData = NULL; BOOL parsed = FALSE; CHARRANGE range; if (ch == ',') { int nesting =1 ; pos = p->selendcharpos-1; while (nesting > 0 && pos> 0 && p->cd->text[pos].ch != '{' && p->cd->text[pos].ch != '}') { if (p->cd->text[pos].ch == ')') nesting++; else if (p->cd->text[pos].ch == '(') nesting --; else if (p->cd->text[pos].ch == ',' && nesting == 1) commaCount++; pos--; } if (nesting) return; if (!pos || !isalnum(p->cd->text[pos-1].ch) && p->cd->text[pos-1].ch != '_') return; range.cpMin = pos; range.cpMax = pos; } else { range.cpMin = p->selendcharpos-1; range.cpMax = p->selendcharpos-1; } GetWordSpan(p, &range); if (range.cpMin == range.cpMax) return; pos = range.cpMin; while (pos && isspace(p->cd->text[pos-1].ch)) { pos--; } if (pos && p->cd->text[pos-1].ch == ':') { pos = CPPScanBackward(p, range.cpMax, TRUE); } else { pos = range.cpMin; } for (i=pos; i < range.cpMax; i++) name[i-pos] = p->cd->text[i].ch; name[i-pos] = 0; p1 = name; GetQualifiedName(name + i-pos + 1, &p1, FALSE, FALSE); strcpy(name, name +i-pos + 1); while (pos && isspace(p->cd->text[pos-1].ch)) { pos--; } if (pos && (p->cd->text[pos-1].ch == '.' || p->cd->text[pos-1].ch == '>')) { int start = 0; start = CPPScanBackward(p, p->selendcharpos, TRUE); if (start != pos) { char qual[2048]; for (i=start; i < pos; i++) qual[i-start] = p->cd->text[i].ch; qual[i-start] = 0; parsed = TRUE; sprintf(qual + strlen(qual), "@%s", name); functionData = ccLookupFunctionList(lineno, info->dwName, qual); } } if (!parsed) { CCFUNCDATA **scan; char funcbase[2048], nsbase[512], abase[512]; abase[0] = 0; GetContainerData(lineno, info->dwName, nsbase, funcbase); if (strrchr(name, '@') != name) { char *p = strrchr(name, '@'); strncpy(abase, name, p - name); abase[p-name] = 0; strcpy(name, p); *p = 0; } functionData = ccLookupFunctionList(lineno, info->dwName, name); if (!functionData) { name[0] = '_'; functionData = ccLookupFunctionList(lineno, info->dwName, name); name[0] = '@'; } scan = &functionData; while (*scan) { char nsbase2[2048]; if ((*scan)->args->member) { if (!funcbase[0] || strncmp(funcbase, (*scan)->fullname, strlen(funcbase))) { CCFUNCDATA *remove = *scan; *scan = (*scan)->next; remove->next = NULL; ccFreeFunctionList(remove); } else { scan = &(*scan)->next; } } else { char *last, *p ; int nesting = 0; p = last = (*scan)->fullname; while (*p) { switch(*p) { case '@': if (!nesting) last = p; break; case '#': nesting++; break; case '~': if (nesting) nesting--; break; } p++; } if (last != (*scan)->fullname && (strncmp((*scan)->fullname, funcbase, last - (*scan)->fullname) || funcbase[last - (*scan)->fullname] != '@' && funcbase[last - (*scan)->fullname] != 0)) { BOOL found = FALSE; char *p = nsbase; while (*p) { char *q = nsbase2; while (*p && *p != ';') *q++ = *p++; if (*p) p++; *q = 0; if (!strncmp((*scan)->fullname, nsbase2, last - (*scan)->fullname) &&( nsbase2[last - (*scan)->fullname] == '@' || nsbase2[last - (*scan)->fullname] == 0)) { found = TRUE; break; } } if (!found) { strcpy(nsbase2, abase); if (!strncmp((*scan)->fullname, nsbase2, last - (*scan)->fullname) && nsbase2[last - (*scan)->fullname] == 0) { found = TRUE; } } if (!found) { CCFUNCDATA *remove = *scan; *scan = (*scan)->next; remove->next = NULL; ccFreeFunctionList(remove); } else scan = &(*scan)->next; } else { BOOL found = abase[0] == '\0'; strcpy(nsbase2, abase); if (!strncmp((*scan)->fullname, nsbase2, last - (*scan)->fullname) && nsbase2[last - (*scan)->fullname] == 0) { found = TRUE; } if (!found) { CCFUNCDATA *remove = *scan; *scan = (*scan)->next; remove->next = NULL; ccFreeFunctionList(remove); } else { scan = &(*scan)->next; } } } } } if (functionData) { if (!hwndShowFunc) { hwndShowFunc = CreateWindowEx(0 | /*WS_EX_TOPMOST | WS_EX_LAYERED |*/ WS_EX_NOACTIVATE, "xccfuncclass", "", (WS_CHILD), CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndFrame, 0, GetModuleHandle(0), 0); // done this way to associate the popup with the application rather than the desktop SetWindowLong(hwndShowFunc, GWL_STYLE, (GetWindowLong(hwndShowFunc, GWL_STYLE) & ~WS_CHILD ) | WS_POPUP); } SendMessage(hwndShowFunc, WM_USER, 0, (LPARAM)functionData); SendMessage(hwndShowFunc, WM_USER+1, (WPARAM)hwnd, (LPARAM)p); SendMessage(hwndShowFunc, WM_USER+2, commaCount, 0); ShowWindow(hwndShowFunc, SW_SHOW); SetFocus(hwnd); } } }
INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); timerID = 0; { HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); mir_subclassWindow(hwndList, PluginListWndProc); HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 4, 0); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_UNICODE); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_ANSI); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_LOADED); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_NOTLOADED); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_LOADEDGRAY); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_NOTLOADEDGRAY); ListView_SetImageList(hwndList, hIml, LVSIL_SMALL); LVCOLUMN col; col.mask = LVCF_TEXT | LVCF_WIDTH; col.pszText = _T(""); col.cx = 40; ListView_InsertColumn(hwndList, 0, &col); col.pszText = TranslateT("Plugin"); col.cx = 180; ListView_InsertColumn(hwndList, 1, &col); col.pszText = TranslateT("Name"); col.cx = 180;//max = 220; ListView_InsertColumn(hwndList, 2, &col); col.pszText = TranslateT("Version"); col.cx = 75; ListView_InsertColumn(hwndList, 3, &col); ListView_SetExtendedListViewStyleEx(hwndList, 0, LVS_EX_SUBITEMIMAGES | LVS_EX_CHECKBOXES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT); // scan the plugin dir for plugins, cos arPluginList.destroy(); szFilter.Empty(); enumPlugins(dialogListPlugins, (WPARAM)hwndDlg, (LPARAM)hwndList); // sort out the headers ListView_SetColumnWidth(hwndList, 1, LVSCW_AUTOSIZE); // dll name int w = ListView_GetColumnWidth(hwndList, 1); if (w > 110) { ListView_SetColumnWidth(hwndList, 1, w = 110); } int max = w < 110 ? 189 + 110 - w : 189; ListView_SetColumnWidth(hwndList, 3, LVSCW_AUTOSIZE); // short name w = ListView_GetColumnWidth(hwndList, 2); if (w > max) ListView_SetColumnWidth(hwndList, 2, max); ListView_SortItems(hwndList, SortPlugins, (LPARAM)hwndDlg); } return TRUE; case WM_NOTIFY: if (lParam) { NMLISTVIEW *hdr = (NMLISTVIEW *)lParam; if (hdr->hdr.code == LVN_ITEMCHANGED && IsWindowVisible(hdr->hdr.hwndFrom)) { if (hdr->uOldState != 0 && (hdr->uNewState == 0x1000 || hdr->uNewState == 0x2000)) { HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); LVITEM it; it.mask = LVIF_PARAM | LVIF_STATE; it.iItem = hdr->iItem; if (!ListView_GetItem(hwndList, &it)) break; PluginListItemData *dat = (PluginListItemData*)it.lParam; if (dat->flags & STATIC_PLUGIN) { ListView_SetItemState(hwndList, hdr->iItem, 0x3000, LVIS_STATEIMAGEMASK); return FALSE; } // find all another standard plugins by mask and disable them if ((hdr->uNewState == 0x2000) && dat->stdPlugin != 0) { for (int iRow = 0; iRow != -1; iRow = ListView_GetNextItem(hwndList, iRow, LVNI_ALL)) { if (iRow != hdr->iItem) { // skip the plugin we're standing on LVITEM dt; dt.mask = LVIF_PARAM; dt.iItem = iRow; if (ListView_GetItem(hwndList, &dt)) { PluginListItemData *dat2 = (PluginListItemData*)dt.lParam; if (dat2->stdPlugin & dat->stdPlugin) {// mask differs // the lParam is unset, so when the check is unset the clist block doesnt trigger int iSave = dat2->stdPlugin; dat2->stdPlugin = 0; ListView_SetItemState(hwndList, iRow, 0x1000, LVIS_STATEIMAGEMASK); dat2->stdPlugin = iSave; } } } } } if (bOldMode) ShowWindow(GetDlgItem(hwndDlg, IDC_RESTART), TRUE); // this here only in "ghazan mode" SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } if (hdr->iItem != -1) { int sel = hdr->uNewState & LVIS_SELECTED; HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); LVITEM lvi = { 0 }; lvi.mask = LVIF_PARAM; lvi.iItem = hdr->iItem; if (ListView_GetItem(hwndList, &lvi)) { PluginListItemData *dat = (PluginListItemData*)lvi.lParam; TCHAR buf[1024]; ListView_GetItemText(hwndList, hdr->iItem, 2, buf, _countof(buf)); SetDlgItemText(hwndDlg, IDC_PLUGININFOFRAME, sel ? buf : _T("")); ptrT tszAuthor(latin2t(sel ? dat->author : NULL)); SetDlgItemText(hwndDlg, IDC_PLUGINAUTHOR, tszAuthor); ptrT tszEmail(latin2t(sel ? dat->authorEmail : NULL)); SetDlgItemText(hwndDlg, IDC_PLUGINEMAIL, tszEmail); ptrT p(Langpack_PcharToTchar(dat->description)); SetDlgItemText(hwndDlg, IDC_PLUGINLONGINFO, sel ? p : _T("")); ptrT tszCopyright(latin2t(sel ? dat->copyright : NULL)); SetDlgItemText(hwndDlg, IDC_PLUGINCPYR, tszCopyright); ptrT tszUrl(latin2t(sel ? dat->homepage : NULL)); SetDlgItemText(hwndDlg, IDC_PLUGINURL, tszUrl); if (!equalUUID(miid_last, dat->uuid)) { char szUID[128]; uuidToString(dat->uuid, szUID, sizeof(szUID)); SetDlgItemTextA(hwndDlg, IDC_PLUGINPID, sel ? szUID : ""); } else SetDlgItemText(hwndDlg, IDC_PLUGINPID, sel ? TranslateT("<none>") : _T("")); } } } if (hdr->hdr.code == PSN_APPLY) { bool needRestart = false; TCHAR bufRestart[1024]; int bufLen = mir_sntprintf(bufRestart, _T("%s\n"), TranslateT("Miranda NG must be restarted to apply changes for these plugins:")); HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); for (int iRow = 0; iRow != -1;) { TCHAR buf[1024]; ListView_GetItemText(hwndList, iRow, 1, buf, _countof(buf)); int iState = ListView_GetItemState(hwndList, iRow, LVIS_STATEIMAGEMASK); SetPluginOnWhiteList(buf, (iState & 0x2000) ? 1 : 0); if (!bOldMode && iState != 0x3000) { LVITEM lvi = { 0 }; lvi.mask = LVIF_IMAGE | LVIF_PARAM; lvi.stateMask = -1; lvi.iItem = iRow; lvi.iSubItem = 0; if (ListView_GetItem(hwndList, &lvi)) { lvi.mask = LVIF_IMAGE; PluginListItemData *dat = (PluginListItemData*)lvi.lParam; if (iState == 0x2000) { // enabling plugin if (lvi.iImage == 3 || lvi.iImage == 5) { if (lvi.iImage == 3 && LoadPluginDynamically(dat)) { lvi.iImage = 2; ListView_SetItem(hwndList, &lvi); } else { bufLen += mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T(" - %s\n"), buf); needRestart = true; } } } else { // disabling plugin if (lvi.iImage == 2 || lvi.iImage == 4) { if (lvi.iImage == 2 && UnloadPluginDynamically(dat)) { lvi.iImage = 3; ListView_SetItem(hwndList, &lvi); } else { bufLen += mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T(" - %s\n"), buf); needRestart = true; } } } } } iRow = ListView_GetNextItem(hwndList, iRow, LVNI_ALL); } LoadStdPlugins(); ShowWindow(GetDlgItem(hwndDlg, IDC_RESTART), needRestart); if (needRestart) { mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T("\n%s"), TranslateT("Do you want to restart it now?")); if (MessageBox(NULL, bufRestart, _T("Miranda NG"), MB_ICONWARNING | MB_YESNO) == IDYES) CallService(MS_SYSTEM_RESTART, 1, 0); } } } break; case WM_COMMAND: if (HIWORD(wParam) == STN_CLICKED) { switch (LOWORD(wParam)) { case IDC_GETMOREPLUGINS: Utils_OpenUrl("http://miranda-ng.org/downloads/"); break; case IDC_PLUGINEMAIL: case IDC_PLUGINURL: char buf[512]; char *p = &buf[7]; mir_strcpy(buf, "mailto:"); if (GetDlgItemTextA(hwndDlg, LOWORD(wParam), p, _countof(buf) - 7)) Utils_OpenUrl(LOWORD(wParam) == IDC_PLUGINEMAIL ? buf : p); break; } } break; case WM_DESTROY: arPluginList.destroy(); RemoveAllItems(GetDlgItem(hwndDlg, IDC_PLUGLIST)); break; } return FALSE; }
VOID RebarLoadSettings( VOID ) { if (ToolStatusConfig.ToolBarEnabled && !ToolBarImageList) { ToolBarImageSize.cx = GetSystemMetrics(SM_CXSMICON); ToolBarImageSize.cy = GetSystemMetrics(SM_CYSMICON); ToolBarImageList = ImageList_Create(ToolBarImageSize.cx, ToolBarImageSize.cy, ILC_COLOR32, 0, 0); HFONT newFont; if (newFont = ToolStatusGetTreeWindowFont()) { if (ToolStatusWindowFont) DeleteObject(ToolStatusWindowFont); ToolStatusWindowFont = newFont; } } if (ToolStatusConfig.ToolBarEnabled && !RebarHandle) { RebarHandle = CreateWindowEx( WS_EX_TOOLWINDOW, REBARCLASSNAME, NULL, WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CCS_NODIVIDER | CCS_TOP | RBS_VARHEIGHT | RBS_AUTOSIZE, // CCS_NOPARENTALIGN CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, PhMainWndHandle, NULL, NULL, NULL ); ToolBarHandle = CreateWindowEx( 0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CCS_NOPARENTALIGN | CCS_NODIVIDER | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TRANSPARENT | TBSTYLE_TOOLTIPS | TBSTYLE_AUTOSIZE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, RebarHandle, NULL, NULL, NULL ); // Set the rebar info with no imagelist. SendMessage(RebarHandle, RB_SETBARINFO, 0, (LPARAM)&(REBARINFO){ sizeof(REBARINFO) }); // Set the toolbar struct size. SendMessage(ToolBarHandle, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0); // Set the toolbar extended toolbar styles. SendMessage(ToolBarHandle, TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_DOUBLEBUFFER | TBSTYLE_EX_MIXEDBUTTONS | TBSTYLE_EX_HIDECLIPPEDBUTTONS); // Configure the toolbar imagelist. SendMessage(ToolBarHandle, TB_SETIMAGELIST, 0, (LPARAM)ToolBarImageList); // Add the buttons to the toolbar. ToolbarLoadButtonSettings(); SendMessage(ToolBarHandle, WM_SETFONT, (WPARAM)ToolStatusWindowFont, FALSE); // Resize the toolbar. SendMessage(ToolBarHandle, TB_AUTOSIZE, 0, 0); // Inset the toolbar into the rebar control. ULONG toolbarButtonSize = (ULONG)SendMessage(ToolBarHandle, TB_GETBUTTONSIZE, 0, 0); RebarBandInsert(REBAR_BAND_ID_TOOLBAR, ToolBarHandle, LOWORD(toolbarButtonSize), HIWORD(toolbarButtonSize)); } if (ToolStatusConfig.SearchBoxEnabled && !SearchboxHandle) { SearchboxText = PhReferenceEmptyString(); ProcessTreeFilterEntry = PhAddTreeNewFilter(PhGetFilterSupportProcessTreeList(), ProcessTreeFilterCallback, NULL); ServiceTreeFilterEntry = PhAddTreeNewFilter(PhGetFilterSupportServiceTreeList(), ServiceTreeFilterCallback, NULL); NetworkTreeFilterEntry = PhAddTreeNewFilter(PhGetFilterSupportNetworkTreeList(), NetworkTreeFilterCallback, NULL); if (SearchboxHandle = CreateWindowEx( WS_EX_CLIENTEDGE, WC_EDIT, NULL, WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | ES_LEFT | ES_AUTOHSCROLL | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, RebarHandle, NULL, NULL, NULL )) { PhCreateSearchControl(RebarHandle, SearchboxHandle, L"Search Processes (Ctrl+K)"); } } if (ToolStatusConfig.StatusBarEnabled && !StatusBarHandle) { StatusBarHandle = CreateWindowEx( 0, STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | CCS_BOTTOM | SBARS_SIZEGRIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, PhMainWndHandle, NULL, NULL, NULL ); if (StatusBarHandle && PhGetIntegerSetting(L"EnableThemeSupport")) { PhInitializeWindowThemeStatusBar(StatusBarHandle); } } // Hide or show controls (Note: don't unload or remove at runtime). if (ToolStatusConfig.ToolBarEnabled) { if (RebarHandle && !IsWindowVisible(RebarHandle)) ShowWindow(RebarHandle, SW_SHOW); } else { if (RebarHandle && IsWindowVisible(RebarHandle)) ShowWindow(RebarHandle, SW_HIDE); } if (ToolStatusConfig.SearchBoxEnabled && RebarHandle && SearchboxHandle) { UINT height = (UINT)SendMessage(RebarHandle, RB_GETROWHEIGHT, 0, 0); // Add the Searchbox band into the rebar control. if (!RebarBandExists(REBAR_BAND_ID_SEARCHBOX)) RebarBandInsert(REBAR_BAND_ID_SEARCHBOX, SearchboxHandle, PH_SCALE_DPI(180), height); if (!IsWindowVisible(SearchboxHandle)) ShowWindow(SearchboxHandle, SW_SHOW); if (SearchBoxDisplayMode == SEARCHBOX_DISPLAY_MODE_HIDEINACTIVE) { if (RebarBandExists(REBAR_BAND_ID_SEARCHBOX)) RebarBandRemove(REBAR_BAND_ID_SEARCHBOX); } } else { // Remove the Searchbox band from the rebar control. if (RebarBandExists(REBAR_BAND_ID_SEARCHBOX)) RebarBandRemove(REBAR_BAND_ID_SEARCHBOX); if (SearchboxHandle) { // Clear search text and reset search filters. SetFocus(SearchboxHandle); Static_SetText(SearchboxHandle, L""); if (IsWindowVisible(SearchboxHandle)) ShowWindow(SearchboxHandle, SW_HIDE); } } if (ToolStatusConfig.StatusBarEnabled) { if (StatusBarHandle && !IsWindowVisible(StatusBarHandle)) ShowWindow(StatusBarHandle, SW_SHOW); } else { if (StatusBarHandle && IsWindowVisible(StatusBarHandle)) ShowWindow(StatusBarHandle, SW_HIDE); } }
inline BOOL HookHandle(UINT MessageId, HWND hWnd, WPARAM wParam, LPARAM lParam) { //////////////////////////////////////////////////////////////// // HANDLE DEFERRED UPDATES // Is this a deferred-update message? if (MessageId == VNC_DEFERRED_UPDATE) { // NOTE : NEVER use the SendDeferred- routines to send updates // from here, or you'll get an infinite loop....! // NB : The format of DEFERRED_UPDATE matches that of UpdateRectMessage, // so just send the exact same message data to WinVNC PostThreadMessage( vnc_thread_id, UpdateRectMessage, wParam, lParam ); return FALSE; } // *** Could use WM_COPYDATA to send data to WinVNC /* if (GetClassLong(hWnd, GCW_ATOM) == 32768) { _RPT4(_CRT_WARN, "DBG : popup menu message (hwnd=%d, msg=%d, l=%d, w=%d)\n", hWnd, MessageId, lParam, wParam); } */ //////////////////////////////////////////////////////////////// // UPDATE-TRIGGERING MESSAGES // Do something dependent upon message type switch (MessageId) { //////////////////////////////////////////////////////////////// // Messages indicating only a border repaint. case WM_NCPAINT: case WM_NCACTIVATE: SendDeferredBorderRect(hWnd); old_cursor = NULL; break; //////////////////////////////////////////////////////////////// // Messages indicating a client area repaint case WM_CHAR: case WM_KEYUP: // Handle key-presses if (prf_use_KeyPress) SendDeferredWindowRect(hWnd); break; case WM_LBUTTONUP: // Handle LMB clicks if (prf_use_LButtonUp) SendDeferredWindowRect(hWnd); break; case WM_MBUTTONUP: // Handle MMB clicks if (prf_use_MButtonUp) SendDeferredWindowRect(hWnd); break; case WM_RBUTTONUP: // Handle RMB clicks if (prf_use_RButtonUp) SendDeferredWindowRect(hWnd); break; case WM_TIMER: if (prf_use_Timer) SendDeferredWindowRect(hWnd); break; case WM_HSCROLL: case WM_VSCROLL: if (((int) LOWORD(wParam) == SB_THUMBTRACK) || ((int) LOWORD(wParam) == SB_ENDSCROLL)) SendDeferredWindowRect(hWnd); break; case 485: // HACK to handle popup menus { // Get the old popup menu selection value HANDLE prop = GetProp(hWnd, (LPCTSTR) MAKELONG(VNC_POPUPSELN_ATOM, 0)); if (prop != (HANDLE) wParam) { // It did, so update the menu & the selection value SendDeferredWindowRect(hWnd); SetProp(hWnd, (LPCTSTR) MAKELONG(VNC_POPUPSELN_ATOM, 0), (HANDLE) wParam); } } break; //////////////////////////////////////////////////////////////// // Messages indicating a full window update case WM_SYSCOLORCHANGE: case WM_PALETTECHANGED: case WM_SETTEXT: case WM_ENABLE: case BM_SETCHECK: case BM_SETSTATE: case EM_SETSEL: //case WM_MENUSELECT: SendDeferredWindowRect(hWnd); break; //////////////////////////////////////////////////////////////// // Messages indicating that an area of the window needs updating // Uses GetUpdateRect to find out which case WM_PAINT: if (prf_use_GetUpdateRect) { HRGN region; region = CreateRectRgn(0, 0, 0, 0); // Get the affected region if (GetUpdateRgn(hWnd, region, FALSE) != ERROR) { int buffsize; UINT x; RGNDATA *buff; POINT TopLeft; // Get the top-left point of the client area TopLeft.x = 0; TopLeft.y = 0; if (!ClientToScreen(hWnd, &TopLeft)) break; // Get the size of buffer required buffsize = GetRegionData(region, 0, 0); if (buffsize != 0) { buff = (RGNDATA *) new BYTE [buffsize]; if (buff == NULL) break; // Now get the region data if(GetRegionData(region, buffsize, buff)) { for (x=0; x<(buff->rdh.nCount); x++) { // Obtain the rectangles from the list RECT *urect = (RECT *) (((BYTE *) buff) + sizeof(RGNDATAHEADER) + (x * sizeof(RECT))); SendDeferredUpdateRect( hWnd, (SHORT) (TopLeft.x + urect->left), (SHORT) (TopLeft.y + urect->top), (SHORT) (TopLeft.x + urect->right), (SHORT) (TopLeft.y + urect->bottom) ); // Modified by mws for VNC ver. 3.3.6 // We yield this thread so our PostMessages and socket commands // can complete, otherwise this hook can suck up too many // timeslices before it returns Sleep (0); } } delete [] buff; } } // Now free the region if (region != NULL) DeleteObject(region); } else SendDeferredWindowRect(hWnd); break; //////////////////////////////////////////////////////////////// // Messages indicating full repaint of this and a different window // Send the new position of the window case WM_WINDOWPOSCHANGING: if (IsWindowVisible(hWnd)) SendWindowRect(hWnd); break; case WM_WINDOWPOSCHANGED: if (IsWindowVisible(hWnd)) SendDeferredWindowRect(hWnd); break; //////////////////////////////////////////////////////////////// // WinVNC also wants to know about mouse movement case WM_NCMOUSEMOVE: case WM_MOUSEMOVE: // Inform WinVNC that the mouse has moved and pass it the current cursor handle { ULONG new_cursor = (ULONG)GetCursor(); if (new_cursor != old_cursor) { PostThreadMessage( vnc_thread_id, MouseMoveMessage, (ULONG) new_cursor, 0); old_cursor=new_cursor; } } break; // RealVNC 335 case WM_MOUSEWHEEL: // Handle mousewheel events SendDeferredWindowRect(hWnd); break; //////////////////////////////////////////////////////////////// // VNCHOOKS PROPERTIES HANDLING WINDOWS case WM_DESTROY: RemoveProp(hWnd, (LPCTSTR) MAKELONG(VNC_POPUPSELN_ATOM, 0)); break; } return TRUE; }
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case TRAY_CALLBACK: { switch(lParam) { case WM_LBUTTONDBLCLK: if (IsWindowVisible(hWnd)) ShowWindow(hWnd, SW_HIDE); else ShowWindow(hWnd, SW_RESTORE); break; case WM_MOUSEMOVE: { CString sInfoTip; sInfoTip.Format(L"Cached Directories : %Id\nWatched paths : %d", CSVNStatusCache::Instance().GetCacheSize(), CSVNStatusCache::Instance().GetNumberOfWatchedPaths()); NOTIFYICONDATA SystemTray = {}; SystemTray.cbSize = sizeof(NOTIFYICONDATA); SystemTray.hWnd = hTrayWnd; SystemTray.uID = TRAY_ID; SystemTray.uFlags = NIF_TIP; wcscpy_s(SystemTray.szTip, sInfoTip); Shell_NotifyIcon(NIM_MODIFY, &SystemTray); } break; case WM_RBUTTONUP: case WM_CONTEXTMENU: { POINT pt; GetCursorPos(&pt); HMENU hMenu = CreatePopupMenu(); if(hMenu) { InsertMenu(hMenu, (UINT)-1, MF_BYPOSITION, TRAYPOP_EXIT, L"Exit"); SetForegroundWindow(hWnd); TrackPopupMenu(hMenu, TPM_BOTTOMALIGN, pt.x, pt.y, 0, hWnd, NULL); DestroyMenu(hMenu); } } break; } } break; case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = BeginPaint(hWnd, &ps); RECT rect; GetClientRect(hWnd, &rect); // clear the background HBRUSH background = CreateSolidBrush(::GetSysColor(COLOR_WINDOW)); HGDIOBJ oldbrush = SelectObject(hdc, background); FillRect(hdc, &rect, background); int line = 0; SIZE fontsize = {0}; AutoLocker print(critSec); GetTextExtentPoint32( hdc, szCurrentCrawledPath[0], (int)wcslen(szCurrentCrawledPath[0]), &fontsize ); for (int i=nCurrentCrawledpathIndex; i<MAX_CRAWLEDPATHS; ++i) { TextOut(hdc, 0, line*fontsize.cy, szCurrentCrawledPath[i], (int)wcslen(szCurrentCrawledPath[i])); ++line; } for (int i=0; i<nCurrentCrawledpathIndex; ++i) { TextOut(hdc, 0, line*fontsize.cy, szCurrentCrawledPath[i], (int)wcslen(szCurrentCrawledPath[i])); ++line; } SelectObject(hdc,oldbrush); EndPaint(hWnd, &ps); DeleteObject(background); return 0L; } break; case WM_COMMAND: { WORD wmId = LOWORD(wParam); switch (wmId) { case TRAYPOP_EXIT: DestroyWindow(hWnd); break; } return 1; } case WM_QUERYENDSESSION: { ATLTRACE("WM_QUERYENDSESSION\n"); bRun = false; CAutoWriteWeakLock writeLock(CSVNStatusCache::Instance().GetGuard(), 200); CSVNStatusCache::Instance().Stop(); return TRUE; } break; case WM_CLOSE: case WM_ENDSESSION: case WM_DESTROY: case WM_QUIT: { ATLTRACE("WM_CLOSE/DESTROY/ENDSESSION/QUIT\n"); bRun = false; CAutoWriteLock writeLock(CSVNStatusCache::Instance().GetGuard()); CSVNStatusCache::Instance().Stop(); CSVNStatusCache::Instance().SaveCache(); if (message != WM_QUIT) PostQuitMessage(0); return 1; } break; case WM_DEVICECHANGE: { DEV_BROADCAST_HDR * phdr = (DEV_BROADCAST_HDR*)lParam; switch (wParam) { case DBT_CUSTOMEVENT: { CTraceToOutputDebugString::Instance()(__FUNCTION__ ": WM_DEVICECHANGE with DBT_CUSTOMEVENT\n"); if (phdr->dbch_devicetype == DBT_DEVTYP_HANDLE) { DEV_BROADCAST_HANDLE * phandle = (DEV_BROADCAST_HANDLE*)lParam; if (IsEqualGUID(phandle->dbch_eventguid, GUID_IO_VOLUME_DISMOUNT)) { CTraceToOutputDebugString::Instance()(__FUNCTION__ ": Device to be dismounted\n"); CAutoWriteLock writeLock(CSVNStatusCache::Instance().GetGuard()); CSVNStatusCache::Instance().CloseWatcherHandles(phandle->dbch_handle); } if (IsEqualGUID(phandle->dbch_eventguid, GUID_IO_VOLUME_LOCK)) { CTraceToOutputDebugString::Instance()(__FUNCTION__ ": Device lock event\n"); CAutoWriteLock writeLock(CSVNStatusCache::Instance().GetGuard()); CSVNStatusCache::Instance().CloseWatcherHandles(phandle->dbch_handle); } } } break; case DBT_DEVICEREMOVEPENDING: case DBT_DEVICEQUERYREMOVE: case DBT_DEVICEREMOVECOMPLETE: CTraceToOutputDebugString::Instance()(__FUNCTION__ ": WM_DEVICECHANGE with DBT_DEVICEREMOVEPENDING/QUERYREMOVE/REMOVECOMPLETE\n"); if (phdr->dbch_devicetype == DBT_DEVTYP_HANDLE) { DEV_BROADCAST_HANDLE * phandle = (DEV_BROADCAST_HANDLE*)lParam; CAutoWriteLock writeLock(CSVNStatusCache::Instance().GetGuard()); CSVNStatusCache::Instance().CloseWatcherHandles(phandle->dbch_handle); } else if (phdr->dbch_devicetype == DBT_DEVTYP_VOLUME) { DEV_BROADCAST_VOLUME * pVolume = (DEV_BROADCAST_VOLUME*)lParam; CAutoWriteLock writeLock(CSVNStatusCache::Instance().GetGuard()); for (BYTE i = 0; i < 26; ++i) { if (pVolume->dbcv_unitmask & (1 << i)) { TCHAR driveletter = 'A' + i; CString drive = CString(driveletter); drive += L":\\"; CSVNStatusCache::Instance().CloseWatcherHandles(CTSVNPath(drive)); } } } else { CAutoWriteLock writeLock(CSVNStatusCache::Instance().GetGuard()); CSVNStatusCache::Instance().CloseWatcherHandles(0); } break; } } break; default: break; } return DefWindowProc(hWnd, message, wParam, lParam); }
// asynchronous position fix improves stability ULONG AsyncFixThread( LPVOID pParam ) { HWND hWnd = (HWND) pParam; // little delay is needed to guarantee that window is ready for (int x = 0; x < 20; x++) { Sleep(100); if (IsWindow(hWnd) == FALSE) return 0; if (IsWindowVisible(hWnd) == TRUE) break; } Sleep(100); __try { if (IsWindow(hWnd) == TRUE) { if ((GetParent(hWnd) == NULL || ((GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD) == NULL)) && IsWindowVisible(hWnd) == TRUE) { wchar_t className[50]; ZeroString(className, 50); GetClassName(hWnd, className, 50); if (wcslen(className)) { RECT rect = {0, 0, 0, 0}; GetWindowRect(hWnd, &rect); int newY = rect.top; int newHeight = rect.bottom - rect.top; if (FixPosition(hWnd, className, 0, &newY, &newHeight) == TRUE) { SetWindowPos(hWnd, NULL, rect.left, newY, rect.right - rect.left, newHeight, SWP_NOZORDER); } wchar_t windowName[50]; ZeroString(windowName, 50); GetWindowText(hWnd, windowName, 50); DWORD isDoubleFix = IsDoubleFixWindow(hWnd); if (isDoubleFix && (IsSipWindowVisible() == TRUE || isDoubleFix == 2) && ShouldBeProcessed(className) == TRUE) { //RECT rect = {0, 0, 0, 0}; //GetWindowRect(hWnd, &rect); //SetWindowPos(hWnd, NULL, rect.left, rect.top, // rect.right - rect.left, rect.bottom - rect.top, // SWP_NOZORDER); SIPINFO si; GetSipInfo(&si); SHSipInfo(SPI_SETSIPINFO, 0, &si, 0); } } } } } __except (GetExceptionCode()) { } return 0; };
VOID ToolbarCreateGraphs(VOID) { UINT height = (UINT)SendMessage(RebarHandle, RB_GETROWHEIGHT, 0, 0); if (ToolStatusConfig.CpuGraphEnabled && !CpuGraphHandle) { CpuGraphHandle = CreateWindow( PH_GRAPH_CLASSNAME, NULL, WS_VISIBLE | WS_CHILD | WS_BORDER, 0, 0, 0, 0, PhMainWndHandle, NULL, NULL, NULL ); Graph_SetTooltip(CpuGraphHandle, TRUE); PhInitializeGraphState(&CpuGraphState); } if (ToolStatusConfig.MemGraphEnabled && !MemGraphHandle) { MemGraphHandle = CreateWindow( PH_GRAPH_CLASSNAME, NULL, WS_VISIBLE | WS_CHILD | WS_BORDER, 0, 0, 0, 0, PhMainWndHandle, NULL, NULL, NULL ); Graph_SetTooltip(MemGraphHandle, TRUE); PhInitializeGraphState(&MemGraphState); } if (ToolStatusConfig.CommitGraphEnabled && !CommitGraphHandle) { CommitGraphHandle = CreateWindow( PH_GRAPH_CLASSNAME, NULL, WS_VISIBLE | WS_CHILD | WS_BORDER, 0, 0, 0, 0, PhMainWndHandle, NULL, NULL, NULL ); Graph_SetTooltip(CommitGraphHandle, TRUE); PhInitializeGraphState(&CommitGraphState); } if (ToolStatusConfig.IoGraphEnabled && !IoGraphHandle) { IoGraphHandle = CreateWindow( PH_GRAPH_CLASSNAME, NULL, WS_VISIBLE | WS_CHILD | WS_BORDER, 0, 0, 0, 0, PhMainWndHandle, NULL, NULL, NULL ); Graph_SetTooltip(IoGraphHandle, TRUE); PhInitializeGraphState(&IoGraphState); } if (ToolStatusConfig.CpuGraphEnabled) { if (!RebarBandExists(REBAR_BAND_ID_CPUGRAPH)) RebarBandInsert(REBAR_BAND_ID_CPUGRAPH, CpuGraphHandle, 145, height); // 85 if (CpuGraphHandle && !IsWindowVisible(CpuGraphHandle)) ShowWindow(CpuGraphHandle, SW_SHOW); } else { if (RebarBandExists(REBAR_BAND_ID_CPUGRAPH)) RebarBandRemove(REBAR_BAND_ID_CPUGRAPH); if (CpuGraphHandle) { PhDeleteGraphState(&CpuGraphState); DestroyWindow(CpuGraphHandle); CpuGraphHandle = NULL; } } if (ToolStatusConfig.MemGraphEnabled) { if (!RebarBandExists(REBAR_BAND_ID_MEMGRAPH)) RebarBandInsert(REBAR_BAND_ID_MEMGRAPH, MemGraphHandle, 145, height); // 85 if (MemGraphHandle && !IsWindowVisible(MemGraphHandle)) { ShowWindow(MemGraphHandle, SW_SHOW); } } else { if (RebarBandExists(REBAR_BAND_ID_MEMGRAPH)) RebarBandRemove(REBAR_BAND_ID_MEMGRAPH); if (MemGraphHandle) { PhDeleteGraphState(&MemGraphState); DestroyWindow(MemGraphHandle); MemGraphHandle = NULL; } } if (ToolStatusConfig.CommitGraphEnabled) { if (!RebarBandExists(REBAR_BAND_ID_COMMITGRAPH)) RebarBandInsert(REBAR_BAND_ID_COMMITGRAPH, CommitGraphHandle, 145, height); // 85 if (CommitGraphHandle && !IsWindowVisible(CommitGraphHandle)) { ShowWindow(CommitGraphHandle, SW_SHOW); } } else { if (RebarBandExists(REBAR_BAND_ID_COMMITGRAPH)) RebarBandRemove(REBAR_BAND_ID_COMMITGRAPH); if (CommitGraphHandle) { PhDeleteGraphState(&CommitGraphState); DestroyWindow(CommitGraphHandle); CommitGraphHandle = NULL; } } if (ToolStatusConfig.IoGraphEnabled) { if (!RebarBandExists(REBAR_BAND_ID_IOGRAPH)) RebarBandInsert(REBAR_BAND_ID_IOGRAPH, IoGraphHandle, 145, height); // 85 if (IoGraphHandle && !IsWindowVisible(IoGraphHandle)) { ShowWindow(IoGraphHandle, SW_SHOW); } } else { if (RebarBandExists(REBAR_BAND_ID_IOGRAPH)) RebarBandRemove(REBAR_BAND_ID_IOGRAPH); if (IoGraphHandle) { PhDeleteGraphState(&IoGraphState); DestroyWindow(IoGraphHandle); IoGraphHandle = NULL; } } }
static void AddOrUpdateHwnd(HWND hWnd, WCHAR *wszTitle, HICON hIcon, BOOL bHung) { LPAPPLICATION_PAGE_LIST_ITEM pAPLI = NULL; HIMAGELIST hImageListLarge; HIMAGELIST hImageListSmall; LV_ITEMW item; int i, count; BOOL bAlreadyInList = FALSE; BOOL bItemRemoved = FALSE; memset(&item, 0, sizeof(LV_ITEMW)); /* Get the image lists */ hImageListLarge = (HIMAGELIST)SendMessageW(hApplicationPageListCtrl, LVM_GETIMAGELIST, LVSIL_NORMAL, 0); hImageListSmall = (HIMAGELIST)SendMessageW(hApplicationPageListCtrl, LVM_GETIMAGELIST, LVSIL_SMALL, 0); count = SendMessageW(hApplicationPageListCtrl, LVM_GETITEMCOUNT, 0, 0); /* Check to see if it's already in our list */ for (i=0; i<count; i++) { memset(&item, 0, sizeof(LV_ITEMW)); item.mask = LVIF_IMAGE|LVIF_PARAM; item.iItem = i; SendMessageW(hApplicationPageListCtrl, LVM_GETITEMW, 0, (LPARAM) &item); pAPLI = (LPAPPLICATION_PAGE_LIST_ITEM)item.lParam; if (pAPLI->hWnd == hWnd) { bAlreadyInList = TRUE; break; } } /* If it is already in the list then update it if necessary */ if (bAlreadyInList) { /* Check to see if anything needs updating */ if ((pAPLI->hIcon != hIcon) || (strcmpW(pAPLI->wszTitle, wszTitle) != 0) || (pAPLI->bHung != bHung)) { /* Update the structure */ pAPLI->hIcon = hIcon; pAPLI->bHung = bHung; strcpyW(pAPLI->wszTitle, wszTitle); /* Update the image list */ ImageList_ReplaceIcon(hImageListLarge, item.iItem, hIcon); ImageList_ReplaceIcon(hImageListSmall, item.iItem, hIcon); /* Update the list view */ count = SendMessageW(hApplicationPageListCtrl, LVM_GETITEMCOUNT, 0, 0); SendMessageW(hApplicationPageListCtrl, LVM_REDRAWITEMS, 0, count); /* UpdateWindow(hApplicationPageListCtrl); */ InvalidateRect(hApplicationPageListCtrl, NULL, 0); } } /* It is not already in the list so add it */ else { pAPLI = HeapAlloc(GetProcessHeap(), 0, sizeof(APPLICATION_PAGE_LIST_ITEM)); pAPLI->hWnd = hWnd; pAPLI->hIcon = hIcon; pAPLI->bHung = bHung; strcpyW(pAPLI->wszTitle, wszTitle); /* Add the item to the list */ memset(&item, 0, sizeof(LV_ITEMW)); item.mask = LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM; ImageList_AddIcon(hImageListLarge, hIcon); item.iImage = ImageList_AddIcon(hImageListSmall, hIcon); item.pszText = LPSTR_TEXTCALLBACKW; item.iItem = SendMessageW(hApplicationPageListCtrl, LVM_GETITEMCOUNT, 0, 0); item.lParam = (LPARAM)pAPLI; SendMessageW(hApplicationPageListCtrl, LVM_INSERTITEMW, 0, (LPARAM) &item); } /* Check to see if we need to remove any items from the list */ for (i=SendMessageW(hApplicationPageListCtrl, LVM_GETITEMCOUNT, 0, 0)-1; i>=0; i--) { memset(&item, 0, sizeof(LV_ITEMW)); item.mask = LVIF_IMAGE|LVIF_PARAM; item.iItem = i; SendMessageW(hApplicationPageListCtrl, LVM_GETITEMW, 0, (LPARAM) &item); pAPLI = (LPAPPLICATION_PAGE_LIST_ITEM)item.lParam; if (!IsWindow(pAPLI->hWnd)|| (strlenW(pAPLI->wszTitle) <= 0) || !IsWindowVisible(pAPLI->hWnd) || (GetParent(pAPLI->hWnd) != NULL) || (GetWindow(pAPLI->hWnd, GW_OWNER) != NULL) || (GetWindowLongW(hWnd, GWL_EXSTYLE) & WS_EX_TOOLWINDOW)) { ImageList_Remove(hImageListLarge, item.iItem); ImageList_Remove(hImageListSmall, item.iItem); SendMessageW(hApplicationPageListCtrl, LVM_DELETEITEM, item.iItem, 0); HeapFree(GetProcessHeap(), 0, pAPLI); bItemRemoved = TRUE; } } /* * If an item was removed from the list then * we need to resync all the items with the * image list */ if (bItemRemoved) { count = SendMessageW(hApplicationPageListCtrl, LVM_GETITEMCOUNT, 0, 0); for (i=0; i<count; i++) { memset(&item, 0, sizeof(LV_ITEMW)); item.mask = LVIF_IMAGE; item.iItem = i; item.iImage = i; SendMessageW(hApplicationPageListCtrl, LVM_SETITEMW, 0, (LPARAM) &item); } } ApplicationPageUpdate(); }
void CTabPanelWin::RepositionInt() { RECT client, self; client = gpConEmu->GetGuiClientRect(); GetWindowRect(mh_Tabbar, &self); if (mh_Rebar) { SIZE sz = {0,0}; int nBarIndex = -1; BOOL lbNeedShow = FALSE, lbWideEnough = FALSE; if (mh_Toolbar) { nBarIndex = SendMessage(mh_Rebar, RB_IDTOINDEX, 2, 0); if (gpSet->isMultiShowButtons) { SendMessage(mh_Toolbar, TB_GETMAXSIZE, 0, (LPARAM)&sz); sz.cx += (gpSet->isHideCaptionAlways() ? gpSet->nToolbarAddSpace : 0); lbWideEnough = (sz.cx + 150) <= client.right; if (!lbWideEnough) { if (IsWindowVisible(mh_Toolbar)) SendMessage(mh_Rebar, RB_SHOWBAND, nBarIndex, 0); } else { if (!IsWindowVisible(mh_Toolbar)) lbNeedShow = TRUE; } } else { SendMessage(mh_Rebar, RB_SHOWBAND, nBarIndex, 0); } } if (gpSet->nTabsLocation == 1) { int nStatusHeight = gpSet->isStatusBarShow ? gpSet->StatusBarHeight() : 0; MoveWindow(mh_Rebar, 0, client.bottom-nStatusHeight-mn_TabHeight, client.right, mn_TabHeight, 1); } else { MoveWindow(mh_Rebar, 0, 0, client.right, mn_TabHeight, 1); } // Не будем пока трогать. Некрасиво табы рисуются. Нужно на OwnerDraw переходить. #if 0 DWORD nCurStyle = GetWindowLong(mh_Tabbar, GWL_STYLE); DWORD nNeedStyle = (gpSet->nTabsLocation == 1) ? (nCurStyle | TCS_BOTTOM) : (nCurStyle & ~TCS_BOTTOM); if (nNeedStyle != nCurStyle) { SetWindowLong(mh_Tabbar, GWL_STYLE, nNeedStyle); //_ASSERTE(!gpSet->isTabFrame); if (gpSet->nTabsLocation == 1) { RECT rcTab = client; GetWindowRect(mh_Tabbar, &rcTab); SetWindowPos(mh_Tabbar, NULL, 0, client.bottom - (rcTab.bottom-rcTab.top), 0,0, SWP_NOSIZE); } else { SetWindowPos(mh_Tabbar, NULL, 0,0, 0,0, SWP_NOSIZE); } } #endif //if (gpSet->nTabsLocation == 1) // m_Margins = MakeRect(0,0,0,mn_TabHeight); //else // m_Margins = MakeRect(0,mn_TabHeight,0,0); //gpSet->UpdateMargins(m_Margins); if (lbWideEnough && nBarIndex != 1) { SendMessage(mh_Rebar, RB_MOVEBAND, nBarIndex, 1); nBarIndex = SendMessage(mh_Rebar, RB_IDTOINDEX, 2, 0); _ASSERTE(nBarIndex == 1); } if (lbNeedShow) { SendMessage(mh_Rebar, RB_SHOWBAND, nBarIndex, 1); } } //else if (gpSet->isTabFrame) //{ // MoveWindow(mh_Tabbar, 0, 0, client.right, client.bottom, 1); //} else { MoveWindow(mh_Tabbar, 0, 0, client.right, mn_TabHeight, 1); } UpdateToolbarPos(); }
void ReplaceGuiAppWindow(BOOL abStyleHidden) { if (!ghAttachGuiClient) { _ASSERTEX(ghAttachGuiClient!=NULL); return; } DWORD_PTR dwStyle = user->getWindowLongPtrW(ghAttachGuiClient, GWL_STYLE); DWORD_PTR dwStyleEx = user->getWindowLongPtrW(ghAttachGuiClient, GWL_EXSTYLE); if (!gbAttachGuiClientStyleOk) { gbAttachGuiClientStyleOk = TRUE; gnAttachGuiClientStyle = (DWORD)dwStyle; gnAttachGuiClientStyleEx = (DWORD)dwStyleEx; } // Позвать user->getWindowRect(ghAttachGuiClient, &grcAttachGuiClientOrig); если надо CheckOrigGuiClientRect(); if (!gbGuiClientExternMode) { // DotNet: если не включить WS_CHILD - не работают toolStrip & menuStrip // Native: если включить WS_CHILD - исчезает оконное меню DWORD_PTR dwNewStyle = dwStyle & ~(WS_MAXIMIZEBOX|WS_MINIMIZEBOX); if (gnAttachGuiClientFlags & agaf_WS_CHILD) dwNewStyle = (dwNewStyle|WS_CHILD/*|DS_CONTROL*/) & ~(WS_POPUP); if (dwStyle != dwNewStyle) user->setWindowLongPtrW(ghAttachGuiClient, GWL_STYLE, dwNewStyle); /* DWORD_PTR dwNewStyleEx = (dwStyleEx|WS_EX_CONTROLPARENT); if (dwStyleEx != dwNewStyleEx) user->setWindowLongPtrW(ghAttachGuiClient, GWL_EXSTYLE, dwNewStyleEx); */ HWND hCurParent = user->getParent(ghAttachGuiClient); _ASSERTEX(ghConEmuWndBack && user->isWindow(ghConEmuWndBack)); if (hCurParent != ghConEmuWndBack) { user->setParent(ghAttachGuiClient, ghConEmuWndBack); } RECT rcGui = AttachGuiClientPos(); if (user->setWindowPos(ghAttachGuiClient, HWND_TOP, rcGui.left,rcGui.top, rcGui.right-rcGui.left, rcGui.bottom-rcGui.top, SWP_DRAWFRAME | SWP_NOCOPYBITS | /*SWP_FRAMECHANGED |*/ (abStyleHidden ? SWP_SHOWWINDOW : 0))) { if (abStyleHidden && IsWindowVisible(ghAttachGuiClient)) abStyleHidden = FALSE; } // !!! OnSetForegroundWindow не подходит - он дергает Cmd. user->setForegroundWindow(ghConEmuWnd); user->postMessageW(ghAttachGuiClient, WM_NCPAINT, 0, 0); } }
void CSListView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) { // TODO: Add your specialized code here and/or call the base class if( UPDATE_HINT_SLISTVIEW != lHint ) return; if( IsWindowVisible() ) SetFocus( ); int nColumnCount = m_Grid.GetColumnCount(); if( nColumnCount <= 0 ) return; if( GetParentFrame()->GetSafeHwnd() != AfxGetMainFrame()->GetActiveFrame()->GetSafeHwnd() ) { m_bShouldUpdate = TRUE; return; } m_bShouldUpdate = FALSE; CStockContainer & container = AfxGetSListStockContainer(); container.Lock(); m_Grid.DeleteNonFixedRows(); // Progress CUIntArray anParams; anParams.SetSize( 0, nColumnCount ); for( int nCol=0; nCol < nColumnCount; nCol ++ ) { LPARAM lParam = m_Grid.GetItemData( 0, nCol ); anParams.Add( lParam ); } CRect rectClient; GetClientRect( &rectClient ); int nPageCount = 1 + rectClient.Height() / abs(m_Grid.GetFixedRowHeight()) + 1; /** disabled for( int i=0; i<container.GetSize(); i++ ) { CStockInfo & info = container.GetStockInfoByID(i); int nRow = m_Grid.InsertRow( info.GetStockName() ); m_Grid.SetItemData( nRow, 0, i ); for( int nCol=0; nCol<anParams.GetSize(); nCol++ ) { m_Grid.SetItemFormat( nRow, nCol, DT_CENTER|DT_VCENTER|DT_SINGLELINE ); m_Grid.SetItemText( nRow, nCol, AfxGetVariantDispString( anParams[nCol], info, &container ) ); m_Grid.SetItemBkColour( nRow, nCol, AfxGetProfile().GetColor(CColorClass::clrSListBK) ); m_Grid.SetItemFgColour( nRow, nCol, AfxGetVariantColor( anParams[nCol], info ) ); if( anParams[nCol] == SLH_DATE ) m_Grid.SetColumnWidth( nCol, 80 ); } if( i == nPageCount+5 ) { m_Grid.Invalidate( ); MSG msg; while (::PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE) ) AfxGetApp()->PumpMessage(); } if( pMainFrame ) pMainFrame->SetProgress( 100*i/container.GetSize() ); } // Set Average and Weight Average SetAverageItem( m_Grid, container, FALSE ); // Sort If Needed if( -1 != m_nColSort ) { LPARAM lParam = m_Grid.GetItemData( 0, m_nColSort ); if( lParam >= 0 ) { CStockContainer::m_pSortContainer = &container; container.m_nSortVariantID = lParam; container.m_bSortAscend = m_bSortAscend; m_Grid.SortItems( ItemCompareFunc, 0, TRUE ); } } */ for(int i= 0;i<1;i++) { int nRow = m_Grid.InsertRow( "sz002376"); m_Grid.SetItemData( nRow, 0, i ); const char * paramValues [] = {"新北洋","sz002376","1000","1000","1000","17.74","19.08","17740","-1340.0"}; for( int nCol=0; nCol<9; nCol++ ) { m_Grid.SetItemFormat( nRow, nCol, DT_CENTER|DT_VCENTER|DT_SINGLELINE ); m_Grid.SetItemText( nRow, nCol, paramValues[nCol] ); m_Grid.SetItemBkColour( nRow, nCol, AfxGetProfile().GetColor(CColorClass::clrSListBK) ); //m_Grid.SetItemFgColour( nRow, nCol, ); if( anParams[nCol] == SLH_DATE ) m_Grid.SetColumnWidth( nCol, 80 ); } } int nRow = m_Grid.InsertRow( "summary"); //m_Grid.SetItemData( nRow, 0, 1 ); const char * sumValues [] = {"","","","","","","合计(人民币)","17740","-1340.0"}; for( int ic=0; ic<9; ic++ ) { m_Grid.SetItemFormat( nRow, ic, DT_CENTER|DT_VCENTER|DT_SINGLELINE ); m_Grid.SetItemText( nRow, ic, sumValues[ic] ); m_Grid.SetItemBkColour( nRow, 0, AfxGetProfile().GetColor(CColorClass::clrSListBK) ); } nRow = m_Grid.InsertRow( "blank"); m_Grid.SetItemText( nRow, 0, "" ); m_Grid.SetItemBkColour( nRow, 0, AfxGetProfile().GetColor(CColorClass::clrSListBK) ); //m_Grid.SetItemData( nRow, 0, 1 ); nRow = m_Grid.InsertRow( "allheader"); const char * allValues [] = {"币种","资金余额","可用资金","可取资金","证券市值","资产总值","","",""}; for( ic=0; ic<9; ic++ ) { m_Grid.SetItemFormat( nRow, ic, DT_CENTER|DT_VCENTER|DT_SINGLELINE ); m_Grid.SetItemText( nRow, ic, allValues[ic] ); m_Grid.SetItemBkColour( nRow, ic, AfxGetProfile().GetColor(CColorClass::clrSListBK) ); m_Grid.SetItemFgColour( nRow, ic, 0x00ff0000 ); LOGFONT *pfont = m_Grid.GetItemFont(nRow,ic); pfont->lfWeight = 700; m_Grid.SetItemFont(nRow,ic,pfont); } nRow = m_Grid.InsertRow( "alldata"); const char * alldataValues [] = {"人民币","2163.99","2163.99","2163.99","17740","19903.99","","",""}; for( ic=0; ic<9; ic++ ) { m_Grid.SetItemFormat( nRow, ic, DT_CENTER|DT_VCENTER|DT_SINGLELINE ); m_Grid.SetItemText( nRow, ic, alldataValues[ic] ); m_Grid.SetItemBkColour( nRow, ic, AfxGetProfile().GetColor(CColorClass::clrSListBK) ); } if( m_bFirstUpdate ) m_Grid.AutoSizeColumns( ); else m_Grid.SetColumnWidth( 0, 80 ); m_bFirstUpdate = FALSE; m_Grid.Invalidate( ); //SendRequestQuote(TRUE); container.UnLock(); }
static BOOL CALLBACK ListWndProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam) { static BOOL ListSearchWndShow; switch (uMess){ case WM_INITDIALOG: ListSearchWndShow = 0; InitListSearchWnd(hwnd); SendDlgItemMessage(hwnd,IDC_LISTBOX_PLAYLIST, LB_SETHORIZONTALEXTENT,(WPARAM)LISTWND_HORIZONTALEXTENT,0); w32g_send_rc(RC_EXT_UPDATE_PLAYLIST, 0); SetWindowPosSize(GetDesktopWindow(),hwnd,ListWndInfo.PosX, ListWndInfo.PosY ); return FALSE; case WM_DESTROY: { RECT rc; GetWindowRect(hwnd,&rc); ListWndInfo.Width = rc.right - rc.left; ListWndInfo.Height = rc.bottom - rc.top; } DestroyMenu(ListWndInfo.hPopupMenu); ListWndInfo.hPopupMenu = NULL; INISaveListWnd(); break; /* マウス入力がキャプチャされていないための処理 */ case WM_SETCURSOR: switch(HIWORD(lParam)){ case WM_RBUTTONDOWN: if(LOWORD(lParam)!=HTCAPTION){ // タイトルバーにないとき POINT point; int res; GetCursorPos(&point); SetForegroundWindow ( hwnd ); res = TrackPopupMenu(ListWndInfo.hPopupMenu,TPM_TOPALIGN|TPM_LEFTALIGN, point.x,point.y,0,hwnd,NULL); PostMessage ( hwnd, WM_NULL, 0, 0 ); return TRUE; } break; default: break; } break; case WM_CHOOSEFONT_DIAG: { char fontName[64]; int fontHeight; int fontWidth; strcpy(fontName,ListWndInfo.fontName); fontHeight = ListWndInfo.fontHeight; fontWidth = ListWndInfo.fontWidth; if(DlgChooseFont(hwnd,fontName,&fontHeight,&fontWidth)==0){ ListWndSetFontListBox(fontName,fontWidth,fontHeight); } } break; case WM_LIST_SEARCH_DIAG: ShowListSearch(); break; case WM_COMMAND: switch (HIWORD(wParam)) { case IDCLOSE: ShowWindow(hwnd, SW_HIDE); MainWndUpdateListButton(); break; case LBN_DBLCLK: SendMessage(hwnd,WM_COMMAND,(WPARAM)IDM_LISTWND_PLAY,0); return FALSE; case LBN_SELCHANGE: { int idListBox = (int) LOWORD(wParam); HWND hwndListBox = (HWND) lParam; int selected, nfiles, cursel; w32g_get_playlist_index(&selected,&nfiles,&cursel); SetNumListWnd(cursel,nfiles); return FALSE; } default: break; } switch (LOWORD(wParam)) { case IDC_BUTTON_CLEAR: if(MessageBox(hListWnd,"Clear playlist?","Playlist", MB_YESNO)==IDYES) w32g_send_rc(RC_EXT_CLEAR_PLAYLIST, 0); return FALSE; case IDC_BUTTON_REFINE: if(MessageBox(hListWnd, "Remove unsupported file types from the playlist?", "Playlist",MB_YESNO) == IDYES) w32g_send_rc(RC_EXT_REFINE_PLAYLIST, 0); return FALSE; case IDC_BUTTON_UNIQ: if(MessageBox(hListWnd, "Remove the same files from the playlist and make files of the playlist unique?", "Playlist",MB_YESNO)==IDYES) w32g_send_rc(RC_EXT_UNIQ_PLAYLIST, 0); return FALSE; case IDM_LISTWND_REMOVE: w32g_send_rc(RC_EXT_DELETE_PLAYLIST, 0); break; case IDC_BUTTON_DOC: { int cursel; w32g_get_playlist_index(NULL, NULL, &cursel); w32g_send_rc(RC_EXT_OPEN_DOC, cursel); } break; case IDM_LISTWND_PLAY: { int new_cursel = SendDlgItemMessage(hwnd,IDC_LISTBOX_PLAYLIST,LB_GETCURSEL,0,0); int selected, nfiles, cursel; w32g_get_playlist_index(&selected, &nfiles, &cursel); if ( nfiles <= new_cursel ) new_cursel = nfiles - 1; if ( new_cursel >= 0 ) w32g_send_rc(RC_EXT_JUMP_FILE, new_cursel ); } return FALSE; case IDM_LISTWND_CHOOSEFONT: { SendMessage(hwnd,WM_CHOOSEFONT_DIAG,0,0); } return FALSE; case IDM_LISTWND_CURRENT: { int selected, nfiles, cursel; w32g_get_playlist_index(&selected, &nfiles, &cursel); SendDlgItemMessage(hwnd,IDC_LISTBOX_PLAYLIST, LB_SETCURSEL,(WPARAM)selected,0); SetNumListWnd(selected,nfiles); } return FALSE; case IDM_LISTWND_SEARCH: { SendMessage(hwnd,WM_LIST_SEARCH_DIAG,0,0); } return FALSE; default: break; } break; case WM_VKEYTOITEM: { UINT vkey = (UINT)LOWORD(wParam); int nCaretPos = (int)HIWORD(wParam); switch(vkey){ case VK_SPACE: case VK_RETURN: w32g_send_rc(RC_EXT_JUMP_FILE, nCaretPos); return -2; case 0x50: // VK_P SendMessage(hMainWnd,WM_COMMAND,MAKEWPARAM(IDM_PREV,0),0); return -2; case 0x4e: // VK_N SendMessage(hMainWnd,WM_COMMAND,MAKEWPARAM(IDM_NEXT,0),0); return -2; case 0x45: // VK_E SendMessage(hMainWnd,WM_COMMAND,MAKEWPARAM(IDM_STOP,0),0); return -2; case 0x53: // VK_S SendMessage(hMainWnd,WM_COMMAND,MAKEWPARAM(IDM_PAUSE,0),0); return -2; case VK_ESCAPE: SendMessage(hListWnd,WM_COMMAND,MAKEWPARAM(0,IDCLOSE),0); return -2; case 0x51: // VK_Q if(MessageBox(hListWnd,"Quit TiMidity?","TiMidity",MB_ICONQUESTION|MB_YESNO)==IDYES) SendMessage(hMainWnd,WM_CLOSE,0,0); return -2; case VK_BACK: w32g_send_rc(RC_EXT_DELETE_PLAYLIST, -1); return -2; case 0x44: // VK_D w32g_send_rc(RC_EXT_DELETE_PLAYLIST, 0); return -2; case VK_DELETE: w32g_send_rc(RC_EXT_ROTATE_PLAYLIST, -1); return -2; case VK_INSERT: w32g_send_rc(RC_EXT_ROTATE_PLAYLIST, 1); return -2; case 0x46: // VK_F return -2; case 0x42: // VK_B return -2; case 0x4D: // VK_M SendMessage(hListWnd,WM_COMMAND,MAKEWPARAM(IDC_BUTTON_REFINE,0),0); return -2; case 0x43: // VK_C SendMessage(hListWnd,WM_COMMAND,MAKEWPARAM(IDC_BUTTON_CLEAR,0),0); return -2; case 0x55: // VK_U SendMessage(hListWnd,WM_COMMAND,MAKEWPARAM(IDC_BUTTON_UNIQ,0),0); return -2; case 0x56: // VK_V SendMessage(hListWnd,WM_COMMAND,MAKEWPARAM(IDC_BUTTON_DOC,0),0); return -2; case 0x57: // VK_W SendMessage(hMainWnd,WM_COMMAND,MAKEWPARAM(IDM_WRD,0),0); return -2; case VK_F1: case 0x48: // VK_H if ( PlayerLanguage == LANGUAGE_JAPANESE ){ MessageBox(hListWnd, "キーコマンド\n" "リストウインドウコマンド\n" " ESC: ヘルプを閉じる H: ヘルプを出す\n" " V: ドキュメントを見る W: WRD ウインドウを開く\n" "プレイヤーコマンド\n" " SPACE/ENTER: 演奏開始 E: 停止 S: 一時停止\n" " P: 前の曲 N: 次の曲\n" "プレイリスト操作コマンド\n" " M: MIDIファイル以外を削除 U: 重複ファイルを削除\n" " C: プレイリストのクリア\n" " D: カーソルの曲を削除 BS: カーソルの前の曲を削除\n" " INS: カーソルの曲をリストの最後に移す (Push)\n" " DEL: リストの最後の曲をカーソルの前に挿入 (Pop)\n" "TiMidity コマンド\n" " Q: 終了\n" ,"ヘルプ", MB_OK); } else { MessageBox(hListWnd, "Usage of key.\n" "List window command.\n" " ESC: Close Help H: Help\n" " V: View Document W: Open WRD window\n" "Player command.\n" " SPACE/ENTER: PLAY E: Stop S: Pause\n" " P: Prev N: Next\n" "Playlist command.\n" " M: Refine playlist U: Uniq playlist\n" " C: Clear playlist\n" " D: Remove playlist BS: Remove previous playlist\n" " INS: Push Playlist DEL: Pop Playlist\n" "TiMidity command.\n" " Q: Quit\n" ,"Help", MB_OK); } return -2; default: break; } return -1; } case WM_SIZE: switch(wParam){ case SIZE_MAXIMIZED: case SIZE_RESTORED: { // なんか意味なく面倒(^^;; int x,y,cx,cy; int maxHeight = 0; int center, idControl; HWND hwndChild; RECT rcParent, rcChild, rcRest; int nWidth = LOWORD(lParam); int nHeight = HIWORD(lParam); GetWindowRect(hwnd,&rcParent); cx = rcParent.right-rcParent.left; cy = rcParent.bottom-rcParent.top; if(cx < 380) MoveWindow(hwnd,rcParent.left,rcParent.top,380,cy,TRUE); if(cy < 200) MoveWindow(hwnd,rcParent.left,rcParent.top,cx,200,TRUE); GetClientRect(hwnd,&rcParent); rcRest.left = rcParent.left; rcRest.right = rcParent.right; // IDC_EDIT_NUM idControl = IDC_EDIT_NUM; hwndChild = GetDlgItem(hwnd,idControl); GetWindowRect(hwndChild,&rcChild); cx = rcChild.right-rcChild.left; cy = rcChild.bottom-rcChild.top; x = rcParent.left; y = rcParent.bottom - cy; MoveWindow(hwndChild,x,y,cx,cy,TRUE); if(cy>maxHeight) maxHeight = cy; rcRest.left += cx; // IDC_BUTTON_DOC idControl = IDC_BUTTON_DOC; hwndChild = GetDlgItem(hwnd,idControl); GetWindowRect(hwndChild,&rcChild); cx = rcChild.right-rcChild.left; cy = rcChild.bottom-rcChild.top; x = rcRest.left + 10; y = rcParent.bottom - cy; MoveWindow(hwndChild,x,y,cx,cy,TRUE); if(cy>maxHeight) maxHeight = cy; rcRest.left += cx; // IDC_BUTTON_CLEAR idControl = IDC_BUTTON_CLEAR; hwndChild = GetDlgItem(hwnd,idControl); GetWindowRect(hwndChild,&rcChild); cx = rcChild.right-rcChild.left; cy = rcChild.bottom-rcChild.top; x = rcParent.right - cx - 5; y = rcParent.bottom - cy ; MoveWindow(hwndChild,x,y,cx,cy,TRUE); if(cy>maxHeight) maxHeight = cy; rcRest.right -= cx + 5; // IDC_BUTTON_UNIQ center = rcRest.left + (int)((rcRest.right - rcRest.left)*0.52); idControl = IDC_BUTTON_UNIQ; hwndChild = GetDlgItem(hwnd,idControl); GetWindowRect(hwndChild,&rcChild); cx = rcChild.right-rcChild.left; cy = rcChild.bottom-rcChild.top; x = center - cx; y = rcParent.bottom - cy; MoveWindow(hwndChild,x,y,cx,cy,TRUE); if(cy>maxHeight) maxHeight = cy; // IDC_BUTTON_REFINE idControl = IDC_BUTTON_REFINE; hwndChild = GetDlgItem(hwnd,idControl); GetWindowRect(hwndChild,&rcChild); cx = rcChild.right-rcChild.left; cy = rcChild.bottom-rcChild.top; x = center + 3; y = rcParent.bottom - cy; MoveWindow(hwndChild,x,y,cx,cy,TRUE); if(cy>maxHeight) maxHeight = cy; // IDC_LISTBOX_PLAYLIST idControl = IDC_LISTBOX_PLAYLIST; hwndChild = GetDlgItem(hwnd,idControl); cx = rcParent.right - rcParent.left; cy = rcParent.bottom - rcParent.top - maxHeight - 3; x = rcParent.left; y = rcParent.top; MoveWindow(hwndChild,x,y,cx,cy,TRUE); InvalidateRect(hwnd,&rcParent,FALSE); UpdateWindow(hwnd); GetWindowRect(hwnd,&rcParent); ListWndInfo.Width = rcParent.right - rcParent.left; ListWndInfo.Height = rcParent.bottom - rcParent.top; break; } case SIZE_MINIMIZED: case SIZE_MAXHIDE: case SIZE_MAXSHOW: default: break; } break; case WM_MOVE: // ListWndInfo.PosX = (int) LOWORD(lParam); // ListWndInfo.PosY = (int) HIWORD(lParam); { RECT rc; GetWindowRect(hwnd,&rc); ListWndInfo.PosX = rc.left; ListWndInfo.PosY = rc.top; } break; // See PreDispatchMessage() in w32g2_main.c case WM_SYSKEYDOWN: case WM_KEYDOWN: { int nVirtKey = (int)wParam; switch(nVirtKey){ case VK_ESCAPE: SendMessage(hwnd,WM_CLOSE,0,0); break; } } break; case WM_CLOSE: ShowSubWindow(hListWnd,0); // ShowWindow(hListWnd, SW_HIDE); MainWndUpdateListButton(); break; case WM_SHOWWINDOW: { BOOL fShow = (BOOL)wParam; if ( fShow ) { if ( ListSearchWndShow ) { ShowListSearch(); } else { HideListSearch(); } } else { if ( IsWindowVisible ( hListSearchWnd ) ) ListSearchWndShow = TRUE; else ListSearchWndShow = FALSE; HideListSearch(); } } break; case WM_DROPFILES: SendMessage(hMainWnd,WM_DROPFILES,wParam,lParam); return 0; default: return FALSE; } return FALSE; }
void drawWindow(MyWindow* currentWindow, float zOrder){ DWORD winStyle = GetWindowLong(currentWindow->hwnd, GWL_STYLE); if(IsWindowVisible(currentWindow->hwnd)){ BITMAP bitmap; HBITMAP hbmp; //find all childs and sort them according to z-order //draw all window on mainWindowpos + relative coord //myFinder->getAnchorWindow()->draw(); glBindTexture(GL_TEXTURE_2D, screenTexture); hbmp = currentWindow->getHBitmap(); currentWindow->convertToDib(hbmp); GetObject (hbmp, sizeof(BITMAP), &bitmap); int data_size = bitmap.bmWidth * bitmap.bmHeight * 4; //RGB to BGR (ou l'autre, j'en ai plus aucune idée) bool isFullyBlack = 1; for (int i=0; i<data_size; i+=4){ // Bitmap failed to be captured if(bitmap.bmBits == NULL){ return; } unsigned char tmp = ((unsigned char*)bitmap.bmBits)[i]; ((unsigned char*)bitmap.bmBits)[i] = ((unsigned char*)bitmap.bmBits)[i+2]; ((unsigned char*)bitmap.bmBits)[i+2] = tmp; unsigned char* vals = (unsigned char*) bitmap.bmBits; if(vals[0]!=0 && vals[1]!=0 && vals[2]!=0){ isFullyBlack = 0; } } if(isFullyBlack){ return; } glTexImage2D(GL_TEXTURE_2D,0,4,bitmap.bmWidth,bitmap.bmHeight,0,GL_RGBA, GL_UNSIGNED_BYTE, bitmap.bmBits); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); //Draw texture int width = bitmap.bmWidth; int height = bitmap.bmHeight; glBegin(GL_TRIANGLE_STRIP); glColor4f(1,1,1,1); float left,right; float bottom,top; RECT position; GetWindowRect(currentWindow->hwnd, &position); float scale = 50; if(currentWindow->parent!=NULL){ MapWindowPoints(HWND_DESKTOP, currentWindow->parent->hwnd, (LPPOINT) &position, 2); position.left += currentWindow->parent->winPos.left; position.top += currentWindow->parent->winPos.top; position.right += currentWindow->parent->winPos.left; position.bottom += currentWindow->parent->winPos.top; } else{ position.top -= (float)GetSystemMetrics(SM_CYSCREEN)/2 ; position.bottom -= (float)GetSystemMetrics(SM_CYSCREEN)/2; position.left -= (float)GetSystemMetrics(SM_CXSCREEN)/2 ; position.right -= (float)GetSystemMetrics(SM_CXSCREEN)/2 ; currentWindow->adjustConfiguration(&position, scale); } currentWindow->winPos = position; left = position.left; right = position.right; top = -position.top; bottom = top-(float)height; top/=scale; left/=scale; bottom/=scale; right/=scale; glTexCoord2f(0,0); glVertex3f(left,bottom,currentWindow->leftZOrder); glTexCoord2f(1,0); glVertex3f(right, bottom,currentWindow->rightZOrder); glTexCoord2f(0,1); glVertex3f(left, top,currentWindow->leftZOrder); glTexCoord2f(1,1); glVertex3f(right, top,currentWindow->rightZOrder); glEnd(); DeleteObject(hbmp); } for(int i = 0; i < currentWindow->childList.size();i++){ MyWindow* child = currentWindow->childList.front(); currentWindow->childList.pop_front(); float deltaZOrder = (float)(currentWindow->childList.size()-i)/(currentWindow->childList.size()*10000); drawWindow(child,zOrder+deltaZOrder); currentWindow->childList.push_back(child); } }
EXPORT_C GSReplay(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) { int renderer = -1; { char* start = lpszCmdLine; char* end = NULL; long n = strtol(lpszCmdLine, &end, 10); if(end > start) {renderer = n; lpszCmdLine = end;} } while(*lpszCmdLine == ' ') lpszCmdLine++; ::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS); if(FILE* fp = fopen(lpszCmdLine, "rb")) { Console console("GSdx", true); GSinit(); uint8 regs[0x2000]; GSsetBaseMem(regs); s_vsync = !!theApp.GetConfig("vsync", 0); HWND hWnd = NULL; _GSopen((void**)&hWnd, "", renderer); uint32 crc; fread(&crc, 4, 1, fp); GSsetGameCRC(crc, 0); GSFreezeData fd; fread(&fd.size, 4, 1, fp); fd.data = new uint8[fd.size]; fread(fd.data, fd.size, 1, fp); GSfreeze(FREEZE_LOAD, &fd); delete [] fd.data; fread(regs, 0x2000, 1, fp); long start = ftell(fp); GSvsync(1); struct Packet {uint8 type, param; uint32 size, addr; vector<uint8> buff;}; list<Packet*> packets; vector<uint8> buff; int type; while((type = fgetc(fp)) != EOF) { Packet* p = new Packet(); p->type = (uint8)type; switch(type) { case 0: p->param = (uint8)fgetc(fp); fread(&p->size, 4, 1, fp); switch(p->param) { case 0: p->buff.resize(0x4000); p->addr = 0x4000 - p->size; fread(&p->buff[p->addr], p->size, 1, fp); break; case 1: case 2: case 3: p->buff.resize(p->size); fread(&p->buff[0], p->size, 1, fp); break; } break; case 1: p->param = (uint8)fgetc(fp); break; case 2: fread(&p->size, 4, 1, fp); break; case 3: p->buff.resize(0x2000); fread(&p->buff[0], 0x2000, 1, fp); break; } packets.push_back(p); } Sleep(100); while(IsWindowVisible(hWnd)) { for(list<Packet*>::iterator i = packets.begin(); i != packets.end(); i++) { Packet* p = *i; switch(p->type) { case 0: switch(p->param) { case 0: GSgifTransfer1(&p->buff[0], p->addr); break; case 1: GSgifTransfer2(&p->buff[0], p->size / 16); break; case 2: GSgifTransfer3(&p->buff[0], p->size / 16); break; case 3: GSgifTransfer(&p->buff[0], p->size / 16); break; } break; case 1: GSvsync(p->param); break; case 2: if(buff.size() < p->size) buff.resize(p->size); GSreadFIFO2(&buff[0], p->size / 16); break; case 3: memcpy(regs, &p->buff[0], 0x2000); break; } } } for(list<Packet*>::iterator i = packets.begin(); i != packets.end(); i++) { delete *i; } packets.clear(); Sleep(100); /* vector<uint8> buff; bool exit = false; int round = 0; while(!exit) { uint32 index; uint32 size; uint32 addr; int pos; switch(fgetc(fp)) { case EOF: fseek(fp, start, 0); exit = !IsWindowVisible(hWnd); //exit = ++round == 60; break; case 0: index = fgetc(fp); fread(&size, 4, 1, fp); switch(index) { case 0: if(buff.size() < 0x4000) buff.resize(0x4000); addr = 0x4000 - size; fread(&buff[addr], size, 1, fp); GSgifTransfer1(&buff[0], addr); break; case 1: if(buff.size() < size) buff.resize(size); fread(&buff[0], size, 1, fp); GSgifTransfer2(&buff[0], size / 16); break; case 2: if(buff.size() < size) buff.resize(size); fread(&buff[0], size, 1, fp); GSgifTransfer3(&buff[0], size / 16); break; case 3: if(buff.size() < size) buff.resize(size); fread(&buff[0], size, 1, fp); GSgifTransfer(&buff[0], size / 16); break; } break; case 1: GSvsync(fgetc(fp)); exit = !IsWindowVisible(hWnd); break; case 2: fread(&size, 4, 1, fp); if(buff.size() < size) buff.resize(size); GSreadFIFO2(&buff[0], size / 16); break; case 3: fread(regs, 0x2000, 1, fp); break; } } */ GSclose(); GSshutdown(); fclose(fp); } }
bool mxWidget::isVisible () const { return (IsWindowVisible (d_this->d_hwnd) == TRUE); }
int GetWindowVisibleState(HWND hWnd, int iStepX, int iStepY) { RECT rc = { 0 }; POINT pt = { 0 }; register int i = 0, j = 0, width = 0, height = 0, iCountedDots = 0, iNotCoveredDots = 0; BOOL bPartiallyCovered = FALSE; HWND hAux = 0; if (hWnd == NULL) { SetLastError(0x00000006); //Wrong handle return -1; } //Some defaults now. The routine is designed for thin and tall windows. if (IsIconic(hWnd) || !IsWindowVisible(hWnd)) return GWVS_HIDDEN; HRGN rgn = 0; POINT ptOrig; RECT rcClient; int clip = (int)cfg::dat.bClipBorder; GetClientRect(hWnd, &rcClient); ptOrig.x = ptOrig.y = 0; ClientToScreen(hWnd, &ptOrig); rc.left = ptOrig.x; rc.top = ptOrig.y; rc.right = rc.left + rcClient.right; rc.bottom = rc.top + rcClient.bottom; //GetWindowRect(hWnd, &rc); width = rc.right - rc.left; height = rc.bottom - rc.top; if (iStepX <= 0) iStepX = 4; if (iStepY <= 0) iStepY = 16; /* * use a rounded clip region to determine which pixels are covered * this will avoid problems with certain XP themes which are using transparency for rounded * window frames (reluna being one popular example). * the radius of 8 should be sufficient for most themes as they usually don't use bigger * radii. * also, clip at least 2 pixels from the border (same reason) */ if (g_CLUIImageItem) clip = 5; else clip = 0; for (i = rc.top + clip; i < rc.bottom; i += (height / iStepY)) { pt.y = i; for (j = rc.left + clip; j < rc.right; j += (width / iStepX)) { pt.x = j; hAux = WindowFromPoint(pt); while (GetParent(hAux) != NULL) hAux = GetParent(hAux); if (hAux != hWnd && hAux) //There's another window! bPartiallyCovered = TRUE; else iNotCoveredDots++; //Let's count the not covered dots. iCountedDots++; //Let's keep track of how many dots we checked. } } if (rgn) DeleteObject(rgn); if (iNotCoveredDots == iCountedDots) //Every dot was not covered: the window is visible. return GWVS_VISIBLE; if (iNotCoveredDots == 0) //They're all covered! return GWVS_COVERED; //There are dots which are visible, but they are not as many as the ones we counted: it's partially covered. return GWVS_PARTIALLY_COVERED; }
int CALLBACK LongDialogProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam) { sDIALOG_long * dlg; HWND hwnd2; switch (message) { case WM_INITDIALOG: SetWindowPos(hwnd , HWND_TOP , 0 , 0 , 0 , 0 , SWP_NOMOVE | SWP_NOSIZE); dlg = (sDIALOG_long*)lParam; dlg->cancel = false; dlg->handle = hwnd; LongDialogProc(hwnd , MYWM_DLGLONGSET , 0 , lParam); // SetTimer(hwnd , 1 , 500 , (TIMERPROC)LongTimerProc); // SetProp(hwnd , "DLGTIMER" , timer); SendMessage(GetDlgItem(hwnd , IDC_PROGRESS) , PBM_SETRANGE32 , 0 , dlg->progress>0 ? dlg->progress : 100); if (dlg->progress > 0) dlg->progress = 0; break; case WM_CLOSE: // KillTimer(hwnd , 1); // timer = GetProp(hwnd , "DLGTIMER"); // CancelWaitableTimer(timer); // CloseHandle(timer); DestroyWindow(hwnd); break; case WM_DESTROY: RemoveProp(hwnd , "DLG"); // RemoveProp(hwnd , "DLGTIMER"); break; case MYWM_DLGLONGSET: if (!wParam) wParam = -1; dlg = (sDIALOG_long*)lParam; SetProp(hwnd , "DLG" , dlg); if (wParam & DSET_TITLE) SetWindowText(hwnd , dlg->title); if (wParam & DSET_INFO ) SetDlgItemText(hwnd , IDC_STATIC , dlg->info); if (wParam & DSET_BUTTONS) ShowWindow(GetDlgItem(hwnd , IDCANCEL) , dlg->flag & DLONG_CANCEL ? SW_SHOW:SW_HIDE); if (wParam & DSET_ANIM) switch (dlg->flag & 0xFF0) { case DLONG_ASEND: Animate_Open(GetDlgItem(hwnd , IDC_ANIMATE) , MAKEINTRESOURCE(IDA_LONGSEND)); case DLONG_ARECV: Animate_Open(GetDlgItem(hwnd , IDC_ANIMATE) , MAKEINTRESOURCE(IDA_LONGRECV)); case DLONG_AINET: Animate_Open(GetDlgItem(hwnd , IDC_ANIMATE) , MAKEINTRESOURCE(IDA_LONGINET)); case 0: Animate_Open(GetDlgItem(hwnd , IDC_ANIMATE) , MAKEINTRESOURCE(IDA_LONG)); // HINSTANCE hlib = LoadLibrary("shell32.dll"); // Animate_OpenEx(GetDlgItem(hwnd , IDC_ANIMATE) , hlib , MAKEINTRESOURCE(152)); // FreeLibrary(hlib); break; } if (wParam & DSET_PROGRESS) { hwnd2 = GetDlgItem(hwnd , IDC_PROGRESS); if (dlg->progress>=0 && !IsWindowVisible(hwnd2)) ShowWindow(hwnd2 , SW_SHOW); else if (dlg->progress<0 && IsWindowVisible(hwnd2)) ShowWindow(hwnd2 , SW_HIDE); SendMessage(hwnd2 , PBM_SETPOS , dlg->progress , 0); } break; case WM_COMMAND: dlg = (sDIALOG_long*) GetProp(hwnd , "DLG"); if (HIWORD(wParam)!=BN_CLICKED) return 0; switch (LOWORD(wParam)) { case IDCANCEL: IMLOG("- Cancel@LongProc pressed"); if (!dlg->cancelProc) { dlg->cancel = true; ShowWindow(hwnd , SW_HIDE); } else if (dlg->cancelProc(dlg)) dlg->cancel = true; return TRUE; } } return 0; }