|
Man! That's harsh! I'd be like "Hey, my buddies are buying your food and besides you don't even sell pizza!!" Of course, it would not have worked out any better for me. I just like to be argumentative
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
I was well known there - I'd tried to get served in the drive through on foot by getting friends to make car noises while I ordered and holding a plate as a steering wheel.....
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Sounds like the Jamie Kennedy Experiment to me!
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
i hope you did not overturn the plate!
and Tom,if you say so,you propobly will tangle with the servents,maybe take a beating!and very likely badly battered!haha!
just make fun!
|
|
|
|
|
Tom Archer wrote:
"Hey, my buddies are buying your food and besides you don't even sell pizza!!"
I was at a McDonald's that sold pizza, I think it was somewhere in Kentucky; but that was 7 years ago.
James
Simplicity Rules!
|
|
|
|
|
I have been trying to optimise my screensaver, because when double buffering is turned on it slows right down. I create a bitmap and graphics object in memory, draw to that instead of the screen and in the paint method, draw the bitmap to the screen. There is too much action going on to try and draw only the changed bits. It's slower than turning on double buffering - how can this be ? What faster method for double buffering could exist ? I'm using graphics::drawimageunscaled, but I've tried drawimage.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
I think my next project is going to be a class that manages dirty rectangles.
But for a quickie, what happens if you only update the area that is needed in the OnPaint event (ie use the PaintEventArgs.ClipRectangle). I have a hunch that something is causing the Paint event to be fired outside of your Invalidate(false) so if you draw everything over again, a lot of that is wasted cycles because it will only get clipped off.
James
Simplicity Rules!
|
|
|
|
|
James T. Johnson wrote:
Invalidate(false)
Ok James, please fill me in on this, what does Invalidate(); do? I don't seem to find a *visible* method called Invalidate(); but I see people calling it.
Nick Parker
|
|
|
|
|
Invalidate is a method that comes from the Control class, calling Invalidate() or Invalidate(bool) forces the control to repaint itself and optionally its child controls.
The other overloads forces a repaint of only a specific area of the control and optionally its child controls.
The term comes from the Win32 API where a window was Invalid if a part of it needed repainting, calling Invalidate set it so the whole window needed updating or just a specific part of it.
James
Simplicity Rules!
|
|
|
|
|
|
I don't see what else would fire my paint message, but my resolution is (2x1280)x1024, and the *whole* screen needs to be drawn every time. There is stuff going on everywhere. If I run 800x600 it runs very nicely.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Would CachedBitmap help ?
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
I don't know - what does it do ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Sorry, I did a search for DrawCachedBitmap using the Graphics class from the .NET Framework and didn't find it, maybe is not implemented for .NET
anybody knows why is not exposed through the .NET Graphics class ?
<MyOriginalMessage>
From MSDN Help:
CachedBitmap Class
A CachedBitmap object stores a bitmap in a format that is optimized for display on a particular device. To display a cached bitmap, call the Graphics::DrawCachedBitmap method.
Remarks
A CachedBitmap object stores an image in a format that is optimized for a particular display screen. You cannot draw a cached bitmap to a printer or to a metafile.
Cached bitmaps will not work with any transformations other than translation.
When you construct a CachedBitmap object, you must pass the address of a Graphics object to the constructor. If the screen associated with that Graphics object has its bit depth changed after the cached bitmap is constructed, then the DrawCachedBitmap method will fail, and you should reconstruct the cached bitmap. Alternatively, you can hook the display change notification message and reconstruct the cached bitmap at that time.
Example Code [C++]
The following example calls DrawCachedBitmap to draw the image stored in a CachedBitmap object.
VOID Example_DrawCachedBitmap(HDC hdc)
{
Graphics graphics(hdc);
// Create Bitmap object.
Bitmap bitmap(L"Climber.jpg");
// Use the Bitmap object to create a CachedBitmap object.
CachedBitmap cachedBitmap(&bitmap, &graphics);
// Draw the cached bitmap.
graphics.DrawCachedBitmap(&cachedBitmap, 20, 10);
}
I've used it on a project, and it speed the things up (actually i'm not using it right now, see below)
But it's not as flexible as DrawImage (at least in C++, haven't tried it with c# yet)
</MyOriginalMessage>
|
|
|
|
|
Your second buffer needs to be in frame buffer memory. Then switching between the two frames is VERY VERY fast. Of course, if you aren't using OpenGL or DirectX, I have no idea how to do that.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Tim Smith wrote:
Your second buffer needs to be in frame buffer memory. Then switching between the two frames is VERY VERY fast. Of course, if you aren't using OpenGL or DirectX, I have no idea how to do that.
AFAIK only OGL and DX let you do that... Still waiting for DX 9 to come out for C# code support
James
Simplicity Rules!
|
|
|
|
|
Can anyone tell me how to change the screen resolution in C# ? How about for multiple monitors ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
When all else fails...
WIN32 API: ChangeDisplaySettings
|
|
|
|
|
So how do I get my hands on it in C# ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Christian Graus wrote:
So how do I get my hands on it in C# ?
P/Invoke I'm still recovering from shock though, the DEVMODE structure is HUGE. I remember seeing a tool that created P/Invoke code from the vb6 win32api.txt file, I'll see if I can find it again.
James
Simplicity Rules!
|
|
|
|
|
public const int CCHDEVICENAME = 32;
public const int CCHFORMNAME = 32;
[StructLayout(LayoutKind.Sequential)]
public struct DEVMODE{
[MarshalAs(UnmanagedType.ByValTStr,SizeConst:= CCHDEVICENAME)]
public string dmDeviceName;
public int dmSpecVersion;
public int dmDriverVersion;
public int dmSize;
public int dmDriverExtra;
public int dmFields;
public int dmOrientation;
public int dmPaperSize;
public int dmPaperLength;
public int dmPaperWidth;
public int dmScale;
public int dmCopies;
public int dmDefaultSource;
public int dmPrintQuality;
public int dmColor;
public int dmDuplex;
public int dmYResolution;
public int dmTTOption;
public int dmCollate;
[MarshalAs(UnmanagedType.ByValTStr,SizeConst:= CCHFORMNAME)]
public string dmFormName;
public int dmUnusedPadding;
public int dmBitsPerPel;
public int dmPelsWidth;
public int dmPelsHeight;
public int dmDisplayFlags;
public int dmDisplayFrequency;
}
[DllImport("user32.dll")]
public static int ChangeDisplaySettingsEx(
[MarshalAs(UnmangagedType.LPTStr)] string lpszDeviceName,
ref DEVMODE lpDevMode, IntPtr hwnd, int flags,
IntPtr lParam); This should work, but of course its untested and may need some tweaking here and there
James
Simplicity Rules!
|
|
|
|
|
Wow - that IS a monster....
What do I need to be using for it to work ? How do I get my hands on my hwnd to pass in ? What is lParam ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
The hWnd is stored in the Handle property of the Control (Form derives from Control).
lParam can be NULL (IntPtr.Zero) or it can be a pointer to a VIDEOPARAMETERS structure, which I didn't see the first time I looked at the docs.
Here's the help link I used in MSDN when looking up what was there (yes the Platform SDK still has a purpose )
ms-help://MS.VSCC/MS.MSDNVS/gdi/devcons_3tfc.htm
Here is the API Viewer tool which generated the structure me, you'll need the win32api.txt file from the common/tools/apiviewer directory on the VB6 CD.
Unfortunately the API Viewer doesn't have information about the VIDEOPARAMETERS structure, which means lots of fun On second look, I don't think you'll need the structure, its declared in tvout.h
James
Simplicity Rules!
|
|
|
|
|
I took a look at implementing what was required to change the display resolution *correctly* in C#. I ended up reverting to C++, and writing a set of helper classes in MC++. This was much, much easier and has much cleaner interface for other .NET languages.
I will post it when I have finished cleaning it up and testing it if you’re interested.
Regards
|
|
|
|
|
Ok, this is the scoop...
First you need to call "EnumDisplayDevices" to track down which displays you are interested in.
You then need to call "EnumDisplaySettings" for each device of interest to get a list of supported "modes" (X, Y Resolution, Frequency and color depth).
From those lists you can then perform a "ChangeDisplaySettingsEx" to change the actual settings.
Considering you most likely want to make the changes temporary, you can get the current settings for each device by calling "EnumDisplaySettings" with an iModeNum of ENUM_CURRENT_SETTINGS, before you change them.
Regards
|
|
|
|
|