|
C# or JavaME? Which one is better for pocket PC game development?
|
|
|
|
|
A lot of Java games run on mobile devices. but Java is slow,while C# maybe faster than Java. but it needs time proving.
fay
|
|
|
|
|
whatever you want, they both have their pros and cons. C# would be funner though.
/\ |_ E X E GG
|
|
|
|
|
Question Title: Marshalling Return type as LPArray
Author: ranadhir
Points: 80
Date: 06/17/2004 06:41PM PDT
I have a COM client calling invoking a function on a managed library.The interface definition is
[return :MarshalAs(UnmanagedType.LPArray,SizeParamIndex=0)] int[] returnTemperatureAsArray(out int cnt);
When i invoke is from ATL client as follows
long _elem;
long* ptemp=NULL;
ptemp=cpi->returnTemperatureAsArray(&_elem);
I get a runtime debugger error
*********************************************************************************************
The value of ESP was not properly saved across a function call.This is usually a result of calling a function declared with one calling convention with a function pointer decalred with a differenct calling convention.
**********************************************************************************************
I tried invoking the same function from a COM dll,and it works fine.Here is a excerpt from the type libraries (as viewd in oleview)
1.Managed typelib
interface IWeatherSink : IUnknown {
HRESULT _stdcall returnTemperatureAsArray(
[out] long* cnt,
[out, retval] long** pRetVal);
};
2.COM DLL typelib
interface ICheckFunctionCalls : IUnknown {
[helpstring("method returnLongAsArray")]
HRESULT _stdcall returnLongAsArray(
[out] long* pcount,
[out, retval] long** pArr);
};
However if i make the array a out parameter rather than a return type , it works fine.
What is wrong?Is this invocation not allowed from managed code?What should I do to make this invocation succeed?
|
|
|
|
|
COM decrees that you always return an HRESULT from a method or property. Automation clients like VB and, to some degree .NET, translate retvals to return values for you. This can be controlled with the PreserveSigAttribute (although that's for RCWs, not CCWs like you're using here). So your cpi->returnTemperatureArray call should accept an [out, retval] as the last parameter and return an HRESULT (which .NET will for you based on whether or not you thrown an exception, or if you preserve the signature and return an error or success code).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
If you care in the description on your "Custom String Formatting in .NET" there is a 't' floating around....
You might want to fix it... you know the short description under the title on the topish....
/\ |_ E X E GG
|
|
|
|
|
Thanks. I'll get that fixed.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
So what i understand is that there is no way that a function with the following signature
in a C# DLL ,can be invoked by a win32/ATL client
[return :MarshalAs(UnmanagedType.LPArray)] int[] returnTemperatureAsArray(out int cnt);
Why do i not get this error with the following then ?
[return : MarshalAs(UnmanagedType.LPStr)] string GetWeatherAsANSI();
This seems to work fine when invoked from a win32 client.
|
|
|
|
|
You can, but the CCW (COM-Callable Wrapper) changes the int[] return value into an [out, retval] parameter at the end of the method, as it should be in COM since all methods (including property getter and putters) should return an HRESULT .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
What is the fastest way to render raw image bits to a Bitmap Object? I am not allowed to use unsafe code.
|
|
|
|
|
You mean basically what you'd pass to CreateDIBSection in Windows GDI? Well, you must know a few things about the bitmap data, like the width and height, or even just the stride (how many bytes in a line). You also need to know the pixel format, such as whether the data represents a 32-bit bitmap, 24-bit, etc.
Fortunately, with this information GDI+ (and System.Graphics ) makes this easy. Use the Bitmap(int, int, int, PixelFormat, IntPtr) constructor, which takes the width, height, stride, pixel format, and a pointer to the raw data, respectively.
Read more about that constructor in the .NET Framework SDK for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
All I want to do is change the form1.Text property when I click a button?
Could someone provide me with a simple approach?
Thank you,
cb
|
|
|
|
|
form1.ActiveForm.Text = "Text goes here";
|
|
|
|
|
Thank you very much for your quick response.
I got hung up on using a "Layout" method and a few minutes ago figured out I needed a 'PerformMethod' call.
Arrrrrrrrrrrrrrrrgh! If I wanted to write that much code I'd do a novel.
Yours is a more straight fowrard approach and thanks.
BTW as a newbie ... you would'nt believe the Googling I did to try to resovle this apparently easy issue.
Issue closed, thanks again.
cb
|
|
|
|
|
You're Welcome.
I suggest getting a book, it will helpyou greatly to get started with C#.
|
|
|
|
|
How can I make sure my form stay on top of everything. I set the TopMostLevel to true, and it works when I work in windows. Then, I load a game and my form is hidden. Does the game take over the priority or what, and how do I change that?
Thanks
|
|
|
|
|
Games write directly to the screen buffer, not through GDI or GDI+ like Windows does. A system modal dialog would only appear atop a windowed-game, and good luck trying to find any decent ones these days.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
For me to write screen buffer, would I have to use DirectX or something of that sorts?
Thanks in advance.
|
|
|
|
|
You can, or you can P/Invoke the massive amount of APIs required to communicate with the display HAL, which doing in managed code (except, perhaps, Managed C++) would truly be a nightmare.
And just implementing DirectX won't necessary fix the problem: the game may not share its hold on the display device (or any other devices it's using). An exclusive lock may be used. Games like the older Everquest versions (according to my friend) did have such an exclusive lock and if you tried to circumvent the lock the game would crash and eventually your account would be locked out.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hey, I have a vertical splitter between two groupboxes but after i enabled
visualstyles in my application it doesnt work ok ,after i move it the
groupbox which is supposed to fill doesnt and i cant move the splitter any
more, Help , did anyone incounter this kind of problem?
|
|
|
|
|
Check if you set the "Align" property properly. When use splitter, you should set the "Align" property of the splitter as well as the groupbox.
|
|
|
|
|
thanks , but the splitter and groupbox dont have an align property.
|
|
|
|
|
Sorry, I make a mistake. It is the "Dock" property, not the "Align" property. See whether the codes below could work.
groupBox2.Dock = DockStyle.Fill;
splitter1.Dock = DockStyle.Left;
groupBox1.Dock = DockStyle.Left;
|
|
|
|
|
Does anyone know how, or seen a snippet/class for performing a name server lookup on a hostname? If you do and could share your knowledge that'd be appreciated.
|
|
|
|
|
Read about Dns.GetHostByName in the .NET Framework SDK. There's other helpful classes in the System.Net namespace you should read about as well.
Microsoft MVP, Visual C#
My Articles
|
|
|
|