|
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
|
|
|
|
|
I need to do this in MC++ right ? I've never used MC++ before - could be interesting...
Thanks
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
|
|
|
|
|
Don't need to, I already coded up a set of classes to do this.
I used MC++ because, I am very familiar with C++ and it was allot faster than attempting to translate all of the API calls and structures involved to C#. As an added benefit, the MC++ classes are a seamless interface to C# or the *other* .NET languages.
Shoot me your e-mail address at vannote@netaxs.com and I will drop the project off as soon as I feel that it's ready...
Regards
|
|
|
|
|
Anyone know how to change the available client area of a .NET Framework Form ?
I have tried intercepting the WM_NCCALCSIZE message, but this doesn't
do what was expected.
Anyone got any suggestions, or even working examples of WM_NCCALCSIZE ?
|
|
|
|
|
Just set the ClientSize property on the form to the desired size
Much easier than standard win32
James
Simplicity Rules!
|
|
|
|
|
I was playing around last night and had done something like this:
protected override void WndProc(ref Message m)
{
MessageBox.Show(m.Msg.ToString());
}
I got a series of messageboxes (about 2 or 3) and then I received an error stating that it was able to create a handle, that, did I just need something like this to still allow it to call the base constructor?
protected override void WndProc(ref Message m)
{
MessageBox.Show(m.Msg.ToString());
base.WndProc(ref m);
}
I'm just playing with this anyone, so it doesn't really matter, just curious.
Nick Parker
|
|
|
|
|
.Net framework class library Control.WndProc method
Notes to Inheritors: Inheriting control should call the base class's WndProc method to process any messages that they don't handle.
I guess they say so.
- Gile
|
|
|
|
|
You know sometimes it is so damn clear that it doesn't make sense right away, why should I have thought that it would just fall though and continue on its merry way. Thanks.
Nick Parker
|
|
|
|
|
Hi,
I wanna customize the draw method of Datagrid, for example inorder to show the records which have a field (i.e. Salary) More then 50,000 in red BackColor and the others in white.
I don't know if you are familiar with delphi It use to have a OnCustom Draw Event that would deal with it. Do we have sth like that here?
thanks
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
It looks like what you need to do is create a class that inherits from DataGridColumnStyle (or better System.Windows.Forms.DataGridTextBoxColumn) and override the Paint methods.
HTH,
James
Simplicity Rules!
|
|
|
|
|
hi,
all
In c#, how can I get an running instance of a com object
instead of creating a new instance.
Can System.Activator implement it??
thx.
Regards.
Marion
|
|
|
|
|
|
when i am using msflexgrid component in vs.net in windows2000 server enviroment,i can not even put the control to the designing form.it display "you have not the activex control license"!or "The ActiveX control cound not be instantiated because it requires a design-time license "。
why?
how can i register the activex control?
i am a novice,i think to many people here,it's not a difficult question!so please help me !thanks!!
|
|
|
|
|
zhoujun wrote:
when i am using msflexgrid component
I wasn't aware that Microsoft still keep the msflexgrid in the Visual Studio.NET package, or are you adding it in another way?
Nick Parker
This is a non-Calculus course as long as you know things like line integrals and surface integrals...
|
|
|
|