Solved

how to detect mouse?

Posted on 2000-03-28
9
232 Views
Last Modified: 2013-12-03
Hello:
   I want to make a option menu which contain a few button and so on.But i'm in exclusive mode in directx and so I think I canno use window button class and so on.So I think I must bit a bitmap containing button shapes and so on.My question is what is the standard way to detect mouse move onto the certain button(here button is a part of the whole opthon bitmap)?

(or better solution? I wonder how many game make there UI ?)

Need your suggestion .
Thank you very much!
0
Comment
Question by:geeboy
  • 6
  • 2
9 Comments
 
LVL 15

Accepted Solution

by:
NickRepin earned 100 total points
ID: 2666118
Your button image has the certain screen coordinates, say,

RECT btn={50,50,100,80};

Suppose the current mouse coordinates are stored in

POINT mouse;

To detect if mouse is over your button,

if(PtInRect(&btn,mouse)) {
  // Mouse is over the button.
}
else {
   // Mouse is somewhere else.
}

0
 

Author Comment

by:geeboy
ID: 2668580
Is this way professional ?
I wander what way many games use to make their UI ? Make button ,listbox ,and so on ? All draw in picture or use a window ?

Thank you!!
0
 
LVL 4

Expert Comment

by:nils pipenbrinck
ID: 2668872
you can still use the normal gui windows offers...

you just have to make sure, that if your dialog/window is going to paint something you have to tell gdi where to draw to.

This is done using the IDirectDraw4::FlipToGDISurface call.

There are two ways to make gdi work together with directx.

The first one is to call FlipToGDISurface right after you pageflipped  your primary buffer.. I run into some problems here because the window will only draw once... you can workaround that in two different ways: either cache the bitmap of the drawed window in memory or force a window repaint every time you pageflip.

of cause you can also don't pageflip as long as your window is visible.

it's worth the try,

  Nils

0
 

Author Comment

by:geeboy
ID: 2669871
Nils ,thanks for your great help .
But FlipToGDISurface() will make windows system GDI surface appear.How this useful.Soryy for my foolish,I cannot undertand your way.The key is how to tell window draw to my back surface  other than GDI surface?
Then I think I can flip all backsurface to the primary surface,right ?How that funciton help?

>>The first one is to call >>FlipToGDISurface right after you >>pageflipped  your primary buffer..

what's the FlipToGDISurface useful ?
I dont undertand the logic behind...
So ,I think there is no relationship between surface in directx and GDI surface used by windows system,ie primarysurface!=GDI surface and so on
am I wrong ?


I have 20 pts left but I can earn some later ,then I will give your all ,thanks!!!

Great thanks!
Great thanks for your expertise!
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:geeboy
ID: 2669879
sorry,i have 29 pts left.
0
 

Author Comment

by:geeboy
ID: 2669882
sorry,i have 29 pts left.
0
 

Author Comment

by:geeboy
ID: 2669891
Originally ,I want to ask this kind question at Game Programming area but I find less people there.Thus I ask here.Nil,do you often come here? Then I will ask there.
0
 
LVL 4

Expert Comment

by:nils pipenbrinck
ID: 2670022
hm.. it depends..

I check out experts-exchange at least twice a week, and I usually read c, c++, windows, the games section and sometimes the photoshop corner.

Nils
0
 

Author Comment

by:geeboy
ID: 2671756
Nils ,thanks for your great help .
But FlipToGDISurface() will make windows system GDI surface appear.How this useful.Soryy for my foolish,I cannot undertand your way.The key is how to tell window draw to my back surface  other than GDI surface?
Then I think I can flip all backsurface to the primary surface,right ?How that funciton help?

>>The first one is to call >>FlipToGDISurface right after you >>pageflipped  your primary buffer..

what's the FlipToGDISurface useful ?
I dont undertand the logic behind...
So ,I think there is no relationship between surface in directx and GDI surface used by windows system,ie primarysurface!=GDI surface and so on
am I wrong ?
????????

Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Winform not working on 64 bit machine 31 97
Problem to DocumentFormat 8 75
Problem to file 3 67
.NET tools for adding thread safety to a web app? 3 14
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now