我需要删除为控件创建的工具提示窗口,该控件将在主窗口停留时被删除。我想出了下面的内容,但是找不到任何TOOLTIPS_CLASS窗口。有什么原因吗?
TIA !!
for (HWND hwndtip=NULL; (hwndtip=FindWindowEx(hwnd, hwndtip, TOOLTIPS_CLASS, NULL))!=NULL;) {
// check if it has the control id we want
TOOLINFO toolinfo ={ 0 };
toolinfo.cbSize = sizeof(toolinfo);
toolinfo.hwnd = hwnd;
toolinfo.uFlags = TTF_IDISHWND;
toolinfo.uId = (UINT_PTR)hwndctl;
if (SendMessage(hwndtip, TTM_GETTOOLINFO, 0, (LPARAM)&toolinfo)) {
// found tooltip to delete
DestroyWindow(hwndtip);
result=TRUE;
break;
}
}
答案 0 :(得分:0)
好的,我发现了一种通过将TTM_GETTOOLINFO发送到找到的每个工具提示窗口而不会崩溃的方法。基本上,为您创建的工具提示窗口命名。例如,_T(“ MINE !!”)然后找到它:
public class FavoritableCellEditor extends AbstractCellEditor implements TableCellEditor {
private final FavoriteCheckBox cellEditor;
public FavoritableCellEditor() {
cellEditor = new FavoriteCheckBox();
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
if (value instanceof Boolean) {
boolean selected = (boolean) value;
cellEditor.setSelected(selected);
}
return cellEditor;
}
@Override
public Object getCellEditorValue() {
return cellEditor.isSelected();
}
}
public class FavoritableCheckboxRenderer extends FavoriteCheckBox implements TableCellRenderer {
@Override
public void setSelected(boolean selected) {
super.setSelected(selected);
if (selected) {
setIcon(selIcon);
} else {
setIcon(unselIcon);
}
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (value instanceof Boolean) {
boolean selected = (boolean) value;
setSelected(selected);
}
return this;
}
}
public class FavoriteCheckBox extends JCheckBox {
Icon selIcon;
Icon unselIcon;
public FavoriteCheckBox() {
try {
selIcon = new ImageIcon(ImageIO.read(getClass().getResource("/com/lmco/jsf/dqim/applications/TESTING/resources/baseline_star_black_18dp.png")));
unselIcon = new ImageIcon(ImageIO.read(getClass().getResource("/com/lmco/jsf/dqim/applications/TESTING/resources/baseline_star_border_black_18dp.png")));
} catch (IOException ex) {
Logger.getLogger(FavoriteCheckBox.class.getName()).log(Level.SEVERE, null, ex);
}
setHorizontalAlignment(CENTER);
}
@Override
public void setSelected(boolean selected) {
super.setSelected(selected);
if (selected) {
setIcon(selIcon);
} else {
setIcon(unselIcon);
}
revalidate();
repaint();
}
}