|
can i type caste WPARAM and LPARAM into Int32 or not.
is there any lose of values;
<big><small></small></big> Int32 wp=(Int32)wParam;
Int32 lp=(Int32)lParam;
is there any lose of value if i get wParam,lParam like that?
WPARAM wParam=(WPARAM)wp;
LPARAM lParam=(LPARAM)lp;
r00d0034@yahoo.com
|
|
|
|
|
try it. find out.
"[it was..] one of those evenings when you feel that not only will there definitely be a revolution, but that the Association of Manufacturers will foot the bill."
-- Umberto Eco, Foucault's Pendulum
|
|
|
|
|
i chec it but i could not find ?
plz u tell
r00d0034@yahoo.com
|
|
|
|
|
Don't be so stupid.
I really worry when someone is here for so long and continues to post the most basic questions over and over. Are we failing him by answering ? Would he learn if he had to ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
If you look deep in the bowels of the Platform SDK, you'll see the definition of LPARAM and WPARAM. You'll see that WPARAM is an unsigned integer , while LPARAM is a long . Int32 can handle them because as the .NET C++ reference states: "The size of a signed or unsigned int item is the standard size of an integer on a particular machine. For example, in 16-bit operating systems, the int type is usually 16 bits, or 2 bytes. In 32-bit operating systems, the int type is usually 32 bits, or 4 bytes. Thus, the int type is equivalent to either the short int or the long int type, and the unsigned int type is equivalent to either the unsigned short or the unsigned long type, depending on the target environment." I would take that to mean since .NET isn't 16-bit, that you're pretty safe;]
http://www.ian-space.com/
|
|
|
|
|
i saved lparam and wparam values when a key
(say U)pressed on a perticuler edit box.
i want to use these values of lparam and wparam again on different edit box.in order to see that key
(say U) .
i have to type caste wparam and lparam into int32 thats why i have type caste into WPARAM and LPARAM.
is that code is correct or not for that purpose?
is there any change in logic if yes then plz tell?
LPEVENTMSG lpEvent= (LPEVENTMSG)lParam;
PostMessage(different_hWnd,
lpEvent->message,(WPARAM)wParam,(LPARAM)lParam);
r00d0034@yahoo.com
|
|
|
|
|
Why do you ask the same questions over and over, just rewording them ?
I'd like to know why you want to control/hijack the login process. I'm not going to give any more help on this neverending quest of yours unless I am convinced it does not have a malicious intent.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Hi!
I have a C++ class with a callback function. Now I wanna use this class in .NET enviroment. So according the guide, i wrap it in a managed class.
But the problem is the callback. The unmanaged class must have an ability to callback the managed class. How can the callback function in unmanaged class get the pointer of the delegate(or something like that) of the managed class?
any suggestion?
|
|
|
|
|
|
Is there a way to change the text of a hyperlink in an RTF textbox without altering where the link leads to? For instance, changing links in a block of text to read 'click here' instead of displaying the actual link? I have gone from one end of MSDN to the other as well as every scrap of .NET documentation I can find, and still can't figure this one out. The proggie I'm writing is all .NET so far, and I'd rather not 'mix and match'
|
|
|
|
|
Hi folks
Re: ADO.NET : SqlDataReader : I need to assign retrieved value to C++ variable
I have found the source of the problem expressed in the thread "ADO.NET : SqlDataReader : I need to assign retrieved value to C++ variable":
http://www.codeproject.com/script/comments/forums.asp?forumid=3785#xx309754xx
but do not yet know why it occurs or how I can fix it.
The problem arises with the /clr compiler setting.
Here is the code to illustrate this:
/////////////////////////////////////////////////////////
#include <stdafx.h>
#include <cstdlib>
#include "try_ADONET.h"
//#using <mscorlib.dll>
//#using <system.dll>
//#using <system.data.dll> // This is required for the ADO.NET Provider
using namespace std;
//using namespace System;
int Main()
{
CString busNumberSQL[2];
CString bus = "Hello";
busNumberSQL[1] = bus;
return 0;
}
////////////////////////////////////////////////////////
Without the /clr setting the array of CString busNumberSQL[2] is correctly contructed as is CString bus and the line
busNumberSQL[1] = bus;
works as expected. This can be seen by putting a breakpoint in at
return 0;
and seeing the variables in a Watch. Copy the expanded Watch details (Name, Value & Type) to an EXCEL sheet.
..................
Next, add the compiler switch /clr and rerun the code.
CString bus is constructed correctly BUT something weird happens in the construction of CString busNumberSQL[2].
Now,
busNumberSQL[1] = bus;
results in the address of bus as an integer being assigned to busNumberSQL[1], and look at the Watch details!!
Copy the expanded Watch details (Name, Value & Type) to an EXCEL sheet
Name: busNumberSQL; Value: {Length=2}; Type: ATL::CStringT<char,strtraitmfc<char,atl::chtraitscrt<char> > >[] ...(Note no dimension at end compared to the "no /clr" case.
Next Watch line: [0] 2083454756 __int32
Next Watch line: [1] 3103464 __int32
My conclusion is that busNumberSQL[2] is not an array of CString.
Of course, I need the /clr in order to use ADO.NET!
It seems as though a CString works, but a CString array for some (unknown) cannot even be defined.
Do you have any light for me? (I have not got into your previous post yet on Marshall)
Best regards
Doug.
(In case you are wondering I am very much a beginner with C++ and .NET)
Doug
|
|
|
|
|
Hello Doug
I compiled and ran this program successfully.
<br />
#include <Stdafx.h><br />
#include <cstdlib><br />
#include <atlstr.h><br />
<br />
#using <mscorlib.dll><br />
#using <System.dll><br />
#using <system.data.dll><br />
<br />
using namespace std;<br />
using namespace System;<br />
<br />
int main()<br />
{<br />
CString busNumberSQL[2];<br />
CString bus = "Hello";<br />
busNumberSQL[1] = bus;<br />
Console::WriteLine(busNumberSQL[1]);
return 0;<br />
}<br />
I have no idea why it's not working on your box.
Regards,
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Nish
Thanx
You are correct
Console::WriteLine(busNumberSQL[1]); //shows "Hello" on my console
works, as does
cout << "busNumberSQL[1] = " << static_cast<lpctstr>(busNumberSQL[1]) << endl;
Just a pity you cannot, in this case set up the Watch window as a debugging tool by itself.
Here is what someone wrote :
Quote
I see what you are talking about. Although it is not really a problem but just the way managed code and the CLR interacts with unmanaged code. When you use unmanaged code such as the case with the CString object in your example, and compile with the /clr, the managed executable makes references to the unmanaged objects internally using pointers to its memory location which falls outside the GC managed memory pool. As you have noticed when placing a watch on the unmanaged CString objects which show up as a __int32 type with a value that points to a memory address.
There is nothing wrong with the example you gave in your email. The program still compiles, and the results it produces is as expected. The nice thing with C++.Net is the power of mixing managed and unmanged code in one executable. The power does not come without a price and that is your managed executable with parts unmanaged code, has the same risks as a completely unmanaged executable. The CLR does not offer any protection or resource management to unmanaged objects. So, use the power carefully.
using your example above, if you add to following line to your code you'll see that it still produces the expected results.
Console::Writeline (busNumberSQL[1]);
or even,
printf ("%s",busNumberSQL[1] );
Unquote
http://www.codeproject.com/managedcpp/adonet_mcpp.asp?msg=311206#xx311206xx
Regards
Doug
Doug
|
|
|
|
|
Correction:
cout << "busNumberSQL[1] = " << static_cast(busNumberSQL[1]) << endl;
should read:
cout << "busNumberSQL[1] = " << static_cast<lpctstr>(busNumberSQL[1]) << endl;
PS.
Apologies for the multiple post - the error of my way has been pointed out to me and will not happen again.
Doug
|
|
|
|
|
I can get the following to work, the result displaying on the screen:
Console::WriteLine(myReader->GetSqlValue(3));
What I really need to do is to assign the item retrieved to a C++ variable eg.
int halfhrSQL = myReader->GetSqlValue(3);
This gives the C2440 compile error: cannot convert from 'System::Object __gc *' to 'int'.
No matter what cast I use, I cannot get around the error.
Please help if you can.
Thanks, Doug (New Zealand)
Doug
|
|
|
|
|
|
Hi Nish
Thanks very much for pointing me in the right direction!
I now have the code working:
int halfhrSQL = Convert::ToInt32(myReader->GetValue(3));
It took me a while too find out I had to use GetValue().
Not GetSqlValue(3).
Not GetSqlInt32(3).
Not GetData().
Not GetInt32().
The above compile but throw the following exception:
"System.InvalidCastException : Specified cast is not valid at System.Convert.ToInt32(Object value)"
Best regards
Doug
Doug
|
|
|
|
|
Doug if you are still having a problem you might want to read this[^]
article from MSDN, especially the remarks.
Nick Parker
The greatest lesson in life is to know that even fools are right sometimes. - Winston Churchill
|
|
|
|
|
Thanks everyone, problem solved!;)
Doug
|
|
|
|
|
Hi Nick
Re: ADO.NET : SqlDataReader : I need to assign retrieved value to C++ variable
I have found the source of the problem expressed in the thread "ADO.NET : SqlDataReader : I need to assign retrieved value to C++ variable":
http://www.codeproject.com/script/comments/forums.asp?forumid=3785#xx309754xx
but do not yet know why it occurs or how I can fix it.
The problem arises with the /clr compiler setting.
Here is the code to illustrate this:
/////////////////////////////////////////////////////////
#include <stdafx.h>
#include <cstdlib>
#include "try_ADONET.h"
//#using <mscorlib.dll>
//#using <system.dll>
//#using <system.data.dll> // This is required for the ADO.NET Provider
using namespace std;
//using namespace System;
int Main()
{
CString busNumberSQL[2];
CString bus = "Hello";
busNumberSQL[1] = bus;
return 0;
}
////////////////////////////////////////////////////////
Without the /clr setting the array of CString busNumberSQL[2] is correctly contructed as is CString bus and the line
busNumberSQL[1] = bus;
works as expected. This can be seen by putting a breakpoint in at
return 0;
and seeing the variables in a Watch. Copy the expanded Watch details (Name, Value & Type) to an EXCEL sheet.
..................
Next, add the compiler switch /clr and rerun the code.
CString bus is constructed correctly BUT something weird happens in the construction of CString busNumberSQL[2].
Now,
busNumberSQL[1] = bus;
results in the address of bus as an integer being assigned to busNumberSQL[1], and look at the Watch details!!
Copy the expanded Watch details (Name, Value & Type) to an EXCEL sheet
Name: busNumberSQL; Value: {Length=2}; Type: ATL::CStringT<char,strtraitmfc<char,atl::chtraitscrt<char> > >[] ...(Note no dimension at end compared to the "no /clr" case.
Next Watch line: [0] 2083454756 __int32
Next Watch line: [1] 3103464 __int32
My conclusion is that busNumberSQL[2] is not an array of CString.
Of course, I need the /clr in order to use ADO.NET!
It seems as though a CString works, but a CString array for some (unknown) cannot even be defined.
Do you have any light for me? (I have not got into your previous post yet on Marshall)
Best regards
Doug.
(In case you are wondering I am very much a beginner with C++ and .NET)
Doug
|
|
|
|
|
Thanks Nish,
I have definitely got this working where the native C++ type is int and I am confident that I can now handle any numeric type.
What I am battling with is where the .NET value retrieved is a String (the SQL field is text).
I have managed to get the following to work:
String* busNumberSQL __gc[] = new String* __gc[97];
short halfhoursSQL = 0;
.
.
.
Console::WriteLine(myReader->GetString(0));
halfhoursSQL++;
busNumberSQL[halfhoursSQL] = Convert::ToString(myReader->GetValue(0));
However busNumberSQL is a managed array of type String*.
Now I need assign the value of busNumberSQL[halfhoursSQL] to a CString or native C++ string type. All I seem to end up with is the decimal representation of the hexidecimal memory address.
I have also tried:
Convert::ToChar(myReader->GetValue(0)) to assign one character
(Convert::ToString(myReader->GetValue(0)))->ToCharArray()
As I continue to try different things, do you have any idea how this may be done? I will let you know if I crack it.
(With the old ADO I was able to do this by doing a double cast: ---> _bstr_t --> LPCTSTR and then doing a simple assignment to a CString)
Thanks and regards
Doug
Doug
|
|
|
|
|
Hi Nish
Re: ADO.NET : SqlDataReader : I need to assign retrieved value to C++ variable
I have found the source of the problem expressed in the thread "ADO.NET : SqlDataReader : I need to assign retrieved value to C++ variable":
http://www.codeproject.com/script/comments/forums.asp?forumid=3785#xx309754xx
but do not yet know why it occurs or how I can fix it.
The problem arises with the /clr compiler setting.
Here is the code to illustrate this:
/////////////////////////////////////////////////////////
#include <stdafx.h>
#include <cstdlib>
#include "try_ADONET.h"
//#using <mscorlib.dll>
//#using <system.dll>
//#using <system.data.dll> // This is required for the ADO.NET Provider
using namespace std;
//using namespace System;
int Main()
{
CString busNumberSQL[2];
CString bus = "Hello";
busNumberSQL[1] = bus;
return 0;
}
////////////////////////////////////////////////////////
Without the /clr setting the array of CString busNumberSQL[2] is correctly contructed as is CString bus and the line
busNumberSQL[1] = bus;
works as expected. This can be seen by putting a breakpoint in at
return 0;
and seeing the variables in a Watch. Copy the expanded Watch details (Name, Value & Type) to an EXCEL sheet.
..................
Next, add the compiler switch /clr and rerun the code.
CString bus is constructed correctly BUT something weird happens in the construction of CString busNumberSQL[2].
Now,
busNumberSQL[1] = bus;
results in the address of bus as an integer being assigned to busNumberSQL[1], and look at the Watch details!!
Copy the expanded Watch details (Name, Value & Type) to an EXCEL sheet
Name: busNumberSQL; Value: {Length=2}; Type: ATL::CStringT<char,strtraitmfc<char,atl::chtraitscrt<char> > >[] ...(Note no dimension at end compared to the "no /clr" case.
Next Watch line: [0] 2083454756 __int32
Next Watch line: [1] 3103464 __int32
My conclusion is that busNumberSQL[2] is not an array of CString.
Of course, I need the /clr in order to use ADO.NET!
It seems as though a CString works, but a CString array for some (unknown) cannot even be defined.
Do you have any light for me? (I have not got into your previous post yet on Marshall)
Best regards
Doug.
(In case you are wondering I am very much a beginner with C++ and .NET)
Doug
|
|
|
|
|
I'm using a purchased unmanaged library that controls some hardware and throws a windows event (returning an event HANDLE)when the hardware is ready. I'd like to use this event to update my windows form. Is there any way to marshall the event HANDLE to a .NET event?
|
|
|
|
|
Hi.
I want to use WMI functions in a managed C++ project. I have found these functions and classes are defined in the wbemdisp.tlb, but I have not managed to include this library in my class.
In VB.NET I just had to add a reference to the library, so I ought to be possible in C++ as well, but how?
Best regards
/EnkelIk
|
|
|
|
|
See System::Management namespace. It wraps WMI.
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|