int wxTreebookExt::ChangeSelection(size_t n) { int i = wxTreebook::ChangeSelection(n); wxString Temp = GetPageText( n ); ((wxDialog*)GetParent())->SetTitle( Temp ); return i; };
INT_PTR CALLBACK CFileDefExt::GeneralPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: { LPPROPSHEETPAGEW ppsp = (LPPROPSHEETPAGEW)lParam; if (ppsp == NULL || !ppsp->lParam) break; TRACE("WM_INITDIALOG hwnd %p lParam %p ppsplParam %S\n", hwndDlg, lParam, ppsp->lParam); CFileDefExt *pFileDefExt = reinterpret_cast<CFileDefExt *>(ppsp->lParam); SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pFileDefExt); pFileDefExt->InitGeneralPage(hwndDlg); break; } case WM_COMMAND: if (LOWORD(wParam) == 14024) /* Opens With - Change */ { CFileDefExt *pFileDefExt = reinterpret_cast<CFileDefExt *>(GetWindowLongPtr(hwndDlg, DWLP_USER)); OPENASINFO oainfo; oainfo.pcszFile = pFileDefExt->m_wszPath; oainfo.pcszClass = NULL; oainfo.oaifInFlags = OAIF_REGISTER_EXT|OAIF_FORCE_REGISTRATION; return SUCCEEDED(SHOpenWithDialog(hwndDlg, &oainfo)); } else if (LOWORD(wParam) == 14021 || LOWORD(wParam) == 14022 || LOWORD(wParam) == 14023) /* checkboxes */ PropSheet_Changed(GetParent(hwndDlg), hwndDlg); else if (LOWORD(wParam) == 14001) /* Name */ { if (HIWORD(wParam) == EN_CHANGE) PropSheet_Changed(GetParent(hwndDlg), hwndDlg); } break; case WM_NOTIFY: { LPPSHNOTIFY lppsn = (LPPSHNOTIFY)lParam; if (lppsn->hdr.code == PSN_APPLY) { CFileDefExt *pFileDefExt = reinterpret_cast<CFileDefExt *>(GetWindowLongPtr(hwndDlg, DWLP_USER)); /* Update attributes first */ DWORD dwAttr = GetFileAttributesW(pFileDefExt->m_wszPath); if (dwAttr) { dwAttr &= ~(FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_ARCHIVE); if (BST_CHECKED == SendDlgItemMessageW(hwndDlg, 14021, BM_GETCHECK, 0, 0)) dwAttr |= FILE_ATTRIBUTE_READONLY; if (BST_CHECKED == SendDlgItemMessageW(hwndDlg, 14022, BM_GETCHECK, 0, 0)) dwAttr |= FILE_ATTRIBUTE_HIDDEN; if (BST_CHECKED == SendDlgItemMessageW(hwndDlg, 14023, BM_GETCHECK, 0, 0)) dwAttr |= FILE_ATTRIBUTE_ARCHIVE; if (!SetFileAttributesW(pFileDefExt->m_wszPath, dwAttr)) ERR("SetFileAttributesW failed\n"); } /* Update filename now */ WCHAR wszBuf[MAX_PATH]; StringCchCopyW(wszBuf, _countof(wszBuf), pFileDefExt->m_wszPath); LPWSTR pwszFilename = PathFindFileNameW(wszBuf); UINT cchFilenameMax = _countof(wszBuf) - (pwszFilename - wszBuf); if (GetDlgItemTextW(hwndDlg, 14001, pwszFilename, cchFilenameMax)) { if (!MoveFileW(pFileDefExt->m_wszPath, wszBuf)) ERR("MoveFileW failed\n"); } SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, PSNRET_NOERROR); return TRUE; } break; } default: break; } return FALSE; }
void CVolumeCtrl::SetPosInternal(int pos) { SetPos(pos); GetParent()->PostMessage(WM_HSCROLL, MAKEWPARAM((short)pos, SB_THUMBPOSITION), (LPARAM)m_hWnd); // this will be reflected back on us }
void CInitialConfigDlg::OnBnClickedButtonCancel() { // TODO: 在此添加控件通知处理程序代码 ::SendMessage(GetParent()->GetSafeHwnd(),WM_MY_RefreshNodeInfoList,NULL,NULL); SendMessage(WM_CLOSE); }
void CTreePropSheetSplitter::GetAdjustedClientRect(CRect* pRect) const { GetWindowRect(pRect); GetParent()->ScreenToClient(pRect); }
// Moves widget in Z direction void Widget::Dive(int dz) { GetParent()->Lift( -dz, this); }
static LRESULT CALLBACK ColourPickerWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CREATE: SetWindowLongPtr(hwnd, 0, 0); SetWindowLongPtr(hwnd, sizeof(COLORREF), 0); break; case CPM_SETDEFAULTCOLOUR: SetWindowLongPtr(hwnd, sizeof(COLORREF), lParam); break; case CPM_GETDEFAULTCOLOUR: return GetWindowLongPtr(hwnd, sizeof(COLORREF)); case CPM_SETCOLOUR: SetWindowLongPtr(hwnd, 0, lParam); InvalidateRect(hwnd, NULL, FALSE); break; case CPM_GETCOLOUR: return GetWindowLongPtr(hwnd, 0); case WM_LBUTTONUP: { COLORREF custColours[16] = { 0 }; custColours[0] = GetWindowLongPtr(hwnd, sizeof(COLORREF)); CHOOSECOLOR cc = { 0 }; cc.lStructSize = sizeof(CHOOSECOLOR); cc.hwndOwner = hwnd; cc.hInstance = (HWND)g_hInst; cc.rgbResult = GetWindowLongPtr(hwnd, 0); cc.lpCustColors = custColours; cc.Flags = CC_ANYCOLOR | CC_FULLOPEN | CC_RGBINIT; if (ChooseColor(&cc)) { SetWindowLongPtr(hwnd, 0, cc.rgbResult); SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hwnd), CPN_COLOURCHANGED), (LPARAM)hwnd); InvalidateRect(hwnd, NULL, FALSE); } } break; case WM_ENABLE: InvalidateRect(hwnd, NULL, FALSE); break; case WM_NCPAINT: case WM_PAINT: PAINTSTRUCT ps; HDC hdc1 = BeginPaint(hwnd, &ps); RECT rc; GetClientRect(hwnd, &rc); DrawEdge(hdc1, &rc, EDGE_ETCHED, BF_RECT); InflateRect(&rc, -2, -2); HBRUSH hBrush = (IsWindowEnabled(hwnd)) ? CreateSolidBrush(GetWindowLongPtr(hwnd, 0)) : CreateHatchBrush(HS_BDIAGONAL, GetSysColor(COLOR_GRAYTEXT)); SetBkColor(hdc1, GetSysColor(COLOR_BTNFACE)); FillRect(hdc1, &rc, hBrush); DeleteObject(hBrush); EndPaint(hwnd, &ps); break; } return DefWindowProc(hwnd, message, wParam, lParam); }
// // CHistoryPane message handlers // void CHistoryPane::OnPaint() { CPaintDC dc(this); CRect r; CRgn rgn; CPen pen; uint w, i; uint y, gap; COLORREF colBack; GetClientRect(&r); colBack = GetSysColor(COLOR_3DLIGHT); // dc.FillSolidRect(0, 0, XBORDER, r.bottom, colBack); dc.FillSolidRect(r.right-XBORDER, 0, XBORDER, r.bottom, colBack); dc.FillSolidRect(XBORDER, 0, r.right-r.left-2*XBORDER, YBORDER, colBack); dc.FillSolidRect(XBORDER, r.bottom-YBORDER, r.right-r.left-2*XBORDER, YBORDER, colBack); dc.Draw3dRect(&r, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT)); // r.DeflateRect(XBORDER, YBORDER); rgn.CreateRectRgnIndirect(&r); dc.SelectClipRgn(&rgn, RGN_COPY); pen.CreatePen(PS_SOLID, 1, RGB(0xff,0x3f,0x00)); //dc.SetROP2(R2_XORPEN); dc.SelectObject(&pen); dc.SelectStockObject(NULL_BRUSH); dc.SetStretchBltMode(HALFTONE); // w = m_uWidth; y = YBORDER; gap = 0; for (i=m_uTopItem; i<m_vItems.size(); i++) { CItem & info = m_vItems[i]; CRect rTmp(0,0,0,0); rTmp = CRect(XBORDER, y, XBORDER+m_uWidth, y+info.h0); BitmapBlt(&dc, &rTmp, info.image0, 0); if (info.sel0 != rTmp) { rTmp = info.sel0 + CSize(0,y); dc.Rectangle(&rTmp); } dc.FillSolidRect(XBORDER, y+info.h0, m_uWidth, YSPACE, GetSysColor(COLOR_3DLIGHT)); //dc.Draw3dRect(XBORDER, y, w, info.h0, GetSysColor(COLOR_3DHILIGHT), GetSysColor(COLOR_3DSHADOW)); y += info.h0 + YSPACE; if (y > r.bottom) break; } if (y < r.bottom) { gap = r.bottom - y; dc.FillSolidRect(XBORDER, y, m_uWidth, r.bottom-y, colBack); } if (m_bSendScroll || gap != m_uTrailingGap) { m_uTrailingGap = gap; m_bSendScroll = false; GetParent()->PostMessage(m_uMsgScroll); } }
static void PaintWorker(MButtonCtrl *ctl, HDC hdcPaint) { if (hdcPaint) { HDC hdcMem; HBITMAP hbmMem; HBITMAP hbmOld = 0; RECT rcClient; HFONT hOldFont = 0; int xOffset = 0; GetClientRect(ctl->hwnd, &rcClient); hdcMem = CreateCompatibleDC(hdcPaint); hbmMem = CreateCompatibleBitmap(hdcPaint, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top); hbmOld = reinterpret_cast<HBITMAP>(SelectObject(hdcMem, hbmMem)); hOldFont = reinterpret_cast<HFONT>(SelectObject(hdcMem, ctl->hFont)); // If its a push button, check to see if it should stay pressed if (ctl->pushBtn && ctl->pbState) ctl->stateId = PBS_PRESSED; // Draw the flat button if (ctl->flatBtn) { if (ctl->hThemeToolbar && ctl->bThemed) { RECT rc = rcClient; int state = IsWindowEnabled(ctl->hwnd) ? (ctl->stateId == PBS_NORMAL && ctl->defbutton ? PBS_DEFAULTED : ctl->stateId) : PBS_DISABLED; SkinDrawBg(ctl->hwnd, hdcMem); if (API::pfnIsThemeBackgroundPartiallyTransparent(ctl->hThemeToolbar, TP_BUTTON, TBStateConvert2Flat(state))) { API::pfnDrawThemeParentBackground(ctl->hwnd, hdcMem, &rc); } API::pfnDrawThemeBackground(ctl->hThemeToolbar, hdcMem, TP_BUTTON, TBStateConvert2Flat(state), &rc, &rc); } else { HBRUSH hbr; RECT rc = rcClient; if(ctl->buttonItem) { RECT rcParent; POINT pt; HWND hwndParent = pcli->hwndContactList; ImageItem *imgItem = ctl->stateId == PBS_HOT ? ctl->buttonItem->imgHover : (ctl->stateId == PBS_PRESSED ? ctl->buttonItem->imgPressed : ctl->buttonItem->imgNormal); LONG *glyphMetrics = ctl->stateId == PBS_HOT ? ctl->buttonItem->hoverGlyphMetrics : (ctl->stateId == PBS_PRESSED ? ctl->buttonItem->pressedGlyphMetrics : ctl->buttonItem->normalGlyphMetrics); //if(ctl->stateId == PBS_HOT && glyphMetrics[2] <= 1 && glyphMetrics[3] <= 1) // glyphMetrics = ctl->lastGlyphMetrics; GetWindowRect(ctl->hwnd, &rcParent); pt.x = rcParent.left; pt.y = rcParent.top; ScreenToClient(pcli->hwndContactList, &pt); BitBlt(hdcMem, 0, 0, rc.right, rc.bottom, cfg::dat.hdcBg, pt.x, pt.y, SRCCOPY); if(imgItem) DrawAlpha(hdcMem, &rc, 0, 0, 0, 0, 0, 0, 0, imgItem); if(g_glyphItem) { API::pfnAlphaBlend(hdcMem, (rc.right - glyphMetrics[2]) / 2, (rc.bottom - glyphMetrics[3]) / 2, glyphMetrics[2], glyphMetrics[3], g_glyphItem->hdc, glyphMetrics[0], glyphMetrics[1], glyphMetrics[2], glyphMetrics[3], g_glyphItem->bf); //CopyMemory(ctl->lastGlyphMetrics, glyphMetrics, 4 * sizeof(LONG)); } } else if(ctl->bSkinned) { // skinned RECT rcParent; POINT pt; HWND hwndParent = pcli->hwndContactList; StatusItems_t *item; int item_id; GetWindowRect(ctl->hwnd, &rcParent); pt.x = rcParent.left; pt.y = rcParent.top; ScreenToClient(pcli->hwndContactList, &pt); if(HIWORD(ctl->bSkinned)) item_id = ctl->stateId == PBS_HOT ? ID_EXTBKTBBUTTONMOUSEOVER : (ctl->stateId == PBS_PRESSED ? ID_EXTBKTBBUTTONSPRESSED : ID_EXTBKTBBUTTONSNPRESSED); //GetItemByStatus(ctl->stateId == PBS_HOT ? ID_EXTBKBUTTONSMOUSEOVER : (ctl->stateId == PBS_PRESSED ? ID_EXTBKTBBUTTONSPRESSED : ID_EXTBKTBBUTTONSNPRESSED), &item); else item_id = ctl->stateId == PBS_HOT ? ID_EXTBKBUTTONSMOUSEOVER : (ctl->stateId == PBS_PRESSED ? ID_EXTBKBUTTONSPRESSED : ID_EXTBKBUTTONSNPRESSED); item = &StatusItems[item_id - ID_STATUS_OFFLINE]; //GetItemByStatus(ctl->stateId == PBS_PRESSED ? ID_EXTBKBUTTONSPRESSED : ID_EXTBKBUTTONSNPRESSED, &item); SetTextColor(hdcMem, item->TEXTCOLOR); if(item->IGNORED) { if(pt.y < 10 || cfg::dat.bWallpaperMode) //SkinDrawBg(ctl->hwnd, hdcMem); BitBlt(hdcMem, 0, 0, rc.right, rc.bottom, cfg::dat.hdcBg, pt.x, pt.y, SRCCOPY); else FillRect(hdcMem, &rc, GetSysColorBrush(COLOR_3DFACE)); } else { if(pt.y < 10 || cfg::dat.bWallpaperMode) //SkinDrawBg(ctl->hwnd, hdcMem); BitBlt(hdcMem, 0, 0, rc.right, rc.bottom, cfg::dat.hdcBg, pt.x, pt.y, SRCCOPY); else FillRect(hdcMem, &rc, GetSysColorBrush(COLOR_3DFACE)); rc.top += item->MARGIN_TOP; rc.bottom -= item->MARGIN_BOTTOM; rc.left += item->MARGIN_LEFT; rc.right -= item->MARGIN_RIGHT; DrawAlpha(hdcMem, &rc, item->COLOR, item->ALPHA, item->COLOR2, item->COLOR2_TRANSPARENT, item->GRADIENT, item->CORNER, item->BORDERSTYLE, item->imageItem); } } else { if (ctl->stateId == PBS_PRESSED || ctl->stateId == PBS_HOT) hbr = GetSysColorBrush(COLOR_3DFACE); else { HDC dc; HWND hwndParent; hwndParent = GetParent(ctl->hwnd); dc = GetDC(hwndParent); hbr = (HBRUSH) SendMessage(hwndParent, WM_CTLCOLORDLG, (WPARAM) dc, (LPARAM) hwndParent); ReleaseDC(hwndParent, dc); } if (hbr) { FillRect(hdcMem, &rc, hbr); DeleteObject(hbr); } } if(!ctl->bSkinned && ctl->buttonItem == 0) { if (ctl->stateId == PBS_HOT || ctl->focus) { if (ctl->pbState) DrawEdge(hdcMem, &rc, EDGE_ETCHED, BF_RECT | BF_SOFT); else DrawEdge(hdcMem, &rc, BDR_RAISEDOUTER, BF_RECT | BF_SOFT); } else if (ctl->stateId == PBS_PRESSED) DrawEdge(hdcMem, &rc, BDR_SUNKENOUTER, BF_RECT | BF_SOFT); } } } else { // Draw background/border if (ctl->hThemeButton && ctl->bThemed) { int state = IsWindowEnabled(ctl->hwnd) ? (ctl->stateId == PBS_NORMAL && ctl->defbutton ? PBS_DEFAULTED : ctl->stateId) : PBS_DISABLED; POINT pt; RECT rcParent; GetWindowRect(ctl->hwnd, &rcParent); pt.x = rcParent.left; pt.y = rcParent.top; ScreenToClient(pcli->hwndContactList, &pt); BitBlt(hdcMem, 0, 0, rcClient.right, rcClient.bottom, cfg::dat.hdcBg, pt.x, pt.y, SRCCOPY); if (API::pfnIsThemeBackgroundPartiallyTransparent(ctl->hThemeButton, BP_PUSHBUTTON, state)) { API::pfnDrawThemeParentBackground(ctl->hwnd, hdcMem, &rcClient); } API::pfnDrawThemeBackground(ctl->hThemeButton, hdcMem, BP_PUSHBUTTON, state, &rcClient, &rcClient); } else { UINT uState = DFCS_BUTTONPUSH | ((ctl->stateId == PBS_HOT) ? DFCS_HOT : 0) | ((ctl->stateId == PBS_PRESSED) ? DFCS_PUSHED : 0); if (ctl->defbutton && ctl->stateId == PBS_NORMAL) uState |= DLGC_DEFPUSHBUTTON; DrawFrameControl(hdcMem, &rcClient, DFC_BUTTON, uState); } // Draw focus rectangle if button has focus if (ctl->focus) { RECT focusRect = rcClient; InflateRect(&focusRect, -3, -3); DrawFocusRect(hdcMem, &focusRect); } } // If we have an icon or a bitmap, ignore text and only draw the image on the button if (ctl->hIcon || ctl->hIconPrivate || ctl->iIcon) { int ix = (rcClient.right - rcClient.left) / 2 - (g_cxsmIcon / 2); int iy = (rcClient.bottom - rcClient.top) / 2 - (g_cxsmIcon / 2); HICON hIconNew = ctl->hIconPrivate != 0 ? ctl->hIconPrivate : ctl->hIcon; if (lstrlen(ctl->szText) == 0) { if (ctl->iIcon) ImageList_DrawEx(ctl->hIml, ctl->iIcon, hdcMem, ix, iy, g_cxsmIcon, g_cysmIcon, CLR_NONE, CLR_NONE, ILD_NORMAL); else DrawState(hdcMem, NULL, NULL, (LPARAM) hIconNew, 0, ix, iy, g_cxsmIcon, g_cysmIcon, IsWindowEnabled(ctl->hwnd) ? DST_ICON | DSS_NORMAL : DST_ICON | DSS_DISABLED); ctl->sLabel.cx = ctl->sLabel.cy = 0; } else { GetTextExtentPoint32(hdcMem, ctl->szText, lstrlen(ctl->szText), &ctl->sLabel); if(g_cxsmIcon + ctl->sLabel.cx + 8 > rcClient.right - rcClient.left) ctl->sLabel.cx = (rcClient.right - rcClient.left) - g_cxsmIcon - 8; else ctl->sLabel.cx += 4; ix = (rcClient.right - rcClient.left) / 2 - ((g_cxsmIcon + ctl->sLabel.cx) / 2); if (ctl->iIcon) ImageList_DrawEx(ctl->hIml, ctl->iIcon, hdcMem, ix, iy, g_cxsmIcon, g_cysmIcon, CLR_NONE, CLR_NONE, ILD_NORMAL); else DrawState(hdcMem, NULL, NULL, (LPARAM) hIconNew, 0, ix, iy, g_cxsmIcon, g_cysmIcon, IsWindowEnabled(ctl->hwnd) ? DST_ICON | DSS_NORMAL : DST_ICON | DSS_DISABLED); xOffset = ix + g_cxsmIcon + 4; } } else if (ctl->hBitmap) { BITMAP bminfo; int ix, iy; GetObject(ctl->hBitmap, sizeof(bminfo), &bminfo); ix = (rcClient.right - rcClient.left) / 2 - (bminfo.bmWidth / 2); iy = (rcClient.bottom - rcClient.top) / 2 - (bminfo.bmHeight / 2); if (ctl->stateId == PBS_PRESSED) { ix++; iy++; } DrawState(hdcMem, NULL, NULL, (LPARAM) ctl->hBitmap, 0, ix, iy, bminfo.bmWidth, bminfo.bmHeight, IsWindowEnabled(ctl->hwnd) ? DST_BITMAP : DST_BITMAP | DSS_DISABLED); } if (GetWindowTextLength(ctl->hwnd)) { // Draw the text and optinally the arrow RECT rcText; CopyRect(&rcText, &rcClient); SetBkMode(hdcMem, TRANSPARENT); // XP w/themes doesn't used the glossy disabled text. Is it always using COLOR_GRAYTEXT? Seems so. if(!ctl->bSkinned) SetTextColor(hdcMem, IsWindowEnabled(ctl->hwnd) || !ctl->hThemeButton ? GetSysColor(COLOR_BTNTEXT) : GetSysColor(COLOR_GRAYTEXT)); if (ctl->arrow) DrawState(hdcMem, NULL, NULL, (LPARAM) ctl->arrow, 0, rcClient.right - rcClient.left - 5 - g_cxsmIcon + (!ctl->hThemeButton && ctl->stateId == PBS_PRESSED ? 1 : 0), (rcClient.bottom - rcClient.top) / 2 - g_cysmIcon / 2 + (!ctl->hThemeButton && ctl->stateId == PBS_PRESSED ? 1 : 0), g_cxsmIcon, g_cysmIcon, IsWindowEnabled(ctl->hwnd) ? DST_ICON : DST_ICON | DSS_DISABLED); DrawState(hdcMem, NULL, NULL, (LPARAM) ctl->szText, 0, xOffset + (!ctl->hThemeButton && ctl->stateId == PBS_PRESSED ? 1 : 0), ctl->hThemeButton ? (rcText.bottom - rcText.top - ctl->sLabel.cy) / 2 + 1 : (rcText.bottom - rcText.top - ctl->sLabel.cy) / 2 + (ctl->stateId == PBS_PRESSED ? 1 : 0), ctl->sLabel.cx, ctl->sLabel.cy, IsWindowEnabled(ctl->hwnd) || ctl->hThemeButton ? DST_PREFIXTEXT | DSS_NORMAL : DST_PREFIXTEXT | DSS_DISABLED); } if (hOldFont) SelectObject(hdcMem, hOldFont); BitBlt(hdcPaint, 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, hdcMem, 0, 0, SRCCOPY); SelectObject(hdcMem, hbmOld); DeleteObject(hbmMem); DeleteDC(hdcMem); DeleteObject(hbmOld); } }
INT_PTR CALLBACK ServicesPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(lParam); UNREFERENCED_PARAMETER(wParam); switch (message) { case WM_INITDIALOG: { hServicesPage = hDlg; hServicesListCtrl = GetDlgItem(hServicesPage, IDC_SERVICES_LIST); // // Correctly display message strings. // LPCWSTR szOSVendor = (bIsWindows ? IDS_MICROSOFT : IDS_REACTOS); size_t itemLength = 0; LPWSTR szItem = NULL, szNewItem = NULL; itemLength = GetWindowTextLength(GetDlgItem(hServicesPage, IDC_STATIC_SERVICES_WARNING)) + 1; szItem = (LPWSTR)MemAlloc(0, itemLength * sizeof(WCHAR)); GetDlgItemText(hServicesPage, IDC_STATIC_SERVICES_WARNING, szItem, (int)itemLength); szNewItem = FormatString(szItem, szOSVendor); SetDlgItemText(hServicesPage, IDC_STATIC_SERVICES_WARNING, szNewItem); MemFree(szNewItem); MemFree(szItem); itemLength = GetWindowTextLength(GetDlgItem(hServicesPage, IDC_CBX_SERVICES_MASK_PROPRIETARY_SVCS)) + 1; szItem = (LPWSTR)MemAlloc(0, itemLength * sizeof(WCHAR)); GetDlgItemText(hServicesPage, IDC_CBX_SERVICES_MASK_PROPRIETARY_SVCS, szItem, (int)itemLength); szNewItem = FormatString(szItem, szOSVendor); SetDlgItemText(hServicesPage, IDC_CBX_SERVICES_MASK_PROPRIETARY_SVCS, szNewItem); MemFree(szNewItem); MemFree(szItem); // // Initialize the styles. // DWORD dwStyle = ListView_GetExtendedListViewStyle(hServicesListCtrl); ListView_SetExtendedListViewStyle(hServicesListCtrl, dwStyle | LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES); SetWindowTheme(hServicesListCtrl, L"Explorer", NULL); // // Initialize the application page's controls. // LVCOLUMN column = {}; // First column : Service's name. column.mask = LVCF_TEXT | LVCF_WIDTH; column.pszText = LoadResourceString(hInst, IDS_SERVICES_COLUMN_SERVICE); column.cx = 150; ListView_InsertColumn(hServicesListCtrl, 0, &column); MemFree(column.pszText); // Second column : Whether the service is required or not. column.mask = LVCF_TEXT | LVCF_WIDTH; column.pszText = LoadResourceString(hInst, IDS_SERVICES_COLUMN_REQ); column.cx = 60; ListView_InsertColumn(hServicesListCtrl, 1, &column); MemFree(column.pszText); // Third column : Service's vendor. column.mask = LVCF_TEXT | LVCF_WIDTH; column.pszText = LoadResourceString(hInst, IDS_SERVICES_COLUMN_VENDOR); column.cx = 150; ListView_InsertColumn(hServicesListCtrl, 2, &column); MemFree(column.pszText); // Fourth column : Service's status. column.mask = LVCF_TEXT | LVCF_WIDTH; column.pszText = LoadResourceString(hInst, IDS_SERVICES_COLUMN_STATUS); column.cx = 60; ListView_InsertColumn(hServicesListCtrl, 3, &column); MemFree(column.pszText); // Fifth column : Service's disabled date. column.mask = LVCF_TEXT | LVCF_WIDTH; column.pszText = LoadResourceString(hInst, IDS_SERVICES_COLUMN_DATEDISABLED); column.cx = 120; ListView_InsertColumn(hServicesListCtrl, 4, &column); MemFree(column.pszText); // // Populate and sort the list. // GetServices(); ListView_Sort(hServicesListCtrl, 0); Update_Btn_States(hDlg); // Select the first item. ListView_SetItemState(hServicesListCtrl, 0, LVIS_SELECTED, LVIS_SELECTED); return TRUE; } case WM_DESTROY: { ClearServicesList(); userModificationsList.RemoveAll(); return 0; } case WM_COMMAND: { switch (LOWORD(wParam)) { case IDC_BTN_SERVICES_ACTIVATE: { BOOL bAreThereModifs = FALSE; int index = -1; // From the beginning. while ((index = ListView_GetNextItem(hServicesListCtrl, index, LVNI_ALL)) != -1) { bAreThereModifs = ValidateItem(index, TRUE, FALSE) || bAreThereModifs; // The order is verrrrrry important !!!! } if (bAreThereModifs) { Update_Btn_States(hDlg); PropSheet_Changed(GetParent(hServicesPage), hServicesPage); } return TRUE; } case IDC_BTN_SERVICES_DEACTIVATE: { BOOL bAreThereModifs = FALSE; int index = -1; // From the beginning. while ((index = ListView_GetNextItem(hServicesListCtrl, index, LVNI_ALL)) != -1) { bAreThereModifs = ValidateItem(index, FALSE, FALSE) || bAreThereModifs; // The order is verrrrrry important !!!! } if (bAreThereModifs) { Update_Btn_States(hDlg); PropSheet_Changed(GetParent(hServicesPage), hServicesPage); } return TRUE; } case IDC_CBX_SERVICES_MASK_PROPRIETARY_SVCS: { bMaskProprietarySvcs = !bMaskProprietarySvcs; GetServices(bMaskProprietarySvcs); Update_Btn_States(hDlg); return TRUE; } default: return FALSE; } return FALSE; } case UM_CHECKSTATECHANGE: { BOOL bNewCheckState = !!((ListView_GetCheckState(hServicesListCtrl, int(lParam)) + 1) % 2); if (ValidateItem(/*reinterpret_cast<int>*/ int(lParam), bNewCheckState, !HideEssentialServiceWarning())) { Update_Btn_States(hDlg); PropSheet_Changed(GetParent(hServicesPage), hServicesPage); } return TRUE; } case WM_NOTIFY: { if (reinterpret_cast<LPNMHDR>(lParam)->hwndFrom == hServicesListCtrl) { switch (reinterpret_cast<LPNMHDR>(lParam)->code) { case NM_CLICK: case NM_RCLICK: { DWORD dwpos = GetMessagePos(); LVHITTESTINFO ht = {}; ht.pt.x = GET_X_LPARAM(dwpos); ht.pt.y = GET_Y_LPARAM(dwpos); MapWindowPoints(HWND_DESKTOP /*NULL*/, hServicesListCtrl, &ht.pt, 1); /* * We use ListView_SubItemHitTest(...) and not ListView_HitTest(...) * because ListView_HitTest(...) returns bad flags when one clicks * on a sub-item different from 0. The flags then contain LVHT_ONITEMSTATEICON * which must not be obviously present in this case. */ ListView_SubItemHitTest(hServicesListCtrl, &ht); if (LVHT_ONITEMSTATEICON & ht.flags) { PostMessage(hDlg, UM_CHECKSTATECHANGE, 0, (LPARAM)ht.iItem); // Disable default behaviour. Needed for the UM_CHECKSTATECHANGE // custom notification to work as expected. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, TRUE); } return TRUE; } case NM_DBLCLK: case NM_RDBLCLK: { // We deactivate double-clicks. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, TRUE); return TRUE; } case LVN_KEYDOWN: { if (reinterpret_cast<LPNMLVKEYDOWN>(lParam)->wVKey == VK_SPACE) { int iItem = ListView_GetSelectionMark(hServicesListCtrl); PostMessage(hDlg, UM_CHECKSTATECHANGE, 0, (LPARAM)iItem); // Disable default behaviour. Needed for the UM_CHECKSTATECHANGE // custom notification to work as expected. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, TRUE); } return TRUE; } case LVN_COLUMNCLICK: { int iSortingColumn = reinterpret_cast<LPNMLISTVIEW>(lParam)->iSubItem; ListView_SortEx(hServicesListCtrl, iSortingColumn, iSortedColumn); iSortedColumn = iSortingColumn; return TRUE; } } } else { switch (reinterpret_cast<LPNMHDR>(lParam)->code) { case PSN_APPLY: { // Try to apply the modifications to the system. MessageBox(NULL, _T("In Services page: PSN_APPLY"), _T("Info"), MB_ICONINFORMATION); /* // // Move this away... // int iRetVal = MessageBox(NULL, _T("Would you really want to modify the configuration of your system ?"), _T("Warning"), MB_ICONWARNING | MB_YESNOCANCEL); if (iRetVal == IDYES /\* modifications are OK *\/) SetWindowLongPtr(hServicesPage, DWLP_MSGRESULT, PSNRET_NOERROR); else if (iRetVal == IDNO /\* modifications are not OK *\/) SetWindowLongPtr(hServicesPage, DWLP_MSGRESULT, PSNRET_NOERROR); else // if (iRetVal == IDCANCEL) // There was an error... SetWindowLongPtr(hServicesPage, DWLP_MSGRESULT, PSNRET_INVALID); */ // // We modify the services which are stored in the user modification list. // // 1- Open the Service Control Manager for modifications. SC_HANDLE hSCManager = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS); if (hSCManager != NULL) { LPCWSTR svcName; for (POSITION it = userModificationsList.GetHeadPosition(); it; userModificationsList.GetNext(it)) { svcName = userModificationsList.GetAt(it); // 2- Retrieve a handle to the service. SC_HANDLE hService = OpenServiceW(hSCManager, svcName, SERVICE_QUERY_CONFIG | SERVICE_CHANGE_CONFIG); if (hService == NULL) { // TODO : Show a message box. continue; } DWORD dwBytesNeeded = 0; QueryServiceConfigW(hService, NULL, 0, &dwBytesNeeded); // if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) LPQUERY_SERVICE_CONFIG lpServiceConfig = (LPQUERY_SERVICE_CONFIG)MemAlloc(0, dwBytesNeeded); if (!lpServiceConfig) { CloseServiceHandle(hService); continue; // TODO ? Show a message box... } QueryServiceConfigW(hService, lpServiceConfig, dwBytesNeeded, &dwBytesNeeded); if (lpServiceConfig->dwStartType == SERVICE_DISABLED) // We have a disabled service which is becoming to be enabled. { // 3a- Retrive the properties of the disabled service from the registry. RegistryDisabledServiceItemParams params = {}; QUERY_REGISTRY_KEYS_TABLE KeysQueryTable[2] = {}; KeysQueryTable[0].QueryRoutine = GetRegistryKeyedDisabledServicesQueryRoutine; KeysQueryTable[0].EntryContext = ¶ms; RegQueryRegistryKeys(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\services", KeysQueryTable, (PVOID)svcName); if (bIsWindows && bIsPreVistaOSVersion && !params.bIsPresent) { QUERY_REGISTRY_VALUES_TABLE ValuesQueryTable[2] = {}; ValuesQueryTable[0].QueryRoutine = GetRegistryValuedDisabledServicesQueryRoutine; ValuesQueryTable[0].EntryContext = ¶ms; RegQueryRegistryValues(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\services", ValuesQueryTable, (PVOID)svcName); } if (params.bIsPresent) { // 4a- Modify the service. ChangeServiceConfigW(hService, SERVICE_NO_CHANGE, params.dwStartType, SERVICE_NO_CHANGE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); // 5a- Remove the registry entry of the service. if (params.bIsKeyed) { CAtlStringW serviceRegKey(L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\services\\"); serviceRegKey += svcName; RegDeleteKeyW(HKEY_LOCAL_MACHINE, serviceRegKey); /***** HACK for Windows < Vista (e.g. 2000, Xp, 2003...) *****/ // // Delete also the valued-entry of the service. // if (bIsWindows && bIsPreVistaOSVersion) { HKEY hSubKey = NULL; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\services", 0, KEY_SET_VALUE /*KEY_READ*/, &hSubKey) == ERROR_SUCCESS) { RegDeleteValue(hSubKey, svcName); RegCloseKey(hSubKey); } } /*************************************************************/ } else { HKEY hSubKey = NULL; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\services", 0, KEY_SET_VALUE /*KEY_READ*/, &hSubKey) == ERROR_SUCCESS) { RegDeleteValue(hSubKey, svcName); RegCloseKey(hSubKey); } } ////////// HACKHACKHACKHACKHACKHACKHACKHACKHACKHACKHACK /////////// // userModificationsList.RemoveAt(it); } else { // Ohoh !! We have a very big problem. MessageBox(NULL, _T("WTF ??"), _T("FATAL ERROR !!!!"), MB_ICONERROR); } } else // We have an enabled service which is becoming to be disabled. { // 3b- Retrieve the local time of disabling. SYSTEMTIME disableDate = {}; GetLocalTime(&disableDate); // 4b- Modify the service. ChangeServiceConfigW(hService, SERVICE_NO_CHANGE, SERVICE_DISABLED, SERVICE_NO_CHANGE, NULL, NULL, NULL, NULL, NULL, NULL, NULL); // 5b- Register the service into the registry. CAtlStringW serviceRegKey(L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\services\\"); serviceRegKey += svcName; HKEY hSubKey = NULL; if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, serviceRegKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, NULL, &hSubKey, NULL) == ERROR_SUCCESS) { RegSetDWORDValue(hSubKey, NULL, svcName, FALSE, lpServiceConfig->dwStartType); #if 1 // DisableDate RegSetDWORDValue(hSubKey, NULL, L"DAY" , FALSE, disableDate.wDay ); RegSetDWORDValue(hSubKey, NULL, L"HOUR" , FALSE, disableDate.wHour ); RegSetDWORDValue(hSubKey, NULL, L"MINUTE", FALSE, disableDate.wMinute); RegSetDWORDValue(hSubKey, NULL, L"MONTH" , FALSE, disableDate.wMonth ); RegSetDWORDValue(hSubKey, NULL, L"SECOND", FALSE, disableDate.wSecond); RegSetDWORDValue(hSubKey, NULL, L"YEAR" , FALSE, disableDate.wYear ); #endif RegCloseKey(hSubKey); } /***** HACK for Windows < Vista (e.g. 2000, Xp, 2003...) *****/ // // Save also a valued-entry for the service. // if (bIsWindows && bIsPreVistaOSVersion) { RegSetDWORDValue(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\services", svcName, TRUE, lpServiceConfig->dwStartType); } /*************************************************************/ ////////// HACKHACKHACKHACKHACKHACKHACKHACKHACKHACKHACK /////////// // userModificationsList.RemoveAt(it); } MemFree(lpServiceConfig); CloseServiceHandle(hService); } //////////// HACK HACK !!!! //////////// userModificationsList.RemoveAll(); //////////////////////////////////////// CloseServiceHandle(hSCManager); //// PropSheet_UnChanged(GetParent(hServicesPage), hServicesPage); //// PropSheet_CancelToClose(GetParent(hDlg)); /* Modifications are OK */ SetWindowLongPtr(hServicesPage, DWLP_MSGRESULT, PSNRET_NOERROR); } else { MessageBox(hDlg, _T("Impossible to open the SC manager..."), _T("Error"), MB_ICONERROR); // There was an error... SetWindowLongPtr(hServicesPage, DWLP_MSGRESULT, PSNRET_INVALID); } GetServices(bMaskProprietarySvcs); Update_Btn_States(hDlg); return TRUE; } case PSN_HELP: { MessageBox(hServicesPage, _T("Help not implemented yet!"), _T("Help"), MB_ICONINFORMATION | MB_OK); return TRUE; } case PSN_KILLACTIVE: // Is going to lose activation. { // Changes are always valid of course. SetWindowLongPtr(hServicesPage, DWLP_MSGRESULT, FALSE); return TRUE; } case PSN_QUERYCANCEL: { // RefreshStartupList(); // Allows cancellation. SetWindowLongPtr(hServicesPage, DWLP_MSGRESULT, FALSE); return TRUE; } case PSN_QUERYINITIALFOCUS: { // Give the focus on and select the first item. ListView_SetItemState(hServicesListCtrl, 0, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); SetWindowLongPtr(hServicesPage, DWLP_MSGRESULT, (LONG_PTR)hServicesListCtrl); return TRUE; } // // DO NOT TOUCH THESE NEXT MESSAGES, THEY ARE OK LIKE THIS... // case PSN_RESET: // Perform final cleaning, called before WM_DESTROY. return TRUE; case PSN_SETACTIVE: // Is going to gain activation. { SetWindowLongPtr(hServicesPage, DWLP_MSGRESULT, 0); return TRUE; } default: break; } } } default: return FALSE; } return FALSE; }
bool KX_RaySensor::Evaluate() { bool result = false; bool reset = m_reset && m_level; m_rayHit = false; m_hitObject = NULL; m_hitPosition[0] = 0; m_hitPosition[1] = 0; m_hitPosition[2] = 0; m_hitNormal[0] = 1; m_hitNormal[1] = 0; m_hitNormal[2] = 0; KX_GameObject* obj = (KX_GameObject*)GetParent(); MT_Point3 frompoint = obj->NodeGetWorldPosition(); MT_Matrix3x3 matje = obj->NodeGetWorldOrientation(); MT_Matrix3x3 invmat = matje.inverse(); MT_Vector3 todir; m_reset = false; switch (m_axis) { case SENS_RAY_X_AXIS: // X { todir[0] = invmat[0][0]; todir[1] = invmat[0][1]; todir[2] = invmat[0][2]; break; } case SENS_RAY_Y_AXIS: // Y { todir[0] = invmat[1][0]; todir[1] = invmat[1][1]; todir[2] = invmat[1][2]; break; } case SENS_RAY_Z_AXIS: // Z { todir[0] = invmat[2][0]; todir[1] = invmat[2][1]; todir[2] = invmat[2][2]; break; } case SENS_RAY_NEG_X_AXIS: // -X { todir[0] = -invmat[0][0]; todir[1] = -invmat[0][1]; todir[2] = -invmat[0][2]; break; } case SENS_RAY_NEG_Y_AXIS: // -Y { todir[0] = -invmat[1][0]; todir[1] = -invmat[1][1]; todir[2] = -invmat[1][2]; break; } case SENS_RAY_NEG_Z_AXIS: // -Z { todir[0] = -invmat[2][0]; todir[1] = -invmat[2][1]; todir[2] = -invmat[2][2]; break; } } todir.normalize(); m_rayDirection[0] = todir[0]; m_rayDirection[1] = todir[1]; m_rayDirection[2] = todir[2]; MT_Point3 topoint = frompoint + (m_distance) * todir; PHY_IPhysicsEnvironment* pe = m_scene->GetPhysicsEnvironment(); if (!pe) { std::cout << "WARNING: Ray sensor " << GetName() << ": There is no physics environment!" << std::endl; std::cout << " Check universe for malfunction." << std::endl; return false; } PHY_IPhysicsController *spc = obj->GetPhysicsController(); KX_GameObject *parent = obj->GetParent(); if (!spc && parent) spc = parent->GetPhysicsController(); if (parent) parent->Release(); PHY_IPhysicsEnvironment* physics_environment = this->m_scene->GetPhysicsEnvironment(); KX_RayCast::Callback<KX_RaySensor> callback(this, spc); KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback); /* now pass this result to some controller */ if (m_rayHit) { if (!m_bTriggered) { // notify logicsystem that ray is now hitting result = true; m_bTriggered = true; } else { // notify logicsystem that ray is STILL hitting ... result = false; } } else { if (m_bTriggered) { m_bTriggered = false; // notify logicsystem that ray JUST left the Object result = true; } else { result = false; } } if (reset) // force an event result = true; return result; }
INT_PTR CALLBACK EtpWsWatchDlgProc( _In_ HWND hwndDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) { PWS_WATCH_CONTEXT context; if (uMsg == WM_INITDIALOG) { context = (PWS_WATCH_CONTEXT)lParam; SetProp(hwndDlg, L"Context", (HANDLE)context); } else { context = (PWS_WATCH_CONTEXT)GetProp(hwndDlg, L"Context"); if (uMsg == WM_DESTROY) RemoveProp(hwndDlg, L"Context"); } if (!context) return FALSE; switch (uMsg) { case WM_INITDIALOG: { HWND lvHandle; PhCenterWindow(hwndDlg, GetParent(hwndDlg)); context->WindowHandle = hwndDlg; context->ListViewHandle = lvHandle = GetDlgItem(hwndDlg, IDC_LIST); PhSetListViewStyle(lvHandle, FALSE, TRUE); PhSetControlTheme(lvHandle, L"explorer"); PhAddListViewColumn(lvHandle, 0, 0, 0, LVCFMT_LEFT, 340, L"Instruction"); PhAddListViewColumn(lvHandle, 1, 1, 1, LVCFMT_LEFT, 80, L"Count"); PhSetExtendedListView(lvHandle); ExtendedListView_SetSort(lvHandle, 1, DescendingSortOrder); context->Hashtable = PhCreateSimpleHashtable(64); context->BufferSize = 0x2000; context->Buffer = PhAllocate(context->BufferSize); PhInitializeQueuedLock(&context->ResultListLock); context->SymbolProvider = PhCreateSymbolProvider(context->ProcessItem->ProcessId); PhLoadSymbolProviderOptions(context->SymbolProvider); if (!context->SymbolProvider || !context->SymbolProvider->IsRealHandle) { PhShowError(hwndDlg, L"Unable to open the process."); EndDialog(hwndDlg, IDCANCEL); break; } context->ProcessHandle = context->SymbolProvider->ProcessHandle; // Load symbols for both process and kernel modules. context->LoadingSymbolsForProcessId = context->ProcessItem->ProcessId; PhEnumGenericModules( NULL, context->ProcessHandle, 0, EnumGenericModulesCallback, context ); context->LoadingSymbolsForProcessId = SYSTEM_PROCESS_ID; PhEnumGenericModules( SYSTEM_PROCESS_ID, NULL, 0, EnumGenericModulesCallback, context ); context->Enabled = EtpUpdateWsWatch(hwndDlg, context); if (context->Enabled) { // WS Watch is already enabled for the process. Enable updating. EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE), FALSE); ShowWindow(GetDlgItem(hwndDlg, IDC_WSWATCHENABLED), SW_SHOW); SetTimer(hwndDlg, 1, 1000, NULL); } else { // WS Watch has not yet been enabled for the process. } } break; case WM_DESTROY: { context->Destroying = TRUE; PhDereferenceObject(context->Hashtable); if (context->Buffer) { PhFree(context->Buffer); context->Buffer = NULL; } } break; case WM_COMMAND: { switch (LOWORD(wParam)) { case IDCANCEL: case IDOK: EndDialog(hwndDlg, IDOK); break; case IDC_ENABLE: { NTSTATUS status; HANDLE processHandle; if (NT_SUCCESS(status = PhOpenProcess( &processHandle, PROCESS_SET_INFORMATION, context->ProcessItem->ProcessId ))) { status = NtSetInformationProcess( processHandle, ProcessWorkingSetWatchEx, NULL, 0 ); NtClose(processHandle); } if (NT_SUCCESS(status)) { EnableWindow(GetDlgItem(hwndDlg, IDC_ENABLE), FALSE); ShowWindow(GetDlgItem(hwndDlg, IDC_WSWATCHENABLED), SW_SHOW); SetTimer(hwndDlg, 1, 1000, NULL); } else { PhShowStatus(hwndDlg, L"Unable to enable WS watch", status, 0); } } break; } } break; case WM_NOTIFY: { PhHandleListViewNotifyForCopy(lParam, context->ListViewHandle); } break; case WM_TIMER: { switch (wParam) { case 1: { EtpUpdateWsWatch(hwndDlg, context); } break; } } break; } return FALSE; }
static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { HWND hTree = GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE); OrderData *dat = (OrderData*)GetWindowLongPtr(hTree, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); dat = (OrderData*)malloc( sizeof(OrderData)); SetWindowLongPtr(hTree, GWLP_USERDATA, (LONG_PTR)dat); dat->dragging = 0; SetWindowLongPtr(hTree, GWL_STYLE, GetWindowLongPtr(hTree, GWL_STYLE)|TVS_NOHSCROLL); SetDlgItemInt(hwndDlg, IDC_BUTTHEIGHT, g_ctrl->nButtonHeight, FALSE); SendDlgItemMessage(hwndDlg, IDC_SPIN_HEIGHT, UDM_SETRANGE, 0, MAKELONG(50,10)); SendDlgItemMessage(hwndDlg, IDC_SPIN_HEIGHT, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonHeight,0)); SetDlgItemInt(hwndDlg, IDC_BUTTWIDTH, g_ctrl->nButtonWidth, FALSE); SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETRANGE, 0, MAKELONG(50,10)); SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonWidth,0)); SetDlgItemInt(hwndDlg, IDC_BUTTGAP, g_ctrl->nButtonSpace, FALSE); SendDlgItemMessage(hwndDlg, IDC_SPIN_GAP, UDM_SETRANGE, 0, MAKELONG(20,0)); SendDlgItemMessage(hwndDlg, IDC_SPIN_GAP, UDM_SETPOS, 0, MAKELONG(g_ctrl->nButtonSpace,0)); CheckDlgButton(hwndDlg, IDC_USEFLAT, g_ctrl->bFlatButtons); CheckDlgButton(hwndDlg, IDC_AUTORESIZE, g_ctrl->bAutoSize); CheckDlgButton(hwndDlg, IDC_SINGLELINE, g_ctrl->bSingleLine); BuildTree(hwndDlg); EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_DELLBUTTON), FALSE); OptionshWnd = hwndDlg; return TRUE; case WM_COMMAND: if (HIWORD(wParam) == EN_CHANGE && OptionshWnd) { switch(LOWORD(wParam)) { case IDC_ENAME: case IDC_EPATH: break; default: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } break; } if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == BN_DBLCLK)) { int ctrlid = LOWORD(wParam); //----- Launch buttons ----- if (ctrlid == IDC_BROWSE) { TCHAR str[MAX_PATH]; OPENFILENAME ofn = {0}; GetDlgItemText(hwndDlg, IDC_EPATH, str, sizeof(str)); ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.hwndOwner = hwndDlg; ofn.hInstance = NULL; ofn.lpstrFilter = NULL; ofn.lpstrFile = str; ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_EXPLORER; ofn.nMaxFile = sizeof(str); ofn.nMaxFileTitle = MAX_PATH; ofn.lpstrDefExt = _T("exe"); if (!GetOpenFileName(&ofn)) break; SetDlgItemText(hwndDlg, IDC_EPATH, str); break; } SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); if (ctrlid == IDC_LBUTTONSET) { TVITEM tvi ={0}; tvi.hItem = TreeView_GetSelection(hTree); if (tvi.hItem == NULL) break; tvi.mask = TVIF_PARAM; TreeView_GetItem(hTree, &tvi); TopButtonInt* btn = (TopButtonInt*)tvi.lParam; TCHAR buf [256]; // probably, condition not needs if (btn->dwFlags & TTBBF_ISLBUTTON) { if (!(btn->dwFlags & TTBBF_OPTIONAL)) { // create button TTBButton ttb = { 0 }; ttb.cbSize = sizeof(ttb); ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL | TTBBF_OPTIONAL; ttb.name = NULL; ttb.program = NULL; int id = btn->id; btn = CreateButton(&ttb); btn->id = id; tvi.lParam = (LPARAM)btn; TreeView_SetItem(hTree, &tvi); } GetDlgItemText(hwndDlg, IDC_ENAME, buf, 255); replaceStr(btn->pszName, _T2A(buf)); tvi.mask = TVIF_TEXT; tvi.pszText = buf; TreeView_SetItem(hTree, &tvi); GetDlgItemText(hwndDlg, IDC_EPATH, buf, 255); replaceStrT(btn->ptszProgram, buf); } break; } if (ctrlid == IDC_ADDLBUTTON) { // create button TTBButton ttb = { 0 }; ttb.cbSize = sizeof(ttb); ttb.hIconDn = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_RUN), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISLBUTTON | TTBBF_INTERNAL | TTBBF_OPTIONAL; ttb.name = LPGEN("Default"); ttb.program = _T("Execute Path"); TopButtonInt* b = CreateButton(&ttb); // get selection for insert TVITEM tvi = {0}; tvi.hItem = TreeView_GetSelection(hTree); // insert item AddLine(hTree, b, tvi.hItem, dat->himlButtonIcons); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } //----- Separators ----- if (ctrlid == IDC_ADDSEP) { // create button TTBButton ttb = { 0 }; ttb.cbSize = sizeof(ttb); ttb.dwFlags = TTBBF_VISIBLE | TTBBF_ISSEPARATOR | TTBBF_INTERNAL | TTBBF_OPTIONAL; TopButtonInt* b = CreateButton(&ttb); // get selection for insert TVITEM tvi = {0}; tvi.hItem = TreeView_GetSelection(hTree); // insert item AddLine(hTree, b, tvi.hItem, dat->himlButtonIcons); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } if (ctrlid == IDC_REMOVEBUTTON) { TVITEM tvi = {0}; tvi.hItem = TreeView_GetSelection(hTree); if (tvi.hItem == NULL) break; tvi.mask = TVIF_PARAM; TreeView_GetItem(hTree, &tvi); TopButtonInt* btn = (TopButtonInt*)tvi.lParam; // if button enabled for separator and launch only, no need condition // except possible service button introducing if (btn->dwFlags & (TTBBF_ISSEPARATOR | TTBBF_ISLBUTTON)) { // delete if was added in options if (btn->dwFlags & TTBBF_OPTIONAL) delete btn; TreeView_DeleteItem(hTree,tvi.hItem); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } break; } } break; case WM_NOTIFY: switch(((LPNMHDR)lParam)->idFrom) { case 0: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: g_ctrl->nButtonHeight = GetDlgItemInt(hwndDlg, IDC_BUTTHEIGHT, NULL, FALSE); g_ctrl->nButtonWidth = GetDlgItemInt(hwndDlg, IDC_BUTTWIDTH, NULL, FALSE); g_ctrl->nButtonSpace = GetDlgItemInt(hwndDlg, IDC_BUTTGAP, NULL, FALSE); g_ctrl->bFlatButtons = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_USEFLAT); g_ctrl->bAutoSize = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_AUTORESIZE); g_ctrl->bSingleLine = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SINGLELINE); db_set_dw(0, TTB_OPTDIR, "BUTTHEIGHT", g_ctrl->nButtonHeight); db_set_dw(0, TTB_OPTDIR, "BUTTWIDTH", g_ctrl->nButtonWidth); db_set_dw(0, TTB_OPTDIR, "BUTTGAP", g_ctrl->nButtonSpace); db_set_b(0, TTB_OPTDIR, "UseFlatButton", g_ctrl->bFlatButtons); db_set_b(0, TTB_OPTDIR, "SingleLine", g_ctrl->bSingleLine); db_set_b(0, TTB_OPTDIR, "AutoSize", g_ctrl->bAutoSize); SaveTree(hwndDlg); RecreateWindows(); ArrangeButtons(); } break; case IDC_BUTTONORDERTREE: switch (((LPNMHDR)lParam)->code) { case TVN_BEGINDRAGA: case TVN_BEGINDRAGW: SetCapture(hwndDlg); dat->dragging = 1; dat->hDragItem = ((LPNMTREEVIEW)lParam)->itemNew.hItem; TreeView_SelectItem(hTree, dat->hDragItem); break; case NM_CLICK: { TVHITTESTINFO hti; hti.pt.x = (short)LOWORD(GetMessagePos()); hti.pt.y = (short)HIWORD(GetMessagePos()); ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt); if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti)) if (hti.flags & TVHT_ONITEMSTATEICON) { SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); TreeView_SelectItem(hTree, hti.hItem); } } break; case TVN_SELCHANGEDA: case TVN_SELCHANGEDW: { HTREEITEM hti = TreeView_GetSelection(hTree); if (hti == NULL) break; TopButtonInt *btn = (TopButtonInt*)((LPNMTREEVIEW)lParam)->itemNew.lParam; mir_cslock lck(csButtonsHook); if (btn->dwFlags & TTBBF_ISLBUTTON) { bool enable = (btn->dwFlags & TTBBF_INTERNAL) !=0; EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), enable); EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), enable); EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVEBUTTON), enable); EnableWindow(GetDlgItem(hwndDlg, IDC_LBUTTONSET), enable); if (btn->pszName != NULL) SetDlgItemTextA(hwndDlg, IDC_ENAME, btn->pszName); else SetDlgItemTextA(hwndDlg, IDC_ENAME, ""); if (btn->ptszProgram != NULL) SetDlgItemText(hwndDlg, IDC_EPATH, btn->ptszProgram); else SetDlgItemTextA(hwndDlg, IDC_EPATH, ""); } else { EnableWindow(GetDlgItem(hwndDlg,IDC_REMOVEBUTTON), (btn->dwFlags & TTBBF_ISSEPARATOR)?TRUE:FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_ENAME), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_EPATH), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_LBUTTONSET), FALSE); SetDlgItemTextA(hwndDlg, IDC_ENAME, ""); SetDlgItemTextA(hwndDlg, IDC_EPATH, ""); } } } break; } break; case WM_MOUSEMOVE: if (dat->dragging) { TVHITTESTINFO hti; hti.pt.x = (short)LOWORD(lParam); hti.pt.y = (short)HIWORD(lParam); ClientToScreen(hwndDlg, &hti.pt); ScreenToClient(hTree, &hti.pt); TreeView_HitTest(hTree, &hti); if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) { HTREEITEM it=hti.hItem; hti.pt.y -= TreeView_GetItemHeight(hTree)/2; TreeView_HitTest(hTree, &hti); if (!(hti.flags&TVHT_ABOVE)) TreeView_SetInsertMark(hTree,hti.hItem,1); else TreeView_SetInsertMark(hTree,it,0); } else { if (hti.flags & TVHT_ABOVE) SendMessage(hTree, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0); if (hti.flags & TVHT_BELOW) SendMessage(hTree, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0); TreeView_SetInsertMark(hTree, NULL, 0); } } break; case WM_LBUTTONUP: if (dat->dragging) { TreeView_SetInsertMark(hTree, NULL, 0); dat->dragging = 0; ReleaseCapture(); TVHITTESTINFO hti; hti.pt.x = (short)LOWORD(lParam); hti.pt.y = (short)HIWORD(lParam); ClientToScreen(hwndDlg, &hti.pt); ScreenToClient(hTree, &hti.pt); hti.pt.y -= TreeView_GetItemHeight(hTree)/2; TreeView_HitTest(hTree, &hti); if (dat->hDragItem == hti.hItem) break; if (hti.flags&TVHT_ABOVE) hti.hItem=TVI_FIRST; TVITEM tvi; tvi.mask = TVIF_HANDLE|TVIF_PARAM; tvi.hItem = (HTREEITEM) dat->hDragItem; TreeView_GetItem(hTree, &tvi); if ( (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT)) || (hti.hItem==TVI_FIRST)) { TVINSERTSTRUCT tvis; TCHAR name[128]; tvis.item.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE; tvis.item.stateMask = 0xFFFFFFFF; tvis.item.pszText = name; tvis.item.cchTextMax = SIZEOF(name); tvis.item.hItem = dat->hDragItem; TreeView_GetItem(hTree, &tvis.item); TreeView_DeleteItem(hTree, dat->hDragItem); tvis.hParent = NULL; tvis.hInsertAfter = hti.hItem; TreeView_SelectItem(hTree, TreeView_InsertItem(hTree, &tvis)); SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } } break; case WM_DESTROY: if (dat) { ImageList_Destroy(dat->himlButtonIcons); free(dat); } OptionshWnd = NULL; break; } return FALSE; }
/*-------------------------------------------------- initialize ----------------------------------------------------*/ void InitTrayNotify(HWND hwndClock) { HWND hwnd, hwnd2; char classname[80]; EndTrayNotify(); bFillTray = GetMyRegLong(NULL, "FillTray", FALSE); bFlatTray = GetMyRegLong(NULL, "FlatTray", TRUE); bSkinTray = GetMyRegLong(NULL, "SkinTray", FALSE); // if(bSkinTray) bFillTray = FALSE; // ちょっと強引に設定の矛盾をなくす if(!bFillTray && !bFlatTray && !bSkinTray) return ; // get window handle of TrayNotifyWnd hwndTrayNotify = GetParent(hwndClock); // TrayNotifyWnd // search toolbar if(bFillTray) { hwndToolbar = NULL; hwnd = GetWindow(hwndTrayNotify, GW_CHILD); while(hwnd) { GetClassName(hwnd, classname, 80); if(lstrcmpi(classname, "ToolbarWindow32") == 0) { hwndToolbar = hwnd; break; }else if(lstrcmpi(classname, "SysPager") == 0) { hwnd2 = GetWindow(hwnd, GW_CHILD); while(hwnd2) { GetClassName(hwnd2, classname, 80); if(lstrcmpi(classname, "ToolbarWindow32") == 0) { hwndToolbar = hwnd2; break; } } hwnd2 = GetWindow(hwnd2, GW_HWNDNEXT); } hwnd = GetWindow(hwnd, GW_HWNDNEXT); } if(hwndToolbar == NULL) { bFillTray = FALSE; } } if(bFillTray) { s_hwndClock = hwndClock; oldClassStyleTrayNotify = GetClassLongPtr(hwndTrayNotify, GCL_STYLE); SetClassLongPtr(hwndTrayNotify, GCL_STYLE, oldClassStyleTrayNotify|CS_HREDRAW|CS_VREDRAW); oldWndProcTrayNotify = (WNDPROC)GetWindowLongPtr(hwndTrayNotify, GWLP_WNDPROC); SubclassWindow(hwndTrayNotify, WndProcTrayNotify); oldStyleTrayNotify = GetWindowLongPtr(hwndTrayNotify, GWL_STYLE); SetWindowLongPtr(hwndTrayNotify, GWL_STYLE, oldStyleTrayNotify & ~(WS_CLIPCHILDREN|WS_CLIPSIBLINGS)); } if(bFlatTray) { oldExStyleTrayNotify = GetWindowLongPtr(hwndTrayNotify, GWL_EXSTYLE); SetWindowLongPtr(hwndTrayNotify, GWL_EXSTYLE, oldExStyleTrayNotify & ~WS_EX_STATICEDGE); SetWindowPos(hwndTrayNotify, NULL, 0, 0, 0, 0, SWP_DRAWFRAME|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER); } if(bFillTray || bFlatTray) InvalidateRect(hwndTrayNotify, NULL, TRUE); // if(bFillTray) // SendMessage(hwndToolbar, WM_SYSCOLORCHANGE, 0, 0); if(bFillTray) { if(!bWinXP) SendMessage(hwndToolbar, WM_SYSCOLORCHANGE, 0, 0); else SendMessage(GetParent(hwndToolbar), WM_SYSCOLORCHANGE, 0, 0); } #ifdef TEST_505 { RECT rc; LONG style; style = GetWindowLongPtr(hwndTrayNotify, GWL_STYLE); style |= WS_POPUPWINDOW | WS_CAPTION; SetWindowLongPtr(hwndTrayNotify, GWL_STYLE, style); GetWindowRect(hwndTrayNotify, &rc); SetWindowPos(hwndTrayNotify, NULL, rc.left - 20, rc.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); } #endif //TEST_505 }
bool TrackBar::OnEventMouse(Event event,WPARAM wparam,LPARAM lparam) { if(!GetVisible() || !GetEnabled()) return false; switch(event) { case EventLeftButtonDown: if(PointInTrack(*(Point*)wparam)) { if(!GetFocused()) Focus(); mTracking = true; mTrackingValue = mValue; mTrackingPosition = ((Point*)wparam)->x - GetTrackBox().GetCenter().x; SetCapture(GetKernel()->GetWindowHandle()); return true; } if(PointIn(*(Point*)wparam)) { if(!GetFocused()) Focus(); if(((Point*)wparam)->x > GetTrackBox().GetCenter().x) { if(GetTrackValue() < GetTrackRange()) SetTrackValue(GetTrackValue() + 1); } else { if(GetTrackValue()) SetTrackValue(GetTrackValue() - 1); } return true; } break; case EventLeftButtonUp: if(mTracking) { mTracking = false; ReleaseCapture(); return true; } break; case EventMouseMove: if(mTracking) { Point delta = *(Point*)wparam; delta.x -= GetScreenPosition().x + mTrackingPosition; float val = (float)GetBoundingBox().GetWidth() / (float)GetTrackRange(); if((float)delta.x / val > (float)GetTrackRange()) SetTrackValue(GetTrackRange()); else if((float)delta.x / val < 0.0f) SetTrackValue(0); else SetTrackValue((float)delta.x / val); if(GetParent()) GetParent()->OnEvent(EventChildCommand,ControlEventTrackChange,(LPARAM)this); } break; } return Control::OnEventMouse(event,wparam,lparam); }
static LRESULT CALLBACK TSButtonWndProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { MButtonCtrl *bct = (MButtonCtrl *) GetWindowLongPtr(hwndDlg, 0); switch (msg) { case WM_NCCREATE: { SetWindowLong(hwndDlg, GWL_STYLE, GetWindowLong(hwndDlg, GWL_STYLE) | BS_OWNERDRAW); bct = reinterpret_cast<MButtonCtrl *>(malloc(sizeof(MButtonCtrl))); if (bct == NULL) return FALSE; bct->hwnd = hwndDlg; bct->stateId = PBS_NORMAL; bct->focus = 0; bct->hFont = reinterpret_cast<HFONT>(GetStockObject(DEFAULT_GUI_FONT)); bct->arrow = NULL; bct->defbutton = 0; bct->hIcon = bct->hIconPrivate = 0; bct->iIcon = 0; bct->hIml = 0; bct->hBitmap = NULL; bct->pushBtn = 0; bct->pbState = 0; bct->hThemeButton = NULL; bct->hThemeToolbar = NULL; bct->cHot = 0; bct->flatBtn = 0; bct->bThemed = FALSE; bct->bSkinned = bct->bSendOnDown = 0; bct->buttonItem = NULL; LoadTheme(bct); SetWindowLongPtr(hwndDlg, 0, (LONG_PTR) bct); if (((CREATESTRUCTA *) lParam)->lpszName) SetWindowText(hwndDlg, ((CREATESTRUCT *) lParam)->lpszName); return TRUE; } case WM_DESTROY: { if (bct) { if (hwndToolTips) { TOOLINFO ti; ZeroMemory(&ti, sizeof(ti)); ti.cbSize = sizeof(ti); ti.uFlags = TTF_IDISHWND; ti.hwnd = bct->hwnd; ti.uId = (UINT_PTR) bct->hwnd; if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM) &ti)) { SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM) &ti); } if (SendMessage(hwndToolTips, TTM_GETTOOLCOUNT, 0, (LPARAM) &ti) == 0) { DestroyWindow(hwndToolTips); hwndToolTips = NULL; } } if (bct->hIconPrivate) DestroyIcon(bct->hIconPrivate); DestroyTheme(bct); free(bct); } SetWindowLongPtr(hwndDlg, 0, 0); break; // DONT! fall thru } case WM_SETTEXT: { bct->cHot = 0; if ((char*) lParam) { char *tmp = (char *) lParam; while (*tmp) { if (*tmp == '&' && *(tmp + 1)) { bct->cHot = tolower(*(tmp + 1)); break; } tmp++; } InvalidateRect(bct->hwnd, NULL, TRUE); lstrcpyn(bct->szText, (TCHAR *)lParam, 127); bct->szText[127] = 0; } break; } case WM_SYSKEYUP: if (bct->stateId != PBS_DISABLED && bct->cHot && bct->cHot == tolower((int) wParam)) { if (bct->pushBtn) { if (bct->pbState) bct->pbState = 0; else bct->pbState = 1; InvalidateRect(bct->hwnd, NULL, TRUE); } if(!bct->bSendOnDown) SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg); return 0; } break; case WM_THEMECHANGED: { if (bct->bThemed) LoadTheme(bct); InvalidateRect(bct->hwnd, NULL, TRUE); // repaint it break; } case WM_SETFONT: // remember the font so we can use it later { bct->hFont = (HFONT) wParam; // maybe we should redraw? break; } case WM_NCPAINT: case WM_PAINT: { PAINTSTRUCT ps; HDC hdcPaint; hdcPaint = BeginPaint(hwndDlg, &ps); if (hdcPaint) { PaintWorker(bct, hdcPaint); EndPaint(hwndDlg, &ps); } break; } case BM_GETIMAGE: if(wParam == IMAGE_ICON) return (LRESULT)(bct->hIconPrivate ? bct->hIconPrivate : bct->hIcon); break; case BM_SETIMAGE: if(!lParam) break; bct->hIml = 0; bct->iIcon = 0; if (wParam == IMAGE_ICON) { ICONINFO ii = {0}; BITMAP bm = {0}; if (bct->hIconPrivate) { DestroyIcon(bct->hIconPrivate); bct->hIconPrivate = 0; } GetIconInfo((HICON) lParam, &ii); GetObject(ii.hbmColor, sizeof(bm), &bm); if (bm.bmWidth > g_cxsmIcon || bm.bmHeight > g_cysmIcon) { HIMAGELIST hImageList; hImageList = ImageList_Create(g_cxsmIcon, g_cysmIcon, IsWinVerXPPlus() ? ILC_COLOR32 | ILC_MASK : ILC_COLOR16 | ILC_MASK, 1, 0); ImageList_AddIcon(hImageList, (HICON) lParam); bct->hIconPrivate = ImageList_GetIcon(hImageList, 0, ILD_NORMAL); ImageList_RemoveAll(hImageList); ImageList_Destroy(hImageList); bct->hIcon = 0; } else { bct->hIcon = (HICON) lParam; bct->hIconPrivate = 0; } DeleteObject(ii.hbmMask); DeleteObject(ii.hbmColor); bct->hBitmap = NULL; InvalidateRect(bct->hwnd, NULL, TRUE); } else if (wParam == IMAGE_BITMAP) { bct->hBitmap = (HBITMAP) lParam; if (bct->hIconPrivate) DestroyIcon(bct->hIconPrivate); bct->hIcon = bct->hIconPrivate = NULL; InvalidateRect(bct->hwnd, NULL, TRUE); } break; case BM_SETPRIVATEICON: bct->hIml = 0; bct->iIcon = 0; { if (bct->hIconPrivate) DestroyIcon(bct->hIconPrivate); bct->hIconPrivate = DuplicateIcon(g_hInst, (HICON) lParam); bct->hIcon = 0; break; } case BM_SETIMLICON: { if (bct->hIconPrivate) DestroyIcon(bct->hIconPrivate); bct->hIml = (HIMAGELIST) wParam; bct->iIcon = (int) lParam; bct->hIcon = bct->hIconPrivate = 0; InvalidateRect(bct->hwnd, NULL, TRUE); break; } case BM_SETSKINNED: bct->bSkinned = (DWORD)lParam; bct->bThemed = bct->bSkinned ? FALSE : bct->bThemed; InvalidateRect(bct->hwnd, NULL, TRUE); break; case BM_SETBTNITEM: bct->buttonItem = (ButtonItem *)lParam; break; case BM_SETASMENUACTION: bct->bSendOnDown = wParam ? TRUE : FALSE; return 0; case BM_SETCHECK: if (!bct->pushBtn) break; if (wParam == BST_CHECKED) { bct->pbState = 1; bct->stateId = PBS_PRESSED; } else if (wParam == BST_UNCHECKED) { bct->pbState = 0; bct->stateId = PBS_NORMAL; } InvalidateRect(bct->hwnd, NULL, TRUE); break; case BM_GETCHECK: if (bct->pushBtn) { return bct->pbState ? BST_CHECKED : BST_UNCHECKED; } return 0; case BUTTONSETARROW: // turn arrow on/off if (wParam) { if (!bct->arrow) bct->arrow = (HICON) LoadImage(g_hInst, MAKEINTRESOURCE(IDI_MINIMIZE), IMAGE_ICON, g_cxsmIcon, g_cysmIcon, 0); } else { if (bct->arrow) { DestroyIcon(bct->arrow); bct->arrow = NULL; } } InvalidateRect(bct->hwnd, NULL, TRUE); break; case BUTTONSETDEFAULT: bct->defbutton = wParam ? 1 : 0; InvalidateRect(bct->hwnd, NULL, TRUE); break; case BUTTONSETASPUSHBTN: bct->pushBtn = 1; InvalidateRect(bct->hwnd, NULL, TRUE); break; case BUTTONSETASFLATBTN: bct->flatBtn = lParam == 0 ? 1 : 0; InvalidateRect(bct->hwnd, NULL, TRUE); break; case BUTTONSETASFLATBTN + 10: bct->bThemed = lParam ? TRUE : FALSE; bct->bSkinned = bct->bThemed ? 0 : bct->bSkinned; break; case BUTTONADDTOOLTIP: { TOOLINFO ti; if (!(char*) wParam) break; if (!hwndToolTips) { hwndToolTips = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, _T(""), WS_POPUP, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL); SetWindowPos(hwndToolTips, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); } ZeroMemory(&ti, sizeof(ti)); ti.cbSize = sizeof(ti); ti.uFlags = TTF_IDISHWND; ti.hwnd = bct->hwnd; ti.uId = (UINT_PTR) bct->hwnd; if (SendMessage(hwndToolTips, TTM_GETTOOLINFO, 0, (LPARAM) &ti)) { SendMessage(hwndToolTips, TTM_DELTOOL, 0, (LPARAM) &ti); } ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS; ti.uId = (UINT_PTR) bct->hwnd; ti.lpszText = (TCHAR *) wParam; SendMessage(hwndToolTips, TTM_ADDTOOL, 0, (LPARAM) &ti); break; } case WM_SETFOCUS: // set keybord focus and redraw bct->focus = 1; InvalidateRect(bct->hwnd, NULL, TRUE); break; case WM_KILLFOCUS: // kill focus and redraw bct->focus = 0; InvalidateRect(bct->hwnd, NULL, TRUE); break; case WM_WINDOWPOSCHANGED: InvalidateRect(bct->hwnd, NULL, TRUE); break; case WM_ENABLE: // windows tells us to enable/disable { bct->stateId = wParam ? PBS_NORMAL : PBS_DISABLED; InvalidateRect(bct->hwnd, NULL, TRUE); break; } case WM_MOUSELEAVE: // faked by the WM_TIMER { if (bct->stateId != PBS_DISABLED) { // don't change states if disabled bct->stateId = PBS_NORMAL; InvalidateRect(bct->hwnd, NULL, TRUE); } break; } case WM_LBUTTONDOWN: { if (bct->stateId != PBS_DISABLED && bct->stateId != PBS_PRESSED) { bct->stateId = PBS_PRESSED; InvalidateRect(bct->hwnd, NULL, TRUE); if(bct->bSendOnDown) { SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg); bct->stateId = PBS_NORMAL; InvalidateRect(bct->hwnd, NULL, TRUE); } } break; } case WM_LBUTTONUP: { if (bct->pushBtn) { if (bct->pbState) bct->pbState = 0; else bct->pbState = 1; } if (bct->stateId != PBS_DISABLED) { // don't change states if disabled if (msg == WM_LBUTTONUP) bct->stateId = PBS_HOT; else bct->stateId = PBS_NORMAL; InvalidateRect(bct->hwnd, NULL, TRUE); } if(!bct->bSendOnDown) SendMessage(GetParent(hwndDlg), WM_COMMAND, MAKELONG(GetDlgCtrlID(hwndDlg), BN_CLICKED), (LPARAM) hwndDlg); break; } case WM_MOUSEMOVE: if (bct->stateId == PBS_NORMAL) { bct->stateId = PBS_HOT; InvalidateRect(bct->hwnd, NULL, TRUE); } // Call timer, used to start cheesy TrackMouseEvent faker SetTimer(hwndDlg, BUTTON_POLLID, BUTTON_POLLDELAY, NULL); break; case WM_NCHITTEST: { LRESULT lr = SendMessage(GetParent(hwndDlg), WM_NCHITTEST, wParam, lParam); if(lr == HTLEFT || lr == HTRIGHT || lr == HTBOTTOM || lr == HTTOP || lr == HTTOPLEFT || lr == HTTOPRIGHT || lr == HTBOTTOMLEFT || lr == HTBOTTOMRIGHT) return HTTRANSPARENT; break; } case WM_TIMER: // use a timer to check if they have did a mouseout { if (wParam == BUTTON_POLLID) { RECT rc; POINT pt; GetWindowRect(hwndDlg, &rc); GetCursorPos(&pt); if (!PtInRect(&rc, pt)) { // mouse must be gone, trigger mouse leave PostMessage(hwndDlg, WM_MOUSELEAVE, 0, 0L); KillTimer(hwndDlg, BUTTON_POLLID); } } break; } case WM_ERASEBKGND: return 1; } return DefWindowProc(hwndDlg, msg, wParam, lParam); }
void sim_area_widget::paint_world(wxPaintEvent&) { const model& app_model = (dynamic_cast<biosim_gui_impl&>(*GetParent())).app_model(); const world_map& map = app_model.map(); wxBufferedPaintDC dc(this); dc.SetBackground(wxBrush(wxColor(0,0,0))); dc.Clear(); wxSize client_size(GetClientSize()); int scroll_pixel_x = scroll_x_ % tile_size_x; int scroll_pixel_y = scroll_y_ % tile_size_y; int tile_x_start = (scroll_x_ - scroll_pixel_x) / tile_size_x; int tile_y_start = (scroll_y_ - scroll_pixel_y) / tile_size_y; int tile_x_end = (scroll_x_ + client_size.GetX() - scroll_pixel_x) / tile_size_x + 1; int tile_y_end = (scroll_y_ + client_size.GetY() - scroll_pixel_y) / tile_size_y + 1; for (int y = tile_y_start; y <= tile_y_end; ++y) for (int x = tile_x_start; x <= tile_x_end; ++x) { if (x < 0 || y < 0 || x >= map.size_x() || y >= map.size_y()) continue; int tilepos_x = (x - tile_x_start) * tile_size_x - scroll_pixel_x; int tilepos_y = (y - tile_y_start) * tile_size_y - scroll_pixel_y; dc.DrawBitmap(env_bitmaps_[map.at(x, y).climate()], tilepos_x, tilepos_y); if (x == app_model.cursor_x() && y == app_model.cursor_y()) { dc.DrawBitmap(cursor_bitmap_, tilepos_x, tilepos_y); } const world_tile& tile = map.at(x, y); for (world_tile::creature_iterator it(tile.begin()); it != tile.end(); ++it) { if((*it)->is_alive()) { const creature_prototype *prototype = &((*it)->prototype); std::map<const creature_prototype*, wxBitmap>::iterator find_graphics (creature_bitmaps_.find(prototype)); if (find_graphics == creature_bitmaps_.end()) { find_graphics = creature_bitmaps_.insert (std::pair<const creature_prototype*, wxBitmap> (prototype, convert_to_bitmap(prototype->graphics()))).first; } dc.DrawBitmap(find_graphics->second, tilepos_x, tilepos_y); } else dc.DrawBitmap(dead_bitmap_, tilepos_x, tilepos_y); } } }
LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { ClcContact *contact; ClcGroup *group; BOOL frameHasTitlebar = FALSE; if (wndFrameCLC) frameHasTitlebar = wndFrameCLC->TitleBar.ShowTitleBar; ClcData *dat = (struct ClcData *)GetWindowLongPtr(hwnd, 0); if (msg >= CLM_FIRST && msg < CLM_LAST) return ProcessExternalMessages(hwnd, dat, msg, wParam, lParam); switch (msg) { case WM_CREATE: dat = (struct ClcData *)mir_calloc(sizeof(struct ClcData)); SetWindowLongPtr(hwnd, 0, (LONG_PTR)dat); RowHeight::Init(dat); dat->forceScroll = 0; dat->lastRepaint = 0; dat->hwndParent = GetParent(hwnd); dat->lastSort = GetTickCount(); dat->needsResort = FALSE; { CREATESTRUCT *cs = (CREATESTRUCT *)lParam; if (cs->lpCreateParams == (LPVOID)0xff00ff00) { dat->bisEmbedded = FALSE; dat->bHideSubcontacts = TRUE; cfg::clcdat = dat; if (cfg::dat.bShowLocalTime) SetTimer(hwnd, TIMERID_REFRESH, 65000, NULL); } else dat->bisEmbedded = TRUE; } break; case WM_SIZE: pcli->pfnEndRename(hwnd, dat, 1); KillTimer(hwnd, TIMERID_INFOTIP); KillTimer(hwnd, TIMERID_RENAME); pcli->pfnRecalcScrollBar(hwnd, dat); LBL_Def: return DefWindowProc(hwnd, msg, wParam, lParam); case WM_NCCALCSIZE: return FrameNCCalcSize(hwnd, DefWindowProc, wParam, lParam, frameHasTitlebar); /* * scroll bar handling */ case WM_NCPAINT: return FrameNCPaint(hwnd, DefWindowProc, wParam, lParam, frameHasTitlebar); case INTM_GROUPCHANGED: { WORD iExtraImage[EXTRA_ICON_COUNT]; BYTE flags = 0; if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) memset(iExtraImage, 0xFF, sizeof(iExtraImage)); else { memcpy(iExtraImage, contact->iExtraImage, sizeof(iExtraImage)); flags = contact->flags; } pcli->pfnDeleteItemFromTree(hwnd, wParam); if (GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_SHOWHIDDEN || !CLVM_GetContactHiddenStatus(wParam, NULL, dat)) { pcli->pfnAddContactToTree(hwnd, dat, wParam, 1, 1); if (FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) { memcpy(contact->iExtraImage, iExtraImage, sizeof(iExtraImage)); if (flags & CONTACTF_CHECKED) contact->flags |= CONTACTF_CHECKED; } NMCLISTCONTROL nm; nm.hdr.code = CLN_CONTACTMOVED; nm.hdr.hwndFrom = hwnd; nm.hdr.idFrom = GetDlgCtrlID(hwnd); nm.flags = 0; nm.hItem = (HANDLE)wParam; SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM)&nm); } dat->needsResort = TRUE; PostMessage(hwnd, INTM_SORTCLC, 0, 1); } goto LBL_Def; case INTM_ICONCHANGED: { int recalcScrollBar = 0; MCONTACT hContact = wParam; WORD status = ID_STATUS_OFFLINE; int contactRemoved = 0; MCONTACT hSelItem = NULL; ClcContact *selcontact = NULL; char *szProto = GetContactProto(hContact); if (szProto == NULL) status = ID_STATUS_OFFLINE; else status = cfg::getWord(hContact, szProto, "Status", ID_STATUS_OFFLINE); int shouldShow = (GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_SHOWHIDDEN || !CLVM_GetContactHiddenStatus(hContact, szProto, dat)) && ((cfg::dat.bFilterEffective ? TRUE : !pcli->pfnIsHiddenMode(dat, status)) || pcli->pfnGetContactIcon(hContact) != lParam); // XXX CLVM changed - this means an offline msg is flashing, so the contact should be shown if (!FindItem(hwnd, dat, (HANDLE)hContact, &contact, &group, NULL)) { if (shouldShow && CallService(MS_DB_CONTACT_IS, wParam, 0)) { if (dat->selection >= 0 && pcli->pfnGetRowByIndex(dat, dat->selection, &selcontact, NULL) != -1) hSelItem = (MCONTACT)pcli->pfnContactToHItem(selcontact); pcli->pfnAddContactToTree(hwnd, dat, hContact, 0, 0); recalcScrollBar = 1; FindItem(hwnd, dat, (HANDLE)hContact, &contact, NULL, NULL); if (contact) { contact->iImage = (WORD)lParam; pcli->pfnNotifyNewContact(hwnd, hContact); } } } else { //item in list already DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE); if (contact->iImage == (WORD)lParam) break; if (!shouldShow && !(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->hideOffline || cfg::dat.bFilterEffective)) { // CLVM changed if (dat->selection >= 0 && pcli->pfnGetRowByIndex(dat, dat->selection, &selcontact, NULL) != -1) hSelItem = (MCONTACT)pcli->pfnContactToHItem(selcontact); pcli->pfnRemoveItemFromGroup(hwnd, group, contact, 0); contactRemoved = TRUE; recalcScrollBar = 1; } else { contact->iImage = (WORD)lParam; if (!pcli->pfnIsHiddenMode(dat, status)) contact->flags |= CONTACTF_ONLINE; else contact->flags &= ~CONTACTF_ONLINE; } } if (hSelItem) { ClcGroup *selgroup; if (pcli->pfnFindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL)) dat->selection = pcli->pfnGetRowsPriorTo(&dat->list, selgroup, List_IndexOf((SortedList*)& selgroup->cl, selcontact)); else dat->selection = -1; } dat->needsResort = TRUE; PostMessage(hwnd, INTM_SORTCLC, 0, recalcScrollBar); PostMessage(hwnd, INTM_INVALIDATE, 0, (LPARAM)(contactRemoved ? 0 : wParam)); if (recalcScrollBar) pcli->pfnRecalcScrollBar(hwnd, dat); } goto LBL_Def; case INTM_METACHANGED: if (!pcli->pfnFindItem(hwnd, dat, wParam, &contact, NULL, NULL)) break; if (contact->bIsMeta && !(cfg::dat.dwFlags & CLUI_USEMETAICONS)) { contact->hSubContact = db_mc_getMostOnline(contact->hContact); contact->metaProto = GetContactProto(contact->hSubContact); contact->iImage = pcli->pfnGetContactIcon(contact->hSubContact); if (contact->pExtra) { TExtraCache *pSub = cfg::getCache(contact->hSubContact, contact->metaProto); ClcContact *subContact; if (!pcli->pfnFindItem(hwnd, dat, contact->hSubContact, &subContact, NULL, NULL)) break; contact->pExtra->proto_status_item = GetProtocolStatusItem(contact->metaProto); if (pSub) { contact->pExtra->status_item = pSub->status_item; memcpy(contact->iExtraImage, subContact->iExtraImage, sizeof(contact->iExtraImage)); } } } SendMessage(hwnd, INTM_NAMEORDERCHANGED, wParam, lParam); goto LBL_Def; case INTM_METACHANGEDEVENT: if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) break; if (lParam == 0) pcli->pfnInitAutoRebuild(hwnd); goto LBL_Def; case INTM_NAMECHANGED: ClcContact *contact; if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) break; mir_tstrncpy(contact->szText, pcli->pfnGetContactDisplayName(wParam, 0), SIZEOF(contact->szText)); RTL_DetectAndSet(contact, 0); dat->needsResort = TRUE; PostMessage(hwnd, INTM_SORTCLC, 0, 0); goto LBL_Def; case INTM_CODEPAGECHANGED: if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) break; contact->codePage = cfg::getDword(wParam, "Tab_SRMsg", "ANSIcodepage", cfg::getDword(wParam, "UserInfo", "ANSIcodepage", CP_ACP)); PostMessage(hwnd, INTM_INVALIDATE, 0, 0); goto LBL_Def; case INTM_AVATARCHANGED: contact = NULL; { avatarCacheEntry *cEntry = (struct avatarCacheEntry *)lParam; if (wParam == 0) { //RemoveFromImgCache(0, cEntry); cfg::dat.bForceRefetchOnPaint = TRUE; RedrawWindow(hwnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW); cfg::dat.bForceRefetchOnPaint = FALSE; goto LBL_Def; } if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) return 0; contact->ace = cEntry; if (cEntry == NULL) contact->cFlags &= ~ECF_AVATAR; else { DWORD dwFlags; if (contact->pExtra) dwFlags = contact->pExtra->dwDFlags; else dwFlags = cfg::getDword(contact->hContact, "CList", "CLN_Flags", 0); if (cfg::dat.dwFlags & CLUI_FRAME_AVATARS) contact->cFlags = (dwFlags & ECF_HIDEAVATAR ? contact->cFlags & ~ECF_AVATAR : contact->cFlags | ECF_AVATAR); else contact->cFlags = (dwFlags & ECF_FORCEAVATAR ? contact->cFlags | ECF_AVATAR : contact->cFlags & ~ECF_AVATAR); } PostMessage(hwnd, INTM_INVALIDATE, 0, (LPARAM)contact->hContact); } goto LBL_Def; case INTM_STATUSMSGCHANGED: { TExtraCache *p; char *szProto = NULL; if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) p = cfg::getCache(wParam, NULL); else { p = contact->pExtra; szProto = contact->proto; } GetCachedStatusMsg(p, szProto); PostMessage(hwnd, INTM_INVALIDATE, 0, (LPARAM)(contact ? contact->hContact : 0)); } goto LBL_Def; case INTM_STATUSCHANGED: if (FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) { WORD wStatus = cfg::getWord(wParam, contact->proto, "Status", ID_STATUS_OFFLINE); if (cfg::dat.bNoOfflineAvatars && wStatus != ID_STATUS_OFFLINE && contact->wStatus == ID_STATUS_OFFLINE) { contact->wStatus = wStatus; if (cfg::dat.bAvatarServiceAvail && contact->ace == NULL) LoadAvatarForContact(contact); } contact->wStatus = wStatus; goto LBL_Def; } break; case INTM_PROTOCHANGED: if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) break; contact->proto = GetContactProto(wParam); CallService(MS_CLIST_INVALIDATEDISPLAYNAME, wParam, 0); mir_tstrncpy(contact->szText, pcli->pfnGetContactDisplayName(wParam, 0), SIZEOF(contact->szText)); RTL_DetectAndSet(contact, 0); dat->needsResort = TRUE; PostMessage(hwnd, INTM_SORTCLC, 0, 0); goto LBL_Def; case INTM_INVALIDATE: if (!dat->bNeedPaint) { KillTimer(hwnd, TIMERID_PAINT); SetTimer(hwnd, TIMERID_PAINT, 100, NULL); dat->bNeedPaint = TRUE; } goto LBL_Def; case INTM_INVALIDATECONTACT: if (!FindItem(hwnd, dat, (HANDLE)wParam, &contact, &group, NULL)) break; if (contact && group) { int iItem = pcli->pfnGetRowsPriorTo(&dat->list, group, List_IndexOf((SortedList*) & group->cl, contact)); pcli->pfnInvalidateItem(hwnd, dat, iItem); goto LBL_Def; } break; case INTM_FORCESORT: dat->needsResort = TRUE; return SendMessage(hwnd, INTM_SORTCLC, wParam, lParam); case INTM_SORTCLC: if (dat->needsResort) { pcli->pfnSortCLC(hwnd, dat, TRUE); dat->needsResort = FALSE; } if (lParam) pcli->pfnRecalcScrollBar(hwnd, dat); goto LBL_Def; case INTM_IDLECHANGED: if (FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) { DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam; char *szProto = (char*)cws->szModule; if (szProto == NULL) break; contact->flags &= ~CONTACTF_IDLE; if (cfg::getDword(wParam, szProto, "IdleTS", 0)) { contact->flags |= CONTACTF_IDLE; } PostMessage(hwnd, INTM_INVALIDATE, 0, (LPARAM)contact->hContact); goto LBL_Def; } break; case INTM_XSTATUSCHANGED: { DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam; char *szProto = (char *)cws->szModule; MCONTACT hContact = wParam; TExtraCache *p; if (!FindItem(hwnd, dat, (HANDLE)hContact, &contact, NULL, NULL)) { p = cfg::getCache(hContact, szProto); if (!dat->bisEmbedded && szProto) { // may be a subcontact, forward the xstatus MCONTACT hMasterContact = db_mc_tryMeta(hContact); if (hMasterContact != hContact) // avoid recursive call of settings handler cfg::writeByte(hMasterContact, META_PROTO, "XStatusId", (BYTE)cfg::getByte(hContact, szProto, "XStatusId", 0)); break; } } else { contact->xStatus = cfg::getByte(hContact, szProto, "XStatusId", 0); p = contact->pExtra; } if (szProto == NULL) break; if (contact) { if (ProtoServiceExists(szProto, PS_GETADVANCEDSTATUSICON)) { int iconId = ProtoCallService(szProto, PS_GETADVANCEDSTATUSICON, hContact, 0); if (iconId != -1) contact->xStatusIcon = iconId >> 16; } } GetCachedStatusMsg(p, szProto); PostMessage(hwnd, INTM_INVALIDATE, 0, (LPARAM)(contact ? contact->hContact : 0)); } goto LBL_Def; case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd, &ps); if (IsWindowVisible(hwnd) && !during_sizing && !cfg::shutDown) { PaintClc(hwnd, dat, hdc, &ps.rcPaint); dat->bNeedPaint = FALSE; dat->lastRepaint = GetTickCount(); } EndPaint(hwnd, &ps); if (dat->selection != dat->oldSelection && !dat->bisEmbedded && g_ButtonItems != NULL) { SetDBButtonStates(0); dat->oldSelection = dat->selection; } } goto LBL_Def; case WM_MOUSEWHEEL: dat->forceScroll = TRUE; break; case WM_TIMER: if (wParam == TIMERID_PAINT) { KillTimer(hwnd, TIMERID_PAINT); InvalidateRect(hwnd, NULL, FALSE); goto LBL_Def; } if (wParam == TIMERID_REFRESH) { InvalidateRect(hwnd, NULL, FALSE); goto LBL_Def; } break; case WM_LBUTTONDBLCLK: ReleaseCapture(); dat->iHotTrack = -1; pcli->pfnHideInfoTip(hwnd, dat); KillTimer(hwnd, TIMERID_RENAME); KillTimer(hwnd, TIMERID_INFOTIP); dat->szQuickSearch[0] = 0; { DWORD hitFlags; dat->selection = HitTest(hwnd, dat, (short) LOWORD(lParam), (short) HIWORD(lParam), &contact, NULL, &hitFlags); if (hitFlags & CLCHT_ONITEMEXTRA) break; InvalidateRect(hwnd, NULL, FALSE); if (dat->selection != -1) pcli->pfnEnsureVisible(hwnd, dat, dat->selection, 0); if (hitFlags & CLCHT_ONAVATAR && cfg::dat.bDblClkAvatars) { CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)contact->hContact, 0); return TRUE; } if (hitFlags & (CLCHT_ONITEMICON | CLCHT_ONITEMLABEL | CLCHT_ONITEMSPACE)) { UpdateWindow(hwnd); pcli->pfnDoSelectionDefaultAction(hwnd, dat); } } return TRUE; case WM_CONTEXTMENU: { HMENU hMenu = NULL; POINT pt; DWORD hitFlags; pcli->pfnEndRename(hwnd, dat, 1); pcli->pfnHideInfoTip(hwnd, dat); KillTimer(hwnd, TIMERID_RENAME); KillTimer(hwnd, TIMERID_INFOTIP); if (GetFocus() != hwnd) SetFocus(hwnd); dat->iHotTrack = -1; dat->szQuickSearch[0] = 0; pt.x = (short) LOWORD(lParam); pt.y = (short) HIWORD(lParam); if (pt.x == -1 && pt.y == -1) { dat->selection = pcli->pfnGetRowByIndex(dat, dat->selection, &contact, NULL); if (dat->selection != -1) pcli->pfnEnsureVisible(hwnd, dat, dat->selection, 0); pt.x = dat->iconXSpace + 15; pt.y = RowHeight::getItemTopY(dat, dat->selection) - dat->yScroll + (int)(dat->row_heights[dat->selection] * .7); hitFlags = dat->selection == -1 ? CLCHT_NOWHERE : CLCHT_ONITEMLABEL; } else { ScreenToClient(hwnd, &pt); dat->selection = HitTest(hwnd, dat, pt.x, pt.y, &contact, NULL, &hitFlags); } InvalidateRect(hwnd, NULL, FALSE); if (dat->selection != -1) pcli->pfnEnsureVisible(hwnd, dat, dat->selection, 0); UpdateWindow(hwnd); if (dat->selection != -1 && hitFlags & (CLCHT_ONITEMICON | CLCHT_ONITEMCHECK | CLCHT_ONITEMLABEL)) { if (contact->type == CLCIT_GROUP) { hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDSUBGROUP, (WPARAM)contact->group, 0); ClientToScreen(hwnd, &pt); TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, pcli->hwndContactList, NULL); CheckMenuItem(hMenu, POPUP_GROUPHIDEOFFLINE, contact->group->hideOffline ? MF_CHECKED : MF_UNCHECKED); DestroyMenu(hMenu); return 0; } else if (contact->type == CLCIT_CONTACT) hMenu = (HMENU) CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM) contact->hContact, 0); } else { //call parent for new group/hide offline menu PostMessage(GetParent(hwnd), WM_CONTEXTMENU, wParam, lParam); return 0; } if (hMenu != NULL) { ClientToScreen(hwnd, &pt); TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwnd, NULL); DestroyMenu(hMenu); } } return 0; case WM_COMMAND: if (LOWORD(wParam) == POPUP_NEWGROUP) SendMessage(GetParent(hwnd), msg, wParam, lParam); break; case WM_NCHITTEST: { LRESULT lr = SendMessage(GetParent(hwnd), WM_NCHITTEST, wParam, lParam); if (lr == HTLEFT || lr == HTRIGHT || lr == HTBOTTOM || lr == HTTOP || lr == HTTOPLEFT || lr == HTTOPRIGHT || lr == HTBOTTOMLEFT || lr == HTBOTTOMRIGHT) return HTTRANSPARENT; } break; case WM_DESTROY: RowHeight::Free(dat); break; } return coreCli.pfnContactListControlWndProc(hwnd, msg, wParam, lParam); }
INT_PTR CALLBACK TrackingUIProc(HWND hwndTrk, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: { g_hWndTrack = hwndTrk; LVCOLUMN column; column.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH; column.cx = 50; column.iSubItem = 0; column.pszText = L"ID"; ListView_InsertColumn(GetControl(IDC_MODELS), 0, &column); column.cx = 400; column.iSubItem = 1; column.pszText = L"File"; ListView_InsertColumn(GetControl(IDC_MODELS), 1, &column); HIMAGELIST imgList = ImageList_Create(16, 16, 0, 2, 0); HBITMAP trackingBmp = LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_TRACKING_OK)); HBITMAP notTrackingBmp = LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_NOT_TRACKING)); ImageList_Add(imgList, notTrackingBmp, NULL); ImageList_Add(imgList, trackingBmp, NULL); TreeView_SetImageList(GetControl(IDC_MODELS), imgList, TVSIL_NORMAL); DeleteObject(trackingBmp); DeleteObject(notTrackingBmp); // Initialize combo tracking box ComboBox_AddString(GetControl(IDC_TRACKINGTYPE), L"3D Tracking"); ComboBox_SetItemData(GetControl(IDC_TRACKINGTYPE), 0, TRACKING_3D); ComboBox_AddString(GetControl(IDC_TRACKINGTYPE), L"2D Tracking"); ComboBox_SetItemData(GetControl(IDC_TRACKINGTYPE), 1, TRACKING_2D); ComboBox_AddString(GetControl(IDC_TRACKINGTYPE), L"3D Instant"); ComboBox_SetItemData(GetControl(IDC_TRACKINGTYPE), 2, TRACKING_INSTANT); ComboBox_SetCurSel(GetControl(IDC_TRACKINGTYPE), 0); return TRUE; } case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_LOADMODEL: AddTargetFile(); return TRUE; case IDC_CLEARMODELS: ClearModelTree(); return TRUE; } if (HIWORD(wParam) == CBN_SELCHANGE) { HWND comboBox = (HWND) lParam; int selIndex = ComboBox_GetCurSel(comboBox); TrackingType type = (TrackingType) ComboBox_GetItemData(comboBox, selIndex); switch (type) { case TRACKING_2D: Button_Enable(GetControl(IDC_START), false); Button_Enable(GetControl(IDC_LOADMODEL), true); Button_Enable(GetControl(IDC_CLEARMODELS), false); Button_Enable(GetControl(IDC_ROI), false); Button_SetCheck(GetControl(IDC_ROI), false); ClearModelTree(); return TRUE; case TRACKING_3D: Button_Enable(GetControl(IDC_START), false); Button_Enable(GetControl(IDC_LOADMODEL), true); Button_Enable(GetControl(IDC_CLEARMODELS), false); Button_Enable(GetControl(IDC_ROI), false); Button_SetCheck(GetControl(IDC_ROI), false); ClearModelTree(); return TRUE; case TRACKING_INSTANT: ClearModelTree(); Button_Enable(GetControl(IDC_START),true); Button_Enable(GetControl(IDC_LOADMODEL),false); Button_Enable(GetControl(IDC_CLEARMODELS), false); Button_Enable(GetControl(IDC_ROI), true); Button_SetCheck(GetControl(IDC_ROI), false); if (!showedMessage) { showedMessage = true; MessageBoxExW(GetParent(hwndTrk), L"Please be aware that instant tracking needs special scene/background setup. Refer to the reference manual for details.", L"Note", MB_OK | MB_ICONINFORMATION, 0); } return TRUE; } } break; case WM_NOTIFY: switch ( ((LPNMHDR) lParam)->code) { case TVN_GETDISPINFO: { NMTVDISPINFO *dispInfo = (NMTVDISPINFO*) lParam; if (dispInfo->item.mask & LVIF_IMAGE) { int targetIndex = dispInfo->item.lParam & 0xFF; int cosIDIndex = (dispInfo->item.lParam & 0xFF00) >> 8; if (g_targets[targetIndex].cosIDs[cosIDIndex].isTracking) { dispInfo->item.iImage = 1; } else { dispInfo->item.iImage = 0; } } return TRUE; } } break; }
LRESULT CALLBACK WndPauseProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; RECT rect; TEXTMETRIC tm; LPPW lppw; int cxChar, cyChar, middle; lppw = (LPPW)GetWindowLongPtr(hwnd, 0); switch(message) { case WM_KEYDOWN: if (wParam == VK_RETURN) SendMessage(hwnd, WM_COMMAND, lppw->bDefOK ? IDOK : IDCANCEL, 0L); else if (wParam == VK_ESCAPE) SendMessage(hwnd, WM_COMMAND, IDCANCEL, 0L); return 0; case WM_COMMAND: if ((LOWORD(wParam) == IDCANCEL) || (LOWORD(wParam) == IDOK)) { lppw->bPauseCancel = LOWORD(wParam); lppw->bPause = FALSE; break; } return 0; case WM_SETFOCUS: SetFocus(lppw->bDefOK ? lppw->hOK : lppw->hCancel); return 0; case WM_PAINT: { hdc = BeginPaint(hwnd, &ps); SelectObject(hdc, GetStockObject(SYSTEM_FONT)); SetTextAlign(hdc, TA_CENTER); GetClientRect(hwnd, &rect); SetBkMode(hdc,TRANSPARENT); TextOut(hdc, (rect.right + rect.left) / 2, (rect.bottom + rect.top) / 6, lppw->Message, strlen(lppw->Message)); EndPaint(hwnd, &ps); return 0; } case WM_CREATE: { int ws_opts = WS_CHILD | WS_TABSTOP; #ifdef USE_MOUSE if (!paused_for_mouse) /* don't show buttons during pausing for mouse or key */ ws_opts |= WS_VISIBLE; #endif lppw = (LPPW) ((CREATESTRUCT *)lParam)->lpCreateParams; SetWindowLongPtr(hwnd, 0, (LONG_PTR)lppw); lppw->hWndPause = hwnd; hdc = GetDC(hwnd); SelectObject(hdc, GetStockObject(SYSTEM_FONT)); GetTextMetrics(hdc, &tm); cxChar = tm.tmAveCharWidth; cyChar = tm.tmHeight + tm.tmExternalLeading; ReleaseDC(hwnd, hdc); middle = ((LPCREATESTRUCT) lParam)->cx / 2; lppw->hOK = CreateWindow((LPSTR)"button", (LPSTR)"OK", ws_opts | BS_DEFPUSHBUTTON, middle - 10 * cxChar, 3 * cyChar, 8 * cxChar, 7 * cyChar / 4, hwnd, (HMENU)IDOK, ((LPCREATESTRUCT) lParam)->hInstance, NULL); lppw->bDefOK = TRUE; lppw->hCancel = CreateWindow((LPSTR)"button", (LPSTR)"Cancel", ws_opts | BS_PUSHBUTTON, middle + 2 * cxChar, 3 * cyChar, 8 * cxChar, 7 * cyChar / 4, hwnd, (HMENU)IDCANCEL, ((LPCREATESTRUCT) lParam)->hInstance, NULL); lppw->lpfnOK = (WNDPROC) GetWindowLongPtr(lppw->hOK, GWLP_WNDPROC); SetWindowLongPtr(lppw->hOK, GWLP_WNDPROC, (LONG_PTR)PauseButtonProc); lppw->lpfnCancel = (WNDPROC) GetWindowLongPtr(lppw->hCancel, GWLP_WNDPROC); SetWindowLongPtr(lppw->hCancel, GWLP_WNDPROC, (LONG_PTR)PauseButtonProc); if (GetParent(hwnd)) EnableWindow(GetParent(hwnd), FALSE); return 0; } case WM_DESTROY: GetWindowRect(hwnd, &rect); lppw->Origin.x = (rect.right + rect.left) / 2; lppw->Origin.y = (rect.bottom + rect.top) / 2; lppw->bPause = FALSE; if (GetParent(hwnd)) EnableWindow(GetParent(hwnd), TRUE); break; } return DefWindowProc(hwnd, message, wParam, lParam); }
/* update checked-ness for type="checkbox" and type="radio" */ void nsMenuFrame::UpdateMenuSpecialState(nsPresContext* aPresContext) { PRBool newChecked = mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::checked, nsGkAtoms::_true, eCaseMatters); if (newChecked == mChecked) { /* checked state didn't change */ if (mType != eMenuType_Radio) return; // only Radio possibly cares about other kinds of change if (!mChecked || mGroupName.IsEmpty()) return; // no interesting change } else { mChecked = newChecked; if (mType != eMenuType_Radio || !mChecked) /* * Unchecking something requires no further changes, and only * menuRadio has to do additional work when checked. */ return; } /* * If we get this far, we're type=radio, and: * - our name= changed, or * - we went from checked="false" to checked="true" */ /* * Behavioural note: * If we're checked and renamed _into_ an existing radio group, we are * made the new checked item, and we unselect the previous one. * * The only other reasonable behaviour would be to check for another selected * item in that group. If found, unselect ourselves, otherwise we're the * selected item. That, however, would be a lot more work, and I don't think * it's better at all. */ /* walk siblings, looking for the other checked item with the same name */ // get the first sibling in this menu popup. This frame may be it, and if we're // being called at creation time, this frame isn't yet in the parent's child list. // All I'm saying is that this may fail, but it's most likely alright. nsIFrame* sib = GetParent()->GetFirstChild(nsnull); while (sib) { if (sib != this && sib->GetType() == nsGkAtoms::menuFrame) { nsMenuFrame* menu = static_cast<nsMenuFrame*>(sib); if (menu->GetMenuType() == eMenuType_Radio && menu->IsChecked() && (menu->GetRadioGroupName() == mGroupName)) { /* uncheck the old item */ sib->GetContent()->UnsetAttr(kNameSpaceID_None, nsGkAtoms::checked, PR_TRUE); /* XXX in DEBUG, check to make sure that there aren't two checked items */ return; } } sib = sib->GetNextSibling(); } }
BOOL CALLBACK CShellExt::PageDlgProc_mp3_LAME(HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); LPCSHELLEXT lpcs = (CShellExt *)GetWindowLongPtr(hDlg,DWLP_USER); CString strTmp; switch(uMessage){ case WM_USER+1: //表示のリフレッシュ DispInfo(hDlg,lpcs); break; case WM_INITDIALOG: { lpcs = (LPCSHELLEXT )((LPPROPSHEETPAGE )lParam)->lParam; SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)lpcs); //Ver情報 SetDlgItemText(hDlg,IDC_STATIC_VER_INFO,SOFT_NAME); //情報を表示 DispInfo(hDlg,lpcs); } break; case WM_COMMAND: switch(LOWORD(wParam)){ case IDC_CHECK_AOT: if(IsDlgButtonChecked(hDlg,IDC_CHECK_AOT) == BST_CHECKED) { lpcs->m_bPropAOT = TRUE; SetWindowPos(GetParent(hDlg),HWND_TOPMOST,0,0,0,0, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOSIZE); } else { lpcs->m_bPropAOT = FALSE; SetWindowPos(GetParent(hDlg),HWND_NOTOPMOST,0,0,0,0, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOSIZE); } if(lpcs->m_hwndId3v1) PostMessage(lpcs->m_hwndId3v1,WM_USER+1,0,0); if(lpcs->m_hwndId3v2) PostMessage(lpcs->m_hwndId3v2,WM_USER+1,0,0); regSetDword(HKEY_CURRENT_USER,MP3INFP_REG_ENTRY,_T("PropAOT"),(DWORD )lpcs->m_bPropAOT); break; case IDC_SETUP: ShellExecute(hDlg,_T("open"),_T("rundll32.exe"),_T("shell32.dll,Control_RunDLL mp3infp.cpl,,2"),NULL,SW_SHOW); break; case IDC_HELPVIEW: lpcs->OpenHtmlHelp(hDlg,_T("extension.htm")); break; } break; //状況依存ヘルプ case WM_HELP: { TCHAR szTmp[256]; lstrcpy(szTmp,SOFT_NAME); lstrcat(szTmp,_T(" ")); lstrcat(szTmp,COPY_RIGHT); MessageBox(hDlg,szTmp,_T("About"),MB_APPLMODAL); break; } default: return FALSE; } return TRUE; }
void CTreePropSheetSplitter::UpdateParentRect(LPCRECT lpRectUpdate) { GetParent()->RedrawWindow( lpRectUpdate, NULL, RDW_UPDATENOW | RDW_INVALIDATE ); }
void CLibraryFolderCtrl::NotifySelectionChanged() { GetParent()->PostMessage( WM_TIMER, 2 ); }
static INT_PTR CALLBACK CharMapDlgProc(HWND hDlg, UINT Message, WPARAM wParam, LPARAM lParam) { switch(Message) { case WM_INITDIALOG: { DWORD evMask; #ifdef REMOVE_ADVANCED HWND hAdv; #endif FillFontStyleComboList(GetDlgItem(hDlg, IDC_FONTCOMBO)); ChangeMapFont(hDlg); // Configure Richedit control for sending notification changes. evMask = SendDlgItemMessage(hDlg, IDC_TEXTBOX, EM_GETEVENTMASK, 0, 0); evMask |= ENM_CHANGE; SendDlgItemMessage(hDlg, IDC_TEXTBOX, EM_SETEVENTMASK, 0, (LPARAM)evMask); #ifdef REMOVE_ADVANCED hAdv = GetDlgItem(hDlg, IDC_CHECK_ADVANCED); ShowWindow(hAdv, SW_HIDE); #endif return TRUE; } case WM_COMMAND: { switch(LOWORD(wParam)) { case IDC_FONTMAP: switch (HIWORD(wParam)) { case FM_SETCHAR: AddCharToSelection(hDlg, LOWORD(lParam)); break; } break; case IDC_FONTCOMBO: if (HIWORD(wParam) == CBN_SELCHANGE) { ChangeMapFont(hDlg); } break; case IDC_SELECT: AddCharToSelection(hDlg, 0); break; case IDC_TEXTBOX: switch (HIWORD(wParam)) { case EN_CHANGE: if (GetWindowTextLength(GetDlgItem(hDlg, IDC_TEXTBOX)) == 0) EnableWindow(GetDlgItem(hDlg, IDC_COPY), FALSE); else EnableWindow(GetDlgItem(hDlg, IDC_COPY), TRUE); break; } break; case IDC_COPY: CopyCharacters(hDlg); break; #ifndef REMOVE_ADVANCED case IDC_CHECK_ADVANCED: UpdateSettings(hDlg); ChangeView(GetParent(hDlg)); break; #endif } } break; default: break; } return FALSE; }
void CDlgHiddenColumns::CreateCheckboxes() { int i, stdCount, actualCount; bool val; CAdvancedFrame* pFrame = (CAdvancedFrame*)GetParent(); wxASSERT(wxDynamicCast(pFrame, CAdvancedFrame)); wxNotebook* pNotebook = pFrame->GetNotebook(); wxASSERT(pNotebook); actualCount = m_checkbox_list.size(); for (i=0; i<actualCount; ++i) { std::vector <wxCheckBox*> *checkbox_list = m_checkbox_list[i]; checkbox_list->clear(); delete checkbox_list; } m_checkbox_list.clear(); wxWindow* pwndNotebookPage = NULL; CBOINCBaseView* pView = NULL; long iIndex; long iPageCount; iPageCount = (long)pNotebook->GetPageCount(); for (iIndex = 0; iIndex < iPageCount; iIndex++) { pwndNotebookPage = pNotebook->GetPage(iIndex); wxASSERT(wxDynamicCast(pwndNotebookPage, CBOINCBaseView)); pView = wxDynamicCast(pwndNotebookPage, CBOINCBaseView); wxASSERT(pView); CBOINCListCtrl* listPane = pView->GetListCtrl(); if (!listPane) continue; m_pBOINCBaseView.push_back(pView); std::vector <wxCheckBox*> *checkbox_list = new std::vector <wxCheckBox*>; wxStaticBox* tabStaticBox = new wxStaticBox(m_scrolledWindow, -1, pView->GetViewDisplayName()); wxStaticBoxSizer* tabStaticBoxSizer = new wxStaticBoxSizer( tabStaticBox, wxVERTICAL ); wxGridSizer* checkboxSizer = new wxGridSizer(2, wxSize(0,3)); stdCount = pView->m_aStdColNameOrder->GetCount(); for (i=0; i<stdCount; ++i) { wxString columnLabel = pView->m_aStdColNameOrder->Item(i); wxCheckBox* ckbox = new wxCheckBox(tabStaticBox, wxID_ANY, columnLabel); checkboxSizer->Add(ckbox, 0, wxLEFT, 25); val = false; if (pView->m_iColumnIDToColumnIndex[i] >= 0) val = true; ckbox->SetValue(val); checkbox_list->push_back(ckbox); } m_checkbox_list.push_back(checkbox_list); tabStaticBoxSizer->Add(checkboxSizer, 0, wxEXPAND, 1 ); m_scrolledSizer->Add(tabStaticBoxSizer, 0, wxEXPAND, 1 ); } m_scrolledWindow->SetSizer( m_scrolledSizer ); m_scrolledWindow->Layout(); m_scrolledSizer->Fit( m_scrolledWindow ); }
BOOL WINAPI SoundProc(HWND hwndDlg, WORD wMessage, WPARAM wParam, LPARAM lParam) { static HWND hSoundWaveDuring, hSoundWaveAfter, hFileText, hSoundEdit, hPlay, hBrowse; static UINT uMaxSoundRadioButton; /* upper boundary of uSoundButtonSelected */ switch (wMessage) { case WM_INITDIALOG: if (CanPlayWave()) { hSoundWaveDuring = GetDlgItem(hwndDlg, IDM_SOUND_WAVE_DURING); hSoundWaveAfter = GetDlgItem(hwndDlg, IDM_SOUND_WAVE_AFTER); hFileText = GetDlgItem(hwndDlg, IDM_SOUND_FILE_TEXT); hSoundEdit = GetDlgItem(hwndDlg, IDM_SOUND_EDIT); hPlay = GetDlgItem(hwndDlg, IDM_SOUND_PLAY); hBrowse = GetDlgItem(hwndDlg, IDM_SOUND_BROWSE); EnableWindow(hSoundWaveDuring, TRUE); EnableWindow(hSoundWaveAfter, TRUE); WinAssert(hFileText); EnableWindow(hFileText, TRUE); EnableWindow(hSoundEdit, TRUE); EnableWindow(hPlay, TRUE); EnableWindow(hBrowse, TRUE); SetDlgItemText(hwndDlg, IDM_SOUND_EDIT, lpumb->szSoundName); uMaxSoundRadioButton = IDM_SOUND_WAVE_AFTER; } else /* Can't play wave */ { uMaxSoundRadioButton = IDM_SOUND_BEEP; } uSoundButtonSelectedTmp = uSoundButtonSelected; /* initialize temp value */ CheckRadioButton(hwndDlg, IDM_SOUND_NONE, uMaxSoundRadioButton, uSoundButtonSelectedTmp); //#ifdef NEEDME CenterDialog(GetParent(hwndDlg), hwndDlg); //#endif return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDM_SOUND_NONE: case IDM_SOUND_BEEP: case IDM_SOUND_WAVE_DURING: case IDM_SOUND_WAVE_AFTER: uSoundButtonSelectedTmp = LOWORD(wParam); CheckRadioButton(hwndDlg, IDM_SOUND_NONE, uMaxSoundRadioButton, uSoundButtonSelectedTmp); break; case IDM_SOUND_PLAY: GetDlgItemText(hwndDlg, IDM_SOUND_EDIT, lpumb->szSoundName, WIZUNZIP_MAX_PATH); #ifdef __BORLANDC__ #pragma warn -pro #endif #ifdef WIN32 (*lpSndPlaySound)((LPSTR)lpumb->szSoundName, NULL, SND_ASYNC|SND_NOSTOP); #else (*lpSndPlaySound)((LPSTR)lpumb->szSoundName, SND_ASYNC|SND_NOSTOP); #endif #ifdef __BORLANDC__ #pragma warn .pro #endif break; case IDM_SOUND_BROWSE: if (DoOpenFile(hwndDlg, lpumb->szSoundName)) { /* transfer to command window */ SetDlgItemText(hwndDlg, IDM_SOUND_EDIT, lpumb->szSoundName); } break; case IDOK: uSoundButtonSelected = uSoundButtonSelectedTmp; WritePrivateProfileString(szAppName, szSoundOptKey, SoundOptsTbl[uSoundButtonSelected-IDM_SOUND_NONE], szWizUnzipIniFile); GetDlgItemText(hwndDlg, IDM_SOUND_EDIT, lpumb->szSoundName, WIZUNZIP_MAX_PATH); WritePrivateProfileString(szAppName, szSoundNameKey, lpumb->szSoundName, szWizUnzipIniFile); EndDialog(hwndDlg, TRUE); break; case IDCANCEL: /* restore former value of sound file name */ GetPrivateProfileString(szAppName, szSoundNameKey, szDfltWaveFile, lpumb->szSoundName, WIZUNZIP_MAX_PATH, szWizUnzipIniFile); EndDialog(hwndDlg, FALSE); break; case IDM_SOUND_HELP: WinHelp(hwndDlg,szHelpFileName,HELP_CONTEXT, (DWORD)(HELPID_SOUND_OPTIONS)); break; } return TRUE; } return FALSE; }
// NOTE: aDesiredStretchSize is an IN/OUT parameter // On input - it contains our current size // On output - the same size or the new size that we want NS_IMETHODIMP nsMathMLmoFrame::Stretch(nsRenderingContext& aRenderingContext, nsStretchDirection aStretchDirection, nsBoundingMetrics& aContainerSize, nsHTMLReflowMetrics& aDesiredStretchSize) { if (NS_MATHML_STRETCH_WAS_DONE(mPresentationData.flags)) { NS_WARNING("it is wrong to fire stretch more than once on a frame"); return NS_OK; } mPresentationData.flags |= NS_MATHML_STRETCH_DONE; nsIFrame* firstChild = mFrames.FirstChild(); // get the axis height; float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this); nsRefPtr<nsFontMetrics> fm; nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), fontSizeInflation); nscoord axisHeight, height; GetAxisHeight(aRenderingContext, fm, axisHeight); // get the leading to be left at the top and the bottom of the stretched char // this seems more reliable than using fm->GetLeading() on suspicious fonts nscoord em; GetEmHeight(fm, em); nscoord leading = NSToCoordRound(0.2f * em); // Operators that are stretchy, or those that are to be centered // to cater for fonts that are not math-aware, are handled by the MathMLChar // ('form' is reset if stretch fails -- i.e., we don't bother to stretch next time) bool useMathMLChar = UseMathMLChar(); nsBoundingMetrics charSize; nsBoundingMetrics container = aDesiredStretchSize.mBoundingMetrics; bool isVertical = false; if (((aStretchDirection == NS_STRETCH_DIRECTION_VERTICAL) || (aStretchDirection == NS_STRETCH_DIRECTION_DEFAULT)) && (mEmbellishData.direction == NS_STRETCH_DIRECTION_VERTICAL)) { isVertical = true; } uint32_t stretchHint = GetStretchHint(mFlags, mPresentationData, isVertical, StyleFont()); if (useMathMLChar) { nsBoundingMetrics initialSize = aDesiredStretchSize.mBoundingMetrics; if (stretchHint != NS_STRETCH_NONE) { container = aContainerSize; // some adjustments if the operator is symmetric and vertical if (isVertical && NS_MATHML_OPERATOR_IS_SYMMETRIC(mFlags)) { // we need to center about the axis nscoord delta = std::max(container.ascent - axisHeight, container.descent + axisHeight); container.ascent = delta + axisHeight; container.descent = delta - axisHeight; // get ready in case we encounter user-desired min-max size delta = std::max(initialSize.ascent - axisHeight, initialSize.descent + axisHeight); initialSize.ascent = delta + axisHeight; initialSize.descent = delta - axisHeight; } // check for user-desired min-max size if (mMaxSize != NS_MATHML_OPERATOR_SIZE_INFINITY && mMaxSize > 0.0f) { // if we are here, there is a user defined maxsize ... //XXX Set stretchHint = NS_STRETCH_NORMAL? to honor the maxsize as close as possible? if (NS_MATHML_OPERATOR_MAXSIZE_IS_ABSOLUTE(mFlags)) { // there is an explicit value like maxsize="20pt" // try to maintain the aspect ratio of the char float aspect = mMaxSize / float(initialSize.ascent + initialSize.descent); container.ascent = std::min(container.ascent, nscoord(initialSize.ascent * aspect)); container.descent = std::min(container.descent, nscoord(initialSize.descent * aspect)); // below we use a type cast instead of a conversion to avoid a VC++ bug // see http://support.microsoft.com/support/kb/articles/Q115/7/05.ASP container.width = std::min(container.width, (nscoord)mMaxSize); } else { // multiplicative value container.ascent = std::min(container.ascent, nscoord(initialSize.ascent * mMaxSize)); container.descent = std::min(container.descent, nscoord(initialSize.descent * mMaxSize)); container.width = std::min(container.width, nscoord(initialSize.width * mMaxSize)); } if (isVertical && !NS_MATHML_OPERATOR_IS_SYMMETRIC(mFlags)) { // re-adjust to align the char with the bottom of the initial container height = container.ascent + container.descent; container.descent = aContainerSize.descent; container.ascent = height - container.descent; } } if (mMinSize > 0.0f) { // if we are here, there is a user defined minsize ... // always allow the char to stretch in its natural direction, // even if it is different from the caller's direction if (aStretchDirection != NS_STRETCH_DIRECTION_DEFAULT && aStretchDirection != mEmbellishData.direction) { aStretchDirection = NS_STRETCH_DIRECTION_DEFAULT; // but when we are not honoring the requested direction // we should not use the caller's container size either container = initialSize; } if (NS_MATHML_OPERATOR_MINSIZE_IS_ABSOLUTE(mFlags)) { // there is an explicit value like minsize="20pt" // try to maintain the aspect ratio of the char float aspect = mMinSize / float(initialSize.ascent + initialSize.descent); container.ascent = std::max(container.ascent, nscoord(initialSize.ascent * aspect)); container.descent = std::max(container.descent, nscoord(initialSize.descent * aspect)); container.width = std::max(container.width, (nscoord)mMinSize); } else { // multiplicative value container.ascent = std::max(container.ascent, nscoord(initialSize.ascent * mMinSize)); container.descent = std::max(container.descent, nscoord(initialSize.descent * mMinSize)); container.width = std::max(container.width, nscoord(initialSize.width * mMinSize)); } if (isVertical && !NS_MATHML_OPERATOR_IS_SYMMETRIC(mFlags)) { // re-adjust to align the char with the bottom of the initial container height = container.ascent + container.descent; container.descent = aContainerSize.descent; container.ascent = height - container.descent; } } } // let the MathMLChar stretch itself... nsresult res = mMathMLChar.Stretch(PresContext(), aRenderingContext, fontSizeInflation, aStretchDirection, container, charSize, stretchHint, StyleVisibility()->mDirection); if (NS_FAILED(res)) { // gracefully handle cases where stretching the char failed (i.e., GetBoundingMetrics failed) // clear our 'form' to behave as if the operator wasn't in the dictionary mFlags &= ~NS_MATHML_OPERATOR_FORM; useMathMLChar = false; } } // Place our children using the default method // This will allow our child text frame to get its DidReflow() nsresult rv = Place(aRenderingContext, true, aDesiredStretchSize); if (NS_MATHML_HAS_ERROR(mPresentationData.flags) || NS_FAILED(rv)) { // Make sure the child frames get their DidReflow() calls. DidReflowChildren(mFrames.FirstChild()); } if (useMathMLChar) { // update our bounding metrics... it becomes that of our MathML char mBoundingMetrics = charSize; // if the returned direction is 'unsupported', the char didn't actually change. // So we do the centering only if necessary if (mMathMLChar.GetStretchDirection() != NS_STRETCH_DIRECTION_UNSUPPORTED || NS_MATHML_OPERATOR_IS_CENTERED(mFlags)) { bool largeopOnly = (NS_STRETCH_LARGEOP & stretchHint) != 0 && (NS_STRETCH_VARIABLE_MASK & stretchHint) == 0; if (isVertical || NS_MATHML_OPERATOR_IS_CENTERED(mFlags)) { // the desired size returned by mMathMLChar maybe different // from the size of the container. // the mMathMLChar.mRect.y calculation is subtle, watch out!!! height = mBoundingMetrics.ascent + mBoundingMetrics.descent; if (NS_MATHML_OPERATOR_IS_SYMMETRIC(mFlags) || NS_MATHML_OPERATOR_IS_CENTERED(mFlags)) { // For symmetric and vertical operators, or for operators that are always // centered ('+', '*', etc) we want to center about the axis of the container mBoundingMetrics.descent = height/2 - axisHeight; } else if (!largeopOnly) { // Align the center of the char with the center of the container mBoundingMetrics.descent = height/2 + (container.ascent + container.descent)/2 - container.ascent; } // else align the baselines mBoundingMetrics.ascent = height - mBoundingMetrics.descent; } } } // Fixup for the final height. // On one hand, our stretchy height can sometimes be shorter than surrounding // ASCII chars, e.g., arrow symbols have |mBoundingMetrics.ascent + leading| // that is smaller than the ASCII's ascent, hence when painting the background // later, it won't look uniform along the line. // On the other hand, sometimes we may leave too much gap when our glyph happens // to come from a font with tall glyphs. For example, since CMEX10 has very tall // glyphs, its natural font metrics are large, even if we pick a small glyph // whose size is comparable to the size of a normal ASCII glyph. // So to avoid uneven spacing in either of these two cases, we use the height // of the ASCII font as a reference and try to match it if possible. // special case for accents... keep them short to improve mouse operations... // an accent can only be the non-first child of <mover>, <munder>, <munderover> bool isAccent = NS_MATHML_EMBELLISH_IS_ACCENT(mEmbellishData.flags); if (isAccent) { nsEmbellishData parentData; GetEmbellishDataFrom(GetParent(), parentData); isAccent = (NS_MATHML_EMBELLISH_IS_ACCENTOVER(parentData.flags) || NS_MATHML_EMBELLISH_IS_ACCENTUNDER(parentData.flags)) && parentData.coreFrame != this; } if (isAccent && firstChild) { // see bug 188467 for what is going on here nscoord dy = aDesiredStretchSize.BlockStartAscent() - (mBoundingMetrics.ascent + leading); aDesiredStretchSize.SetBlockStartAscent(mBoundingMetrics.ascent + leading); aDesiredStretchSize.Height() = aDesiredStretchSize.BlockStartAscent() + mBoundingMetrics.descent; firstChild->SetPosition(firstChild->GetPosition() - nsPoint(0, dy)); } else if (useMathMLChar) { nscoord ascent = fm->MaxAscent(); nscoord descent = fm->MaxDescent(); aDesiredStretchSize.SetBlockStartAscent(std::max(mBoundingMetrics.ascent + leading, ascent)); aDesiredStretchSize.Height() = aDesiredStretchSize.BlockStartAscent() + std::max(mBoundingMetrics.descent + leading, descent); } aDesiredStretchSize.Width() = mBoundingMetrics.width; aDesiredStretchSize.mBoundingMetrics = mBoundingMetrics; mReference.x = 0; mReference.y = aDesiredStretchSize.BlockStartAscent(); // Place our mMathMLChar, its origin is in our coordinate system if (useMathMLChar) { nscoord dy = aDesiredStretchSize.BlockStartAscent() - mBoundingMetrics.ascent; mMathMLChar.SetRect(nsRect(0, dy, charSize.width, charSize.ascent + charSize.descent)); } // Before we leave... there is a last item in the check-list: // If our parent is not embellished, it means we are the outermost embellished // container and so we put the spacing, otherwise we don't include the spacing, // the outermost embellished container will take care of it. if (!NS_MATHML_OPERATOR_HAS_EMBELLISH_ANCESTOR(mFlags)) { // Account the spacing if we are not an accent with explicit attributes nscoord leadingSpace = mEmbellishData.leadingSpace; if (isAccent && !NS_MATHML_OPERATOR_HAS_LSPACE_ATTR(mFlags)) { leadingSpace = 0; } nscoord trailingSpace = mEmbellishData.trailingSpace; if (isAccent && !NS_MATHML_OPERATOR_HAS_RSPACE_ATTR(mFlags)) { trailingSpace = 0; } mBoundingMetrics.width += leadingSpace + trailingSpace; aDesiredStretchSize.Width() = mBoundingMetrics.width; aDesiredStretchSize.mBoundingMetrics.width = mBoundingMetrics.width; nscoord dx = (StyleVisibility()->mDirection ? trailingSpace : leadingSpace); if (dx) { // adjust the offsets mBoundingMetrics.leftBearing += dx; mBoundingMetrics.rightBearing += dx; aDesiredStretchSize.mBoundingMetrics.leftBearing += dx; aDesiredStretchSize.mBoundingMetrics.rightBearing += dx; if (useMathMLChar) { nsRect rect; mMathMLChar.GetRect(rect); mMathMLChar.SetRect(nsRect(rect.x + dx, rect.y, rect.width, rect.height)); } else { nsIFrame* childFrame = firstChild; while (childFrame) { childFrame->SetPosition(childFrame->GetPosition() + nsPoint(dx, 0)); childFrame = childFrame->GetNextSibling(); } } } } // Finished with these: ClearSavedChildMetrics(); // Set our overflow area GatherAndStoreOverflow(&aDesiredStretchSize); // There used to be code here to change the height of the child frame to // change the caret height, but the text frame that manages the caret is now // not a direct child but wrapped in a block frame. See also bug 412033. return NS_OK; }
/* * AdminValueDialogProc: Dialog procedure for editing a property's value. * lParam of INITDIALOG message is index of property in object list box. */ BOOL CALLBACK AdminValueDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { static int index; int type, i; char *value, line[MAX_PROPERTYLEN], *str, property[MAX_PROPERTYLEN]; static HWND hEdit; switch (message) { case WM_INITDIALOG: index = lParam; hEdit = GetDlgItem(hDlg, IDC_EDITVALUE); Edit_LimitText(hEdit, MAX_PROPERTYLEN - 1); ListBox_GetText(hObjectList, index, line); value = AdminPropertyValue(line, &type); if (value != NULL) { // Initialize dialog with current value for (i = 0; type_table[i].word != NULL; i++) if (type == type_table[i].type) CheckDlgButton(hDlg, type_table[i].control, 1); Edit_SetText(hEdit, value); Edit_SetSel(hEdit, 0, -1); strcpy(property, AdminNthToken(line, 1)); str = strchr(property, ' '); if (str != NULL) *str = 0; SetDlgItemText(hDlg, IDC_PROPERTY, property); } sprintf(line, "%d", current_obj); SetDlgItemText(hDlg, IDC_OBJECTNUM, line); CenterWindow(hDlg, GetParent(hDlg)); SetWindowFont(hEdit, GetFont(FONT_INPUT), TRUE); SetFocus(hEdit); return FALSE; case WM_COMMAND: switch (GET_WM_COMMAND_ID(wParam, lParam)) { case IDOK: // Get type and value str = NULL; for (i = 0; type_table[i].word != NULL; i++) if (IsDlgButtonChecked(hDlg, type_table[i].control)) { str = type_table[i].word; break; } if (str != NULL) { Edit_GetText(hEdit, line, MAX_PROPERTYLEN); GetDlgItemText(hDlg, IDC_PROPERTY, property, MAX_PROPERTYLEN); // Special case for NIL: value must be zero if (type_table[i].type == TAG_NIL) strcpy(line, "0"); sprintf(command, "set object %d %s %s %s", current_obj, property, str, line); SendMessage(hAdminDlg, BK_SENDCMD, 0, (LPARAM) command); // Change value in object list box sprintf(command, "%s = %s %s", property, str, line); WindowBeginUpdate(hObjectList); ListBox_DeleteString(hObjectList, index); ListBox_InsertString(hObjectList, index, command); WindowEndUpdate(hObjectList); } EndDialog(hDlg, IDOK); return TRUE; case IDCANCEL: EndDialog(hDlg, IDCANCEL); return TRUE; } break; } return FALSE; }
/* Property page dialog callback */ INT_PTR CALLBACK SortPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { PGLOBALDATA pGlobalData; pGlobalData = (PGLOBALDATA)GetWindowLongPtr(hwndDlg, DWLP_USER); switch (uMsg) { case WM_INITDIALOG: pGlobalData = (PGLOBALDATA)((LPPROPSHEETPAGE)lParam)->lParam; SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData); CreateSortList(GetDlgItem(hwndDlg, IDC_SORTLIST_COMBO), pGlobalData->lcid); break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_SORTLIST_COMBO: if (HIWORD(wParam) == CBN_SELCHANGE) { LCID NewLcid; INT iCurSel; iCurSel = SendDlgItemMessage(hwndDlg, IDC_SORTLIST_COMBO, CB_GETCURSEL, 0, 0); if (iCurSel == CB_ERR) break; NewLcid = SendDlgItemMessage(hwndDlg, IDC_SORTLIST_COMBO, CB_GETITEMDATA, iCurSel, 0); if (NewLcid == (LCID)CB_ERR) break; /* Save the new LCID */ pGlobalData->lcid = NewLcid; PropSheet_Changed(GetParent(hwndDlg), hwndDlg); } break; } break; case WM_NOTIFY: if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) { /* FIXME: Set locale ID: pGlobalData->lcid */ } break; } return FALSE; }