void ControlToolBar::Populate() { MakeButtonBackgroundsLarge(); mPause = MakeButton(bmpPause, bmpPause, bmpPauseDisabled, ID_PAUSE_BUTTON, true, _("Pause")); mPlay = MakeButton( bmpPlay, bmpPlay, bmpPlayDisabled, ID_PLAY_BUTTON, true, _("Play")); MakeLoopImage(); mStop = MakeButton( bmpStop, bmpStop, bmpStopDisabled , ID_STOP_BUTTON, false, _("Stop")); mRewind = MakeButton(bmpRewind, bmpRewind, bmpRewindDisabled, ID_REW_BUTTON, false, _("Skip to Start")); mFF = MakeButton(bmpFFwd, bmpFFwd, bmpFFwdDisabled, ID_FF_BUTTON, false, _("Skip to End")); mRecord = MakeButton(bmpRecord, bmpRecord, bmpRecordDisabled, ID_RECORD_BUTTON, true, _("Record")); #if wxUSE_TOOLTIPS RegenerateToolsTooltips(); wxToolTip::Enable(true); wxToolTip::SetDelay(1000); #endif // Set default order and mode ArrangeButtons(); }
// wparam = (TTBButton*)lpTTBButton // lparam = hLangpack INT_PTR TTBAddButton(WPARAM wParam, LPARAM lParam) { if (wParam == 0) return -1; TTBButton *but = (TTBButton *)wParam; if (!(but->dwFlags & TTBBF_ISLBUTTON) && nameexists(but->name)) return -1; TopButtonInt *b = CreateButton(but); b->hLangpack = (int)lParam; b->LoadSettings(); b->CreateWnd(); if (b->hwnd == NULL) { delete b; return -1; } mir_cslock lck(csButtonsHook); Buttons.insert(b); g_ctrl->bOrderChanged = TRUE; ArrangeButtons(); AddToOptions(b); return b->id; }
afx_msg BOOL CWSMessageBox::OnInitDialog() { AFX_MANAGE_STATE( AfxGetStaticModuleState() ) UpdateData(FALSE); CDialog::OnInitDialog(); SetWindowText(m_sTitle); // Set-up the help link m_StaticHyperLinkHelp.SubclassDlgItem(IDC_HELPLINK, this); m_StaticHyperLinkHelp.m_iHelpID = m_iHelpID; // Set the correct fonts GetDlgItem(IDC_HEADLINE_TEXT)->SetFont(CFont::FromHandle(m_workshareFonts.WorkshareMainInstructionFont())); GetDlgItem(IDC_MAIN_TEXT)->SetFont(CFont::FromHandle(m_workshareFonts.WorkshareNormalTextFont())); // Hide all buttons by default m_Btn1.ShowWindow(SW_HIDE); m_Btn2.ShowWindow(SW_HIDE); m_Btn3.ShowWindow(SW_HIDE); m_StaticHyperLinkHelp.ShowWindow(SW_HIDE); m_DoNotShow_ChkBox.ShowWindow( m_sLearningID.IsEmpty() ? SW_HIDE : SW_SHOW); // If no headline text, hide it and move the main text up HideHeadLineText(); // Adjust to fit the amount of text in the text controls AdjustDialogHeight(); LabelButtons(); // Is this a dialog with a help button? if(m_iHelpID >= 0) { m_StaticHyperLinkHelp.ShowWindow(SW_SHOW); } // Hide/show/position the buttons appropriately ArrangeButtons(); // Display the correct icon, based on the type of the message switch(m_Type) { case Workshare::Messaging::WsInfoIcon: m_iIconId = IDB_BITMAP_INFORMATION; break; case Workshare::Messaging::WsErrorIcon: m_iIconId = IDB_BITMAP_ERROR; break; case Workshare::Messaging::WsWarnIcon: m_iIconId = IDB_BITMAP_WARNING; break; } return TRUE; }
static int OnModulesLoad(WPARAM, LPARAM) { LoadAllSeparators(); LoadAllLButs(); ArrangeButtons(); HANDLE hEvent = CreateEvent(NULL, TRUE, TRUE, NULL);//anonymous event if (hEvent != 0) CallService(MS_SYSTEM_WAITONHANDLE, (WPARAM)hEvent, (LPARAM)"TTB_ONSTARTUPFIRE"); if (HookEvent(ME_BACKGROUNDCONFIG_CHANGED, OnBGChange)) { char buf[256]; mir_snprintf(buf, "%s/%s", LPGEN("TopToolBar background"), TTB_OPTDIR); CallService(MS_BACKGROUNDCONFIG_REGISTER, (WPARAM)buf, 0); } return 0; }
// wparam = (HANDLE)hTTButton // lparam = 0 INT_PTR TTBRemoveButton(WPARAM wParam, LPARAM) { mir_cslock lck(csButtonsHook); int idx; TopButtonInt *b = idtopos(wParam, &idx); if (b == NULL) return -1; RemoveFromOptions(b->id); Buttons.remove(idx); delete b; g_ctrl->bOrderChanged = TRUE; ArrangeButtons(); return 0; }
void ControlToolBar::Populate() { MakeButtonBackgroundsLarge(); mPause = MakeButton(bmpPause, bmpPause, bmpPauseDisabled, ID_PAUSE_BUTTON, true, _("Pause")); mPlay = MakeButton( bmpPlay, bmpPlay, bmpPlayDisabled, ID_PLAY_BUTTON, true, _("Play")); MakeAlternateImages(*mPlay, 1, bmpLoop, bmpLoop, bmpLoopDisabled); MakeAlternateImages(*mPlay, 2, bmpCutPreview, bmpCutPreview, bmpCutPreviewDisabled); MakeAlternateImages(*mPlay, 3, bmpScrub, bmpScrub, bmpScrubDisabled); MakeAlternateImages(*mPlay, 4, bmpSeek, bmpSeek, bmpSeekDisabled); mPlay->FollowModifierKeys(); mStop = MakeButton( bmpStop, bmpStop, bmpStopDisabled , ID_STOP_BUTTON, false, _("Stop")); mRewind = MakeButton(bmpRewind, bmpRewind, bmpRewindDisabled, ID_REW_BUTTON, false, _("Skip to Start")); mFF = MakeButton(bmpFFwd, bmpFFwd, bmpFFwdDisabled, ID_FF_BUTTON, false, _("Skip to End")); mRecord = MakeButton(bmpRecord, bmpRecord, bmpRecordDisabled, ID_RECORD_BUTTON, true, _("Record")); MakeAlternateImages(*mRecord, 1, bmpAppendRecord, bmpAppendRecord, bmpAppendRecordDisabled); mRecord->FollowModifierKeys(); #if wxUSE_TOOLTIPS RegenerateToolsTooltips(); wxToolTip::Enable(true); wxToolTip::SetDelay(1000); #endif // Set default order and mode ArrangeButtons(); }
int OnPluginUnload(WPARAM, LPARAM lParam) { int lang = GetPluginLangByInstance((HINSTANCE)lParam); if (lang) { bool bNeedUpdate = false; mir_cslock lck(csButtonsHook); for (int i = Buttons.getCount() - 1; i >= 0; i--) if (Buttons[i]->hLangpack == lang) { TTBRemoveButton(Buttons[i]->id, 0); bNeedUpdate = true; } if (bNeedUpdate) { ArrangeButtons(); if (g_ctrl->hWnd) PostMessage(g_ctrl->hWnd, TTB_UPDATEFRAMEVISIBILITY, 0, 0); } } return 0; }
void ControlToolBar::Populate() { MakeButtonBackgroundsLarge(); mPause = MakeButton(bmpPause,bmpPauseDisabled, ID_PAUSE_BUTTON, true, _("Pause"), _("Pause")); mPlay = MakeButton( bmpPlay, bmpPlayDisabled, ID_PLAY_BUTTON, true, _("Play"), _("Play (Shift for Loop Play)")); MakeLoopImage(); mStop = MakeButton( bmpStop, bmpStopDisabled , ID_STOP_BUTTON, false, _("Stop"), _("Stop")); mRewind = MakeButton(bmpRewind, bmpRewindDisabled, ID_REW_BUTTON, false, _("Start"), _("Skip to Start")); mFF = MakeButton(bmpFFwd, bmpFFwdDisabled, ID_FF_BUTTON, false, _("End"), _("Skip to End")); mRecord = MakeButton(bmpRecord, bmpRecordDisabled, ID_RECORD_BUTTON, true, _("Record"), _("Record (Shift for Append Record)")); mBatch = MakeButton(bmpCleanSpeech,bmpCleanSpeechDisabled, ID_BATCH_BUTTON, false, _("Clean Speech"), _("Clean Speech")); #if wxUSE_TOOLTIPS // MB: Should make this a pref wxToolTip::Enable(true); wxToolTip::SetDelay(1000); #endif // Set default order and mode ArrangeButtons(); }
INT_PTR TTBSetOptions(WPARAM wParam, LPARAM lParam) { mir_cslock lck(csButtonsHook); TopButtonInt *b = idtopos(HIWORD(wParam)); if (b == NULL) return -1; switch (LOWORD(wParam)) { case TTBO_FLAGS: { if (b->dwFlags == lParam) return 0; DWORD retval = b->CheckFlags(lParam); if (retval & TTBBF_PUSHED) b->SetBitmap(); if (retval & TTBBF_VISIBLE) { ArrangeButtons(); b->SaveSettings(0, 0); } return 1; } case TTBO_TIPNAME: if (lParam == 0) return -1; replaceStrT(b->ptszTooltip, TranslateTS(_A2T((LPCSTR)lParam))); SendMessage(b->hwnd, BUTTONADDTOOLTIP, (WPARAM)b->ptszTooltip, BATF_UNICODE); return 1; case TTBO_ALLDATA: if (lParam) { TTBButton *lpTTB = (TTBButton*)lParam; DWORD retval = b->CheckFlags(lpTTB->dwFlags); bool changed = false; if (b->hIconUp != lpTTB->hIconUp) { b->hIconUp = lpTTB->hIconUp; changed = true; } if (b->hIconDn != lpTTB->hIconDn) { b->hIconDn = lpTTB->hIconDn; changed = true; } if (changed) b->SetBitmap(); if (retval & TTBBF_VISIBLE) { ArrangeButtons(); b->SaveSettings(0, 0); } if (b->dwFlags & TTBBF_ISLBUTTON) replaceStrT(b->ptszProgram, lpTTB->program); else replaceStr(b->pszService, lpTTB->pszService); b->lParamUp = lpTTB->lParamUp; b->wParamUp = lpTTB->wParamUp; b->lParamDown = lpTTB->lParamDown; b->wParamDown = lpTTB->wParamDown; return 1; } else return 0; default: return -1; } }
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 ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_AUTORESIZE, g_ctrl->bAutoSize ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_SINGLELINE, g_ctrl->bSingleLine ? BST_CHECKED : BST_UNCHECKED); 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, _countof(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 = _countof(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.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, _countof(buf)); replaceStr(btn->pszName, _T2A(buf)); tvi.mask = TVIF_TEXT; tvi.pszText = buf; TreeView_SetItem(hTree, &tvi); GetDlgItemText(hwndDlg, IDC_EPATH, buf, _countof(buf)); replaceStrT(btn->ptszProgram, buf); } break; } if (ctrlid == IDC_ADDLBUTTON) { // create button TTBButton ttb = { 0 }; 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.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_BEGINDRAG: 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_SELCHANGED: { 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 = _countof(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; }
LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { static bool supressRepos = false; switch(msg) { case WM_CREATE: g_ctrl->hWnd = hwnd; PostMessage(hwnd, TTB_UPDATEFRAMEVISIBILITY, 0, 0); return FALSE; case WM_DESTROY: g_ctrl->hWnd = NULL; break; case WM_MOVE: return 0; case WM_WINDOWPOSCHANGING: case WM_SIZE: if (g_ctrl->nLastHeight != HIWORD(lParam)) { db_set_dw(0, TTB_OPTDIR, "LastHeight", g_ctrl->nLastHeight = HIWORD(lParam)); ArrangeButtons(); } if (supressRepos) { supressRepos = false; break; } // fall through case TTB_REPOSBUTTONS: if (g_ctrl->hWnd == hwnd) { int iHeight = ArrangeButtons(); if ( g_ctrl->bAutoSize) { RECT rcClient; GetClientRect(g_ctrl->hWnd, &rcClient); rcClient.bottom -= rcClient.top; if (rcClient.bottom != iHeight && iHeight && rcClient.bottom) { supressRepos = true; PostMessage(hwnd, TTB_UPDATEFRAMEVISIBILITY, 0, 0); } } return 0; } break; case WM_NCPAINT: case WM_PAINT: PaintToolbar(hwnd); return 0; case WM_LBUTTONDOWN: if (db_get_b(NULL, "CLUI", "ClientAreaDrag", 0)) { POINT pt; GetCursorPos(&pt); return SendMessage(GetParent(hwnd), WM_SYSCOMMAND, SC_MOVE|HTCAPTION, MAKELPARAM(pt.x, pt.y)); } return 0; case WM_COMMAND: switch (HIWORD(wParam)) { case BN_CLICKED: case BN_DOUBLECLICKED: { int id = GetWindowLongPtr((HWND)lParam, GWLP_USERDATA); if (id != 0) { mir_cslock lck(csButtonsHook); TopButtonInt* b = idtopos(id); if (b == NULL || b->isSep()) return 0; if (b->dwFlags & TTBBF_ASPUSHBUTTON) b->bPushed = !b->bPushed; if (b->bPushed) { //Dn -> Up if (!(b->dwFlags & TTBBF_ISLBUTTON)) // must be always true if (b->pszService != NULL) CallService(b->pszService, b->wParamUp, b->lParamUp); } else { //Up -> Dn if (b->pszService != NULL) CallService(b->pszService, b->wParamDown, b->lParamDown); } b->SetBitmap(); } } break; } break; case TTB_UPDATEFRAMEVISIBILITY: { bool bResize = false; if (g_ctrl->bAutoSize) { int Height = ArrangeButtons(); INT_PTR frameopt = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, g_ctrl->hFrame), 0); if (Height != frameopt) { CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_HEIGHT, g_ctrl->hFrame), Height); bResize = TRUE; } } if (g_ctrl->bOrderChanged) bResize = TRUE, g_ctrl->bOrderChanged = FALSE; if (bResize) CallService(MS_CLIST_FRAMES_UPDATEFRAME, (WPARAM)g_ctrl->hFrame, FU_FMPOS); } break; case TTB_SETCUSTOMDATASIZE: g_ctrl = (TTBCtrl*)mir_realloc(g_ctrl, lParam); if (lParam > sizeof(TTBCtrl)) memset(g_ctrl+1, 0, lParam - sizeof(TTBCtrl)); SetWindowLongPtr(hwnd, 0, (LONG_PTR)g_ctrl); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return TRUE; }