Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > .NET

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 08-02-2001, 10:41 PM
FancyFace FancyFace is offline
Senior Member
 
Join Date: Jun 2001
Posts: 134
Default To b-w-d.net : MouseMove- Show little box ??/

Hi there,

I just want to make sure about the following. Help if I'm wrong.
On my form I have a TImage called Image1.Next to the image, I have a TPanel component named Panel. This is the code you gave me:


procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage := MessageProcessing;
end;

procedure TForm1.MessageProcessing(var Msg : TMsg; var Handled : boolean);
var
MousePosition : TPoint;
CursorPos : TPoint;

begin
if Msg.message = WM_MOUSEMOVE then if Image1.visible=true then begin
MousePosition:=CursorPos;
MousePosition.x:=MousePosition.x+Form1.left;
MousePosition.y:=MousePosition.y+Form1.top;
if (MousePosition.x >= Image1.left) and (MousePosition.x <= Image1.left+Image1.width) and (MousePosition.y >= Image1.top) and (MousePosition.y <= Image1.top+Image1.height) then begin
Panel.left:=(2*Form1.left)-MousePosition.x;
Panel.top:=(2*Form1.top)-MousePosition.y;
Panel.visible:=true;
end
else Panel.visible:=false;
end;
end;

Now, what currently is happening with this code is: when I move my mouse over the image the panel disappears. Am I right if I say that what suppose to happen is that when my mouse move over the image, the panel will become visible and follow my mouse.Maybe I'm missing something, but if that is the case, how can I make this work for me.

Thanks
Christiaan
Reply With Quote
  #2  
Old 08-03-2001, 02:27 AM
non_zero non_zero is offline
Member
 
Join Date: Jun 2001
Posts: 97
Default RE: To b-w-d.net : MouseMove- Show little box ??/

hiya..

i ll check this..

but i cant send a reply from here.. i think ..
cuz..

send ur email to me ..
my e mail is msarica@bellona.com.tr

bye only for now..
Reply With Quote
  #3  
Old 08-03-2001, 04:12 AM
b-w-d.net b-w-d.net is offline
Senior Member
 
Join Date: May 2001
Posts: 1,122
Default RE: To b-w-d.net : MouseMove- Show little box ??/

ok, i had a look through this code, firstly, CursorPos shouldnt have been declared, and i should not have tried using it, use this instead:

procedure TForm1.MessageProcessing(var Msg : TMsg; var Handled : boolean);
var
MousePosition : TPoint;
begin
if Msg.message = WM_MOUSEMOVE then if Image1.visible=true then begin
MousePosition.x:=Abs( LoWord( Msg.lParam ));
MousePosition.y:=Abs( HiWord( Msg.lParam ));
if (MousePosition.x > Image1.left) and (MousePosition.x < Image1.left+Image1.width) and (MousePosition.y > Image1.top) and (MousePosition.y < Image1.top+Image1.height) then begin
if panel.visible=false then begin
Panel.left:=MousePosition.x;
Panel.top:=MousePosition.y;
Panel.visible:=true;
end;
end
else Panel.visible:=false;
end;
end;


with the image i am using however delphi does not seem to recognise that the mouse is within the images rect while the mouse is over the panel, so there are a few problems there, but you can fix that using almost the same as the above.

you could try using this:

procedure TForm1.MessageProcessing(var Msg : TMsg; var Handled : boolean);
var
MousePosition : TPoint;
begin
if Msg.message = WM_MOUSEMOVE then if Image1.visible=true then begin
MousePosition.x:=Abs( LoWord( Msg.lParam ));
MousePosition.y:=Abs( HiWord( Msg.lParam ));
if (MousePosition.x > Image1.left) and (MousePosition.x < Image1.left+Image1.width) and (MousePosition.y > Image1.top) and (MousePosition.y < Image1.top+Image1.height) and not ((MousePosition.x >= panel.left) and (MousePosition.x <= panel.left+panel.width) and (MousePosition.y >= panel.top) and (MousePosition.y <= panel.top+panel.height)) then begin
if panel.visible=false then begin
Panel.left:=MousePosition.x;
Panel.top:=MousePosition.y;
Panel.visible:=true;
end;
end
else Panel.visible:=false;
end;
end;

which should check if the mouse is within the panels rect, in which case the important code will not begin. with this code the panel does not follow the cursor, i tried to get that done, but it was very flickery as i had to repaint the image each time the panel moved, otherwise i had a nasty gray area on the form over the image.


see you around, bye!

----------------------------
[b-w-d.net]
webmaster@b-w-d.net

[if this helps you please click on Accept]
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:34 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.