|
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;
|
|
|
|
|
How to arrange message sending and getting for example in MDI windows forms app I need to send a custom message WM_USER+1 or something from child to parent and to get it in parent. Something like in VC++ ON_MESSAGE(...) macro is it possible in windows forms, please give a snippet of code
9ine
|
|
|
|
|
|
ok here is what I need to to.
I have a system.string, and I would like to write to file. for this I thought I was gonna use fputs(). the prob is it must be a const char * and not some sort of string. I managed to convert it to __wchar_t __gc[] but this is not what I need.
thank you
|
|
|
|
|
quarry_06 wrote:
fputs().
Why are you using C file handling ?
quarry_06 wrote:
__wchar_t __gc[]
.NET uses Unicode strings, so you're going to need to convert from Unicode to ASCII if you want to use a char *.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
can u point me to a quick introduction of .net file handling with c++
thank you
|
|
|
|