Tooltip ohne Fenster erstellen?

BlackPsycho

Mitglied
Tooltip bewegt sich nicht mit

Hallo ich hab das problem das mein tooltip den ich erstelle nicht an meinem mauszeiger sich mitbewegt sondern einfach hängen bleibt und anscheinend die schleife nicht mehr weiter läuft.

kann mir wer dabei helfen?

wenn wer ne idee hat dann immer her damit :D

danke

Code:
// ImageSearchDLL.cpp : Defines the entry point for the DLL application.
//


#include <afx.h>
#include "stdafx.h"
#include <windows.h>
#include "util.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <array>
#include <GdiPlus.h>
#include "AutoIt3.h"

using namespace std;

/*
#ifdef _MANAGED
#pragma managed(push, off)
#endif

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
					 )
{
    return TRUE;
}

#ifdef _MANAGED
#pragma managed(pop)
#endif
*/
struct __HBUBBLE {
	HWND hwnd;
	TOOLINFO ti;		
};

typedef __HBUBBLE* HBUBBLE;

DWORD BubbleWindow_Create(HBUBBLE& hBubble, LPCTSTR pszText, LPCTSTR pszTitle, 
	WORD x, WORD y, WORD nMaxWidth)
{
	DWORD dwRet = NO_ERROR;
	hBubble = new __HBUBBLE;
	hBubble->hwnd = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, 
		NULL, TTS_ALWAYSTIP | TTS_BALLOON | WS_POPUP,
		0, 0, 0, 0, 
		NULL, NULL, GetModuleHandle(0), hBubble);
	if(NULL != hBubble->hwnd)
	{
		::ZeroMemory(&hBubble->ti, sizeof(TOOLINFO));
		hBubble->ti.cbSize = sizeof(TOOLINFO);
#if (_WIN32_WINNT >= 0x0501)
		hBubble->ti.cbSize -= sizeof(void*);
#endif
		hBubble->ti.uFlags = TTF_TRACK | TTF_ABSOLUTE;
		hBubble->ti.lpszText = const_cast<LPTSTR>(pszText);

		SendMessage(hBubble->hwnd, TTM_ADDTOOL, 0, (LPARAM)&hBubble->ti);
		SendMessage(hBubble->hwnd, TTM_SETMAXTIPWIDTH, 0, nMaxWidth);
		SendMessage(hBubble->hwnd, TTM_SETTITLE, TTI_INFO, (LPARAM)pszTitle);
		SendMessage(hBubble->hwnd, TTM_TRACKACTIVATE, TRUE, (LPARAM)&hBubble->ti);
		SendMessage(hBubble->hwnd, TTM_TRACKPOSITION, 0, MAKELPARAM(x, y));
	}
	else
	{
		dwRet = ::GetLastError();
	}
	return dwRet;
}

CPoint pt; 
HDC hDC;

int *umspeichern(char *x, int *anz)
{
	int *ret;
	int i, j;
	j = strlen(x); *anz = 0;
	for (i = 0; i < j; i++)
	{
		if (x[i] == '|') (*anz)++;
	}
	if (j > 0) (*anz)++;
	ret = (int *) malloc(sizeof(int) * (*anz));
	if (ret == NULL) return NULL;
	j = 0;
	for (i = 0; i < *anz; i++)
	{
		ret[i] = 0;
		while (x[j] != '|' && x[j] != '\0')
		{
			ret[i] = ret[i] * 10 + (x[j] - '0');
			j++;
		}
		j++;
	}
	return ret;
}



void BildSuchen()
{
	bool hit;
	int* array;
	int anz;

	GetCursorPos(&pt);

	char *answer="";
	answer = ImageSearch(0,0,1280,1024,"C:\\pic.bmp");

	// gibt das zurück: gefunden? 1 oder 0, x, y, img_w, img_h
	array = umspeichern(answer, &anz);
	
	//Rectangle(hDC, array[1], array[2], array[1]+array[3], array[2]+array[4]);
	
	RECT rechteck;

	rechteck.left = array[1];
	rechteck.top = array[2];
	rechteck.right = array[1]+array[3];
	rechteck.bottom = array[2]+array[4];

	hit = PtInRect(&rechteck, pt);
	
	

	if(hit == true)
	{
		// tooltip erstellen
		/*
		AU3_ToolTip(L"test",pt.x, pt.y);*/
		HBUBBLE hBubble = NULL;
		LPCTSTR pszText = _T("Test");
		LPCTSTR pszTitle = NULL;
		DWORD dwRet = BubbleWindow_Create(hBubble, pszText, pszTitle, pt.x, pt.y, sizeof(pszText));
		
		cout <<"1 \n";
	}
	else
	{
		// tooltip löschen
		//AU3_ToolTip(L"",pt.x, pt.y);
		cout <<"0 \n";
	}
	
	
	
	free(array);
}

void _tmain()
{
	while(1)
	{

		BildSuchen();

		cout << "mouseX: "<<pt.x<<" mouseY: "<<pt.y<<"\n";

	}	
		
	
	getchar();
	return;
	
}

danke
 
Zuletzt bearbeitet:
Zurück