The control appereance in a Graphics or Bitmap object.

  • Thread starter Thread starter Hamed
  • Start date Start date
H

Hamed

Have I posted the message to wrong newsgroup?

Or

Does the question is so much strage?

Would someone please kindly direct me to a true newsgroup or resource?

Best Regards
Hamed
 
Hamed,

If you don't get an answer than has repeatly asking why that is no result.
You see that in these newsgroups many people try to help as much as
possible. The reason should therefore be in your own question.

There is a chance that nobody (at least for that message me) don't
understand what you are asking.

Better is than to rephrase your message again in the same thread.

As well do people avoid persons who don't give any reaction on replies,
because often people place a question and don't pay any attention than
anymore to the given answers and the work that has done by that..

This kind of messages you write now is without sence and not liked in
newsgroups, what can give the result that you get not any answer anymore.

I hope this gives some help,

Cor
 
If you want a Bitmap of the Control, call the DrawToBitmap method.Create a
Bitmap of the same size as the Control, and call the DrawToBitmap method,
passing the Bitmap, and the Bounds of the Bitmap to it.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

Orange you bland I stopped splaying bananas?
 
Cor

I am partially new in using newsgroups. sorry if this bothered you or any
other here. I just wanted to know if I am sending the question to a wrong
place or not. this is the case.

Anyway, I try to describe the problem in both threads further:

I am developing a ColumnStyle that holds a custom control ( a button or a
numeric up down or something else )

I want to make a property that if set to true (I name it Sparse property)
all cells of the grid is painted by the face of that control. Since we
should implement the Paint method, I want to be able to paint the face of my
custom control in the grid.

Now what is the solution for the above problem?

Regards
 
Hamed,

It becomes more clear, only there are AFAIK 5 types of Grid's in dotNet,
which one is the one you want to inherit? Not that I know it, but I know
active people in this newsgroup who have done a lot with this kind of stuff.

Cor
 
Kevin

Thanks for suggestion but this method is new in the .NET Framework version
2.0

Unfortunately I am using .NET Framework version 1.1

Is there a solution for me in .NET Framework version 1.1 ?

Regards
 
Hamed,

Maybe you can find on this page some stuff that can help you. (It is VB but
that is for most people easily to translate in C# stuff, as far as I could
see is there in the code no part of the VB extensions on the framework
used).

http://www.vb-tips.com/dbpages.aspx?ID=be297475-5e55-4827-a382-d85153e86736

And you were right, you missed the most propitiate newsgroup for this
question.

Microsoft.public.dotnet.framework.adonet
and the special datagrid newsgroups, but those are mainly inactive.

As I wrote this is not my stuff, Ken is active in the VB newsgroups and
forums, as you ask it there as well, will your question than of course be
answered as well in VB code.

I hope this helps,

Cor
 
Cor

I need simply a sparse property that I want to make in my inherited
DataGridColumnStyle class

What you mentioned is a DataGrid ColumnStyle that shows images. The code the
I need is to make the bitmap from the control.

Suppose I have a hidden TrackBar that I want to show in the column of the
DataGrid. I want to make a Bitmap object from the TrackBar (that is hidden)
and paint the Bitmap in each cell.


How can I make a Bitmap object from the appereance of the control?


Regards
 
Hamed,

As I said it is not my code, but a quick look in it shows me this. (I have
made two conversions to C# to show how easy it is to read VB as C# the rest
is almost adding some (), {} and the ; and removing the end clauses.

Dim bm As Bitmap
In C# this is
Bitmap bm;

If TypeOf objData Is String Then
Dim fs As New FileStream(objData.ToString,
FileMode.Open)
in C# this is
FileStream fs = new FileStream(objDataToString, FileMode.Open);

bm = CType(Bitmap.FromStream(fs), Bitmap)
fs.Close()
Else
Try
bm = ConvertToBitmap(DirectCast(objData, Byte()),
78)
Catch
bm = ConvertToBitmap(DirectCast(objData, Byte()), 0)
End Try
End If
Dim h As Integer
Dim s As Double

Here is an image converted to a bitmap, so in my idea should using a bitmap
direct not change this code very much. However as I said in other words
already, bitmaps are not my favorite sport.

Cor
 
I know VB as well as C#. But the VB code does not show how to make a Bitmap
object from current face of a Control such as a TrackBar, CheckBox, etc.
 
Hamed,

This is what i use to create a bitmap from a control:

Private Function _renderImageFromControl(ByVal control As
System.Windows.Forms.Control) As System.Drawing.Bitmap

' Get this form's Graphics object.
Dim me_gr As System.Drawing.Graphics = control.CreateGraphics()
' Me._axFramerControl.CreateGraphics

' Make a Bitmap to hold the image.
Dim bm As New System.Drawing.Bitmap(control.ClientSize.Width,
control.ClientSize.Height)
Dim bm_gr As System.Drawing.Graphics =
System.Drawing.Graphics.FromImage(bm)
Dim bm_hdc As IntPtr = bm_gr.GetHdc

' Get the form's hDC. We must do this after
' creating the new Bitmap, which uses me_gr.
Dim me_hdc As IntPtr = me_gr.GetHdc

' BitBlt the form's image onto the Bitmap.
BitBlt(bm_hdc, 0, 0, control.ClientSize.Width,
control.ClientSize.Height, me_hdc, 0, 0, SRCCOPY)

me_gr.ReleaseHdc(me_hdc)
bm_gr.ReleaseHdc(bm_hdc)

' Return the result.
Return bm

End Function

Hope this helps.

Cheers,
Rob
 
I tried to use it in VB.NET but it seems somehow you should define BitBlt
function in VB.NET too.
 
Hamed,

Sorry forgot to include this code:

Private Declare Auto Function BitBlt Lib "gdi32.dll" (ByVal hdcDest
As IntPtr, ByVal nXDest As Integer, ByVal nYDest As Integer, ByVal
nWidth As Integer, ByVal nHeight As Integer, ByVal hdcSrc As IntPtr,
ByVal nXSrc As Integer, ByVal nYSrc As Integer, ByVal dwRop As
System.Int32) As Boolean
Private Const SRCCOPY As Integer = &HCC0020


Cheers,
Rob
 
Back
Top