|
Hello,
this might be a stupid question, but i haven't found an answer on either this forum or the MS knowledge base, so here is my problem:
On a PocketPC 2003 and using the Compact Framework, I want to create a copy from an image (an embedded resource 24bpp png), modify that copy and use it in subsequent redraws of a control (a class deriving from Forms.Control and overriding OnPaint ).
For this I use the copy-contructor of the Bitmap class (dstImage is a member of the control):
dstImg = new Bitmap(srcImage);
This seems to be a valid copy of the source image, dstImage.GetPixel returns color values identical to srcImage.GetPixel throughout, and the Width and Height properties show the expected image size. However, when I render that image to the control with
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawImage(dstImg, 0, 0);
e.Graphics.DrawImage(srcImage, dstImage.Width + 1, 0);
}
then the image is only about a quarter in size of what it should be. It is not truncated (and small enough to fit in the control entirely), but scaled down. Using srcImage in the above code does not exhibit this unwanted scaling. Please note that there is code ensuring that dstImage is only attempted to be drawn when its production is finished (omitted for brevity).
I've also tried to use different means of contructing dstImg , like
dstImg = new Bitmap(srcImage.Width, srcImage.Height, PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(dstImg);
Rectangle r = new Rectangle(0, 0, srcImage.Width, srcImage.Height);
g.DrawImage(srcImage, r, r, GraphicsUnit.Pixel);
g.Dispose();
A final note: this problem is specific to the compact framework. If I paste the above snippets in a 'full' framework app and run it, both original and copy show correctly. I suspect this behaviour might result from some mismatch of the DPI settings, however you can't seem to access these members (HorizontalResolution and VerticalResolution ) in the CF? What am I missing/doing wrong?
Any help and subtle pointers to possible stupidity on my part would be appreciated,
Georg
|
|
|
|
|
I hear about we can run .Net on Win98 but I just worry about the performance.
And Howabout Run .Net on Win95?
Because I have a hundred of client PCs (Pentium100, Ram32) and I love .NET, I don't want to build vb6 application for this new project.
wait for suggestion...
Thank you.
Regards,
------------------------------
Mr.Wigrom Sakonlapahb
.NET Application Developer
------------------------------
|
|
|
|
|
|
I am new to using Hooks, and am trying to write a process that will run through all processes that are running on a particular computer and for each one determine if there is a visible window and if that window has the focus. I am pretty sure that I will need to use a "Hook" to do this, however I have no clue where to begin. Does anyone have any suggestions as to where to start/what methods will be useful in determining this? Also, will this be possible using the Process class?
|
|
|
|
|
Jeffrey Richter wrote a program to enumerate running processes and return information on them in his book, "Programming Applications for Microsoft Windows". The application was called ProcessExplorer, and was written for Windows 2000 (pre-.NET). You could use the same methods and do it all with Platform Invoke.
|
|
|
|
|
Hell!
I'm a student of computer who liked C,C++ very much so,in order to preogram under windows selected MFC C++,however not long after I got more familier with VC++ 6, I heard news about .NET.
I started looking at it's best languages including C# and Managed C++.
But Most of them disapointed me! I belive most of them are more like "Borland Delphi" to C++.
I wanted to ask code project programmers following questions: will all others move to .Net? Will "MFC like" programming die? Is Microsoft going to lose her C++ programmers?
I know it's too late to ask these questions:zzz: but it's late because I was trying to learn at least one PL from .Net and now I see it's not a lovely work!
Hamed
|
|
|
|
|
Hamed Mosavi wrote:
I belive most of them are more like "Borland Delphi" to C++.
That's not surprising - Microsoft hired the guy that created Delphi to create C#
Hamed Mosavi wrote:
will all others move to .Net?
Not all, no. Althought I think that many people will still make the move.
Hamed Mosavi wrote:
Will "MFC like" programming die?
I don't understand what "MFC like" programming is. MFC (Microsoft Foundation Classes) is a framework that sits on C++ that allows you to create various types of applications. The .NET Framework is similar but it is used by managed languages, such as C#, VB.NET or Managed C++, that allows you to build various types of applications.
Hamed Mosavi wrote:
Is Microsoft going to lose her C++ programmers?
No. There are many things that cannot be written in a managed language. There are many applications that have been evolving for years in C++ that won't be re-written for C# as C# has various interop abilities in order to allow legacy applications to integrate.
Hamed Mosavi wrote:
I was trying to learn at least one PL from .Net and now I see it's not a lovely work!
It depends on your point of view. I switched in 2001 to .NET and I love it. I love the ease that I can create applications. I love that it allows me to integrate with older software. I love the fact that writing code that queries databases is so much easier that it was.
Cada uno es artifice de su ventura
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and Forums
|
|
|
|
|
I totally agree. For all its problems, .NET shines because of the BCL. It simply lets users program at a higher level. It's been very well designed too. The number of times I've expected a method to be in a certain class, only to find it precisely there with the same name, it's really stunning.
Regards
Senthil
My Blog
|
|
|
|
|
Hi,
Thanks alot for your answers.
I think my weak English once again made some problems,Sorry!;P
When I say "MFC Like!!" I mean : when I want to write a new app, I go towards New MFC Project, Select the type (Single Doc,...) and have a template to work on.
one more thing: You mentioned that you moved to .Net because it's easier. "I love the ease that I can create applications"
Could you tell me please how is it easier when there is not any editor for creating dialogs, any single doc or multiple doc template, however I found "form creator template".
Finally if you want the fact, the reason that I didn't move to Delphi when I started learning a Visual Language was that I hated Delphi, and that was one of the best reasons I selected VC++! Now!!
once again I appreciate you for your acswers and excuse me if my english is very bad!
|
|
|
|
|
Hamed Mosavi wrote:
Could you tell me please how is it easier when there is not any editor for creating dialogs
There is an excellent editor for creating dialogs, they are called Forms now. You can have it act as a dialog by using ShowDialog() instead of Show() when you are ready to display it to the user.
Hamed Mosavi wrote:
any single doc or multiple doc template
.NET doesn't have this structure, however there is nothing to stop you from building it. You can create your own set of control classes that can operate like the old View classes and you can create your own document class to hold the data. However, you do have to do a little more work. But, since moving to .NET I've never found that I missed the old Document/View structure at all. In fact, I've found that the new flexibility that .NET offers to be much better as it doesn't constrain you into one way of thinking.
Hamed Mosavi wrote:
the reason that I didn't move to Delphi when I started learning a Visual Language was that I hated Delphi
That's fine. I don't like Delphi either.
Hamed Mosavi wrote:
and that was one of the best reasons I selected VC++! Now!!
I'm not sure what the "Now!!" means at the end of that statement.
Hamed Mosavi wrote:
excuse me if my english is very bad
Your English is actually quite good - I've seen worse written by people who are supposed to have English as a first language.
Cada uno es artifice de su ventura
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and Forums
|
|
|
|
|
Hi Mr. Colin Angus Mackay
Thank you so much , you gave me alot of very good information and ofcourse more confidence to move to .Net.It's extremely kind of you, and I can't find the appropriate world to express my thanks.
For the last question in this conversation(from my side!!;P), could you tell me please, as you seems to have lots of experiences in .Net, witch language do you prefer?
Moving to C# and starting from the start!!, or moving to Managed code (or C++/CLI).
I must thank you once again for your nice patiance(you would be like to me now!!)
Best regards, Hamed Mosavi
|
|
|
|
|
|
Thanks alot Mr. Colin Angus Mackay
for your nice answers.
It was all very helpfull.
Best regards
|
|
|
|
|
Un belivable?
Did you know this?!!
Visual C++ has always been the best language for creating high-performance applications for Microsoft Windows and the World Wide Web.
This is from MSDN , while tring to compare programming languages!! (MSDN 2004, Programming Languages)
Is it tring to say that it's still the best one?
|
|
|
|
|
I think so, after all C++ is native language for Windows (at least current and previous versions). C++ apps of course beat apps written in managed languages in terms of execution spead; it beats VB, Object Pascal etc. (what else use to write win apps? Visual Prolog maybe ) as well.
You must imagine emphasis on high-performance Personally, I'd use C++ in cases where is superior performance is needed (like processing HUGE data, calculations, 3D games...) and C#/.NET for Web Apps (ASP.NET is by far the best "tool" for web application I ever used) or Windows applications with classical UI. I find much easier and more efficient to do UI-oriented apps with .NET then with C++/WIN32API/MFC.
Hamed Mosavi wrote:
Is it tring to say that it's still the best one?
yes. When performance is issue #1.
just my 2 cents
David
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
Hamed Mosavi wrote:
Moving to C# and starting from the start!!, or moving to Managed code (or C++/CLI).
c# is managed code, isn't it?
|
|
|
|
|
I'm sorry
Managed C++
|
|
|
|
|
Hi, everyone,
I have a question when I use the following code to get the response.
WebRequest req = WebRequest.Create(sURL);
try
{
WebResponse result = req.GetResponse();
}
catch(Exception){}
the code works very well on my XP, but when I run it under Windows server 2000, or some others PC, I sometimes get the exception:
The underlying connection was closed: The server committed an HTTP protocol violation.
it comes with the code GetResponse(). But when I use IE try the Url, IE works.
Would you please tell me why that is happened, and How to avoid/fix that, so I can read the response.
Thanks a lot in advance!!
Alan Shen,
Alan Shen
MCAD for .NET Version
^~^~^~^~^~^~^~^~^~^~^
Great idea is the beginging of success!
|
|
|
|
|
Anyone knows why the following code doesn't work:
typedef CArray< CPoint, CPoint* > CPointArray;
Thanks.
|
|
|
|
|
Hello,
I have a problem with the PrinterSettings.Collate property I receive from a PrintDialog. It always seems to return false. I've tried it with a standalone application that does nothing but show the PrintDialog and return the Collate property afterwards. Is this a known bug, and if so, is there a workaraound for the problem?!
Thx klawipo
|
|
|
|
|
I have an application that communicates with the server program through a shared text file, located at a network directory. The server writes to the text file which my application reads. I am using FileSystemWatcher to monitor this file.
Now when server writes to the file, change event in my application fires after 2 or 3 seconds. However when I manually change this file and save it, it acts the ideal way. I want to reduce this time delay as this should act like realtime system.
My C# code goes like this :
-------------------------------------------------------------------
public MyWatcherClass()
{
watcher = new FileSystemWatcher();
this.watcher.Path = this.MyNetworkDrive;
this.watcher.NotifyFilter = NotifyFilters.Size;
this.watcher.Filter = this.MyTextFile;
this.watcher.Changed += new FileSystemEventHandler(OnChanged);
this.watcher.EnableRaisingEvents = true;
}
-------------------------------------------------------------------
What am I missing?
Thanks in advance
|
|
|
|
|
I remember asking this a while ago and getting an answer *cough* David Stone *cough*, but for the life of me I can't remember how to do it.
I have a Bitmap object, from which I can get the RawFormat. Is there a way I can get a friendly name, such as "JPEG", from the ImageFormat object without having to hard-code a lookup table or writing a clunky lookup function that enumerates the Decoders on the system? IIRC, you can do it in one line.
Thanks,
|
|
|
|
|
Hi,
I download the .NET Framework Version 1.1 Redistributable Package in the station, but when I try to run a .NET C++ application I got an error message
"Application has generated an exception that could not be handled."
The same application runs fine in my development station which has the full Visual Studio .NET installed. (It was ver. 1.0, but I also downlod the .NET Framework Version 1.1 Redistributable Package and SDK 1.1 as well).
Does anyone know what else I have to do to run the application outside of the development station?
Thank you in advance for your help.
|
|
|
|
|
I found out that I have to download NET Framework Version 1.0 Redistributable Package to run the application. After I did that, it works fine.
|
|
|
|
|
Depending on what your application does you might be missing a library assembly (DLL) needed, especially if you are getting the exception when the program is loading. Check the dependencies on your development machine. (If you build a deployment package using VS these any assemblies your application depends on should be packaged in the MSI automatically.)
If that's not it you might try adding an application thread exception handler of your own in an effort to get more information on just what exception is being thrown. For example, in your Main method (but before Application.Run()):
Application.ThreadException += new ThreadExceptionEventHandler(ApplicationThreadException);<br />
Then a simple handler:
static void ApplicationThreadException(object sender, ThreadExceptionEventArgs e) {<br />
string msg = <br />
"A problem has occurred while running CAPA Facilitator:\r\n" +<br />
"\t" + e.Exception.Message + "\r\n\r\n" +<br />
"Would you like to continue running CAPA Facilitator so that\r\n" +<br />
"you can save your work?";<br />
DialogResult result = MessageBox.Show(msg, "Unexpected Error", MessageBoxButtons.YesNo);<br />
<br />
if (result == DialogResult.Yes) {<br />
return;<br />
}<br />
Application.Exit();<br />
}<br />
This will display the exception error message in a dialog befor closing the program, which could provide clues to what's going on.
Hope this helps.
Mitchell
|
|
|
|
|