|
Thanks That Worked.
I have found DBEngine And DBEngineClass also exist
|
|
|
|
|
Hi all,
I have a form where I want to set some regions. When the mouse moves over these regions I want the cursor image to change.
My idea is to set up some rectangles and use the mousemove event (somehow) to check against the current position of the cursor.
I just want to know what properties do I need to use for this and is there a better way.
I suppose I'm basically asking how I can check if the mouse is over a certain area of a form.
Thanks in advance
Rich
|
|
|
|
|
Try override event MouseMove to get mouse position.
Or use MouseEnter, MouseHover or MouseLeave event to evulate if mouse is in or on certian controls.
|
|
|
|
|
So I've got a rectangle that defines an area. How do I then check whether the mouse position is in that area. I've tried using,
<br />
myRec.Contains ( this->MousePosition );<br />
but it doesn't seem to use the whole area. It only seems to work at a certain spot.
I'm obviously misunderstanding something.
|
|
|
|
|
I have found the problem. MousePosition gets you position, point 0,0 top left of the creen, not the form.
There is work around this problem.
#include <windows.h>
RECT *rect = new RECT();
HWND hWnd = GetActiveWindow();
GetWindowRect(hWnd, rect);
int x = this->MousePosition.X - rect->left - 4;
int y = this->MousePosition.Y - rect->top - 30;
if (myRec->Contains(x, y) == true)
label1->Text = S"True";
else
label1->Text = S"False";
ps: Overridng Those event like MouseEnter, and other i have posted will work only if it is a control. I have reread and now i anderstand what you have ment.
|
|
|
|
|
Thanks for the help.
I'm having trouble firstly with the drawing or placement of the rectangle. It's not in the correct place - for instance, if I draw a picturebox with the same coordinates they are in different positions on the screen. Very confused as to why this is - so I assume from your previous post they are being drawn with different relative positions.
So I've tried to use the work around you posted but if I include the windows header I have a lot of problems with my message boxes and some other components that I need. Is there no way of doing the same thing without the need for the win32 api.
|
|
|
|
|
Sorry, I can't get that error. Try to make another unmanaget class with old syntax:
#ifndef _MPOINT_H_
#define _MPOINT_H_
#include <Windows.h>
struct pointMData
{
int x;
int y;
};
class MPoint
{
public:
MPoint(void){}
~MPoint(void){}
void GetPoint(pointMData *pData)
{
RECT *rect = new RECT();
HWND hWnd = GetActiveWindow();
GetWindowRect(hWnd, rect);
pData->x = rect->left;
pData->y = rect->top;
return;
}
};
#endif
This is unmanaged class, so i have created pointMData for retreaving, because i have a problem using Rectangle in umanaged class. If this doesn't work, then try Creating Win32 DLL.
quote:
Is there no way of doing the same thing without the need for the win32 api.
I couldn't find in framework for this workaround, so i used Win32 api. I don't know if exist.
ps: i hope this works
|
|
|
|
|
Hello,
I'am new to c++ and i want to convert 3 bytes unsigned character to 4 bytes long.
unsigned char UniqueID[3];
long converted;
converted=??;
How can I convert this?
Thanks.
|
|
|
|
|
What do you expect to do ? What do the three bytes contain ? There's no obvious conversion here, that I can see. If it's a number, then you need to know what significance each byte has. If it's just left to right, this should do it
long converted = UniqueID[0] + (UniqueID[1] << 8) + (UniqueID[2] << 16);
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks, it does what i need.
More Power to you.
|
|
|
|
|
Dudes...
I want a code in either c or c++ that enables SERVER to multiple client communication. I also want the libraries required to do so.
GAURAV ZIBBU
|
|
|
|
|
Hello.
Please suggest how to create an Event Sink registation for Exchange Server Folder on some COM+ component via MAPI and/or Exchange SDK.
Please do not suggest to do this using CDO, coz CDO is not alowed in my project.
Please give a code example or a link to the article.
|
|
|
|
|
Is it possible to produce a code something like the one below, or do I have to change the changeValue functions parameter to (int *& valueReference)?
int value1 = 1;<br />
int value2 = 2;<br />
<br />
void changeValue(int && valueReference)<br />
{<br />
valueReference = value2;<br />
}<br />
<br />
void main()<br />
{<br />
int & valueReference = value1;<br />
changeValue(valueReference);<br />
cout << valueReference;
}
|
|
|
|
|
I suppose this question should be in the C++ forum
Code is OK if you change
void changeValue(int && valueReference)
to
void changeValue(int & valueReference)
&& is the AND operator, int *& is wrong. It may be best to start off getting to grips with C pointers before mixing them with C++ references.
For example, if your code was :-
int value1 = 1;
int value2 = 2;
void changeValue(int *p)
{
p = &value2;
}
int _tmain()
{
int valueReference = value1;
changeValue(&valueReference);
cout << value1; // 1 instead of 2 this time.
}
then valueReference would not be changed, only the local copy of p in changeValue() is set to point to value1.
|
|
|
|
|
quote:
int valueReference = value1;
changeValue(&valueReference);
cout << value1; // 1 instead of 2 this time.
it shoud be:
cout << valueReference; // valueReference instead value 1
|
|
|
|
|
No it shouldn't be cout << valueReference
You miss my point completely, I wanted to show that value1 wasn't changed because this time a pointer was passed to changeValue. Pointers are passed by value, whereas references are passed byref, hence the different result when a pointer is used instead of a reference.
|
|
|
|
|
then change
this:
int valueReference = value1;<br />
changeValue(&valueReference);<br />
<br />
to:<br />
<br />
int *valueReference = &value1;<br />
changeValue(valueReference);
value1 didn't change, because you didn't pass address of value1 to pointer valueReference.
|
|
|
|
|
Tanks for your answer, my question was a bit unclear. What I’m really is looking for is a way to modify the referee itself not the “thing” it refers to, so I believe I have to do something like this.
<br />
const int value1 = 1;<br />
const int value2 = 2;<br />
<br />
void changeReference(const int *& p)<br />
{<br />
p = &value2;<br />
}<br />
<br />
void main()<br />
{<br />
const int * valueReference = &value1;<br />
changeReference(valueReference);<br />
std::cout << value1 << ", " << value2 << ", " << *valueReference;<br />
}<br />
Actually I felt quite familiarly with references in C++, until I started thinking about this particular task.
|
|
|
|
|
Once a reference has bound with a variable, there is no way you can change one without changing the other. So your only option is to use a pointer.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi,
How can i get the handle of the timer by using timer ID of the multimedia timer under WIN32 environment.
Thanks in advance!
|
|
|
|
|
Hi Guys,
I have a void* Message pointer.
i wonder how can i print out the content of the memmory which be pointed by the void type pointer.
And is there any article introduce about the void* pointer in detail.
Thanks very much in advance!
|
|
|
|
|
A void * is a memory address, and you have no idea what is in it. YOu could turn it into a char pointer and thus iterate over the data a byte at a time. But you'll have no idea of it's type, or how long it is.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi Christian,
Thanks verymuch for your help!
there should be a string stored in side the memory address.
Is it possible i can direct cast the it to a string typ?
Many thanks
|
|
|
|
|
Yes, you can do a static_cast or a simple C style cast, just make sure you have valid string at the address, otherwise the thing will blow up at runtime.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
The following code sequence produces an "A" on stdout, and I cannot figure it out why. PLEASE help !
stringstream os;
string buf;
os.str("");
buf=os.str();
cout << buf << flush;
|
|
|
|