Home » Community » Newbie corner » How to make a point follow the mouse through windows 7
How to make a point follow the mouse through windows 7 [message #36482] |
Thu, 31 May 2012 13:36 |
mohrphium
Messages: 2 Registered: May 2012 Location: Munich
|
Junior Member |
|
|
Hi there,
I want to write a small program, that creates a point which follows my mouse all the time. I need this, because I want to stream my desktop to another pc, but it won't show my mouse movements.
I tried drawing a circle in c++ (Visual Studio 2010 Express) but normally I use TheIDE for console apps and I would like to stick with U++ rather then switch to something else.
Anyway, I looked at the DragAndDrop examples, and what I need is exactly that blue dot following my mouse while draging. But I need it not only inside the window, but everywhere.
I don't even know where to start this (first time graphical programming).
PS: Another streaming software is not an option... Unless you know something that does webcam, sound, desktop streaming + recording everything (I already tried VLC, not working!)
PPS: I tried to run ConsoleDraw example, but I don't see anything, except the console window...
[Updated on: Thu, 31 May 2012 13:37] Report message to a moderator
|
|
|
Re: How to make a point follow the mouse through windows 7 [message #36490 is a reply to message #36482] |
Sat, 02 June 2012 02:29 |
Sender Ghost
Messages: 301 Registered: November 2008
|
Senior Member |
|
|
Hello, Frederic.
mohrphium wrote on Thu, 31 May 2012 13:36 | I want to write a small program, that creates a point which follows my mouse all the time. I need this, because I want to stream my desktop to another pc, but it won't show my mouse movements.
|
I think, there are other methods, but I accomplished this with following source code:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
class App : public TopWindow {
private:
Size sz;
Image img;
public:
typedef App CLASSNAME;
App();
TrayIcon tray;
virtual void Paint(Draw& w);
void ChangePos();
void DoChangePos();
void TrayMenu(Bar& bar);
};
void App::Paint(Draw& w)
{
w.DrawImage(sz, img);
}
void App::ChangePos()
{
static Point prev(0, 0);
Point p = GetMousePos();
if (prev != p) {
SetRectX(p.x - sz.cx, sz.cx);
SetRectY(p.y - sz.cy, sz.cy);
prev = p;
}
}
void App::DoChangePos()
{
static bool running = false;
if (!running)
SetTimeCallback(-10, THISBACK(ChangePos), 1);
else
KillTimeCallback(1);
Show(running = !running);
}
void App::TrayMenu(Bar& bar)
{
bar.Add(IsShown() ? t_("Hide") : t_("Show"), THISBACK(DoChangePos)).Key(K_CTRL_W);
bar.Separator();
bar.Add(t_("Exit"), THISBACK1(Break, (int)IDEXIT)).Key(K_CTRL_Q);
}
App::App()
{
const String title(t_("Moving image for mouse pointer"));
Title(title);
FrameLess().ToolWindow().TopMost();
NoInitFocus().NoWantFocus();
sz = Size(5, 5);
SetMinSize(sz); SetRect(sz);
// Drawing image for pointer
ImageDraw iw(sz);
iw.DrawRect(sz, Black());
iw.DrawEllipse(sz + 1, White());
img = iw;
Image icon = Image::Arrow();
Icon(icon);
tray.Icon(icon);
tray.Tip(title);
tray.WhenBar = THISBACK(TrayMenu);
tray.WhenLeftDouble = THISBACK(DoChangePos);
DoChangePos();
}
GUI_APP_MAIN
{
App app;
app.Run();
}
Basically, it creates the frameless tool window with some image, which moves to current mouse position periodically. Also possible to show or hide such window from tray icon.
|
|
|
|
Goto Forum:
Current Time: Sun Jan 19 03:35:21 CET 2025
Total time taken to generate the page: 0.03186 seconds
|