|
just buy the books already, ebooks are usually pirated.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi All:
I am trying to draw small points ontop of an origin background. I am trying to plot points in a 4 coordinate background. So I want the background to be stationary and the points to change given the incoming values. How can I do this? Right now my background is redrawing everytime I draw the small square so it looks awful! Please help!
Laura
|
|
|
|
|
You need to turn on double buffering, probably. Sorry, you need to google for the code, don't know it off hand.
You also need to post your code, so we can see how you're going about it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have a slight bug in one of my programs. It is a program that involves databinding with ADO.NET 2.0. My main form is bound to one of the tables. I have another form and a combo-boxon my main form that is bound to the other table (there are only two) in the database. When I run the application, I find that the individual forms work correctly, but the combo-box does not update if I add a new field in the other form unless I restart the application after closing it. I need a way to refresh that combo-box! Please help!
Person ejbing = new Person();
ej.SayGoodbye();
|
|
|
|
|
I believe the correct form is to do another fill in your main form after returning.
dataAdapter.Fill(dataSet, [table]);
Hope this helps
Started out with nothing and still have most of it left!
|
|
|
|
|
Thanks! I'll have to give it a whirr. You said:
dataAdapter.Fill(dataSet, [table]);
Person ejbing = new Person();
ej.SayGoodbye();
|
|
|
|
|
Hi all I am new to C# and real new to drawing with it. I have been looking online and have been unsuccessful in finding tutorials or examples in what I am trying to do. I am trying to draw a very small square about 1cm in size. I want to draw it at a certain location on the form. Does anyone know how to do this or can help point me in the right direction with sample code. I have a timer implemented and when the timer interrupt occurs I want to draw the small square in a differnt location in the form. Right now its not drawing anything. I call my paint function in the timer event function by doing the following:
this.Paint += new PaintEventHandler(XYZ_Paint);
But nothing gets displayed to the form, not even a simple line or anything. Why is this? Please help. I am using C# and Visual Studio 2005.
Thanks,
Laura
|
|
|
|
|
Your timer function needs to call Invalidate(), this will force the paint event to occur.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks so much! That worked. Now how can I dry a small square and display it in the form at certain locations?
|
|
|
|
|
Add your painting commands to your paint handler (you called it XYZ_Paint).
Just get the Graphics from the PaintEventArgs, and use DrawLine, FillRectangle and all
the other nice Graphics methods.
For animation, use coordinate variables that get changed by your timer tick handler.
|
|
|
|
|
Could you give me a coded example of drawing a 1cm square or a point whichever is easier on a form at location (15,25)? Thanks so much!
|
|
|
|
|
It's just e.Graphics.FillRectange(15, 25, 20, 20); assuming that 20 pixels is about 1 cm.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
in the form's paint handler I would do:
Graphics g=e.Graphics;
g.DrawRectangle(Pens.Black, 15, 25, w, h);
now what are the right values for w and h ?
for a point (or a very small square), set them both to 1 or 2.
for an exact size, it is complex:
- first you must assume that your system settings are correct, i.e. the right dpi
have been set (by default a monitor gets installed at 96 dpi, which is less than what
the average modern monitor is showing). You can change them to the correct value by first
calculating the value, then setting it interactively under Display Properties/Settings/
Advanced/DPI Settings: select custom settings, and then enter the number as a
percentage of 96 dpi.
remark: everything will look smaller now (except for the desktop, which now can hold
much more stuff); you may want to increase the system's default font size, icon size,
etc.
- then your program should find out what the system's dpi settings are, by calling
something like
Bitmap bitmap=new Bitmap(100, 100);
Graphics gBM=Graphics.FromImage(bitmap);
int Dpi=gBM.DpiX;
gBM.Dispose();
This has to be done only once in a program (unless you want to cope with a change
in the setting while the program is running...)
you dont have to worry about DpiY, it will equal DpiX (you could only enter an
overall dpi value in the previous step, so best is to calculate it diagonally !)
Now you can calculate how many pixels are needed to travel 1 cm, and that's the
right value for w and h.
remark: if your system settings are incorrect, dont bother calling gBM.DpiX, since
everything would be based on a lie, hence wrong.
|
|
|
|
|
Yeah, I did not respond to the 1cm bit, because it's never going to work, in the real world.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Well, I started working on a Mac long time ago, all monitors were 72 dpi and all programs
were real size, even Microsoft Word. It was marvelous, you could hold a printed page
against the monitor and print and screen would fit up to the millimeter.
When I switched to PCs and Windows (98, NT, XP), I insisted on keeping real size,
although monitors improved, one of them is at 135 dpi now. And I still manage in most
applications; biggest problem is with some web pages that insist on petite fonts,
ignoring system settings.
So I created a small background app (in C# of course) that upon ALT-S switches resolutions
to some 80% of reality (and back) for easier reading those difficult pages, keeping track
of desktop icon positions, and window sizes, restoring as much as possible when hitting
ALT-S a second time. The one thing it does not do is restore the size of the windows
that were minimized (I dont know how to get/set these values, I think they are well
hidden inside Windows Explorer). Any suggestion here would be welcome.
|
|
|
|
|
Hi,
and of course you must execute the line
this.Paint += new PaintEventHandler(XYZ_Paint);
once, typically this is done in the form's constructor.
|
|
|
|
|
I have a form with a panel called test_panel1. I need to display
a bitmap on that panel and I have this code that works.
<br />
<br />
private void SetBitmap(Bitmap bmap)<br />
<br />
{<br />
<br />
Graphics graph = this.test_panel1.CreateGraphics();<br />
graph.DrawImage(bmap, 0, 0); <br />
<br />
}<br />
I now need to add another panel, lets call it test_panel2
and I need to do the same thing. But I'd like to call SetBitmap
and pass it the panel to put the bitmap on
Something like:
SetBitmap(mybitmap,test_panel2) or SetBitmap(mybitmap,test_panel1)
and have the function look like
<br />
private void SetBitmap(Bitmap bmap,Panel pnl)<br />
{<br />
<br />
Graphics graph = this.pnl.CreateGraphics();<br />
graph.DrawImage(bmap, 0, 0); <br />
<br />
}<br />
But C# doesn't like it and I don't know what the proper way to do this is?
Any help is very very welcomed.
|
|
|
|
|
Try this:
private void SetBitmap(Bitmap bmap, Panel pn)
{
Graphics graph = pn.CreateGraphics();
graph.DrawImage(bmap, 0, 0);
}
|
|
|
|
|
So simple, yet it is so hard!
Mucho Gracias.
|
|
|
|
|
What you've been told will not work if your form is ever obscured by another form.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
if you create an instance of a class that offers a public Dispose() method, you MUST
call that method when you're done. This also applies to Control.CreateGraphics()
and Graphics.FromImage() and the like !!!
|
|
|
|
|
This won't work properly. If the form is invalidated, the panel will be erased, unless this is called from a paint event, in which case, it should just use the existing graphics object.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
You should handle the paint event of the panel, and draw the bitmap onto the panel there. CreateGraphics will not redraw the image if your form is obscured by another form, as no paint event will occur.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello
I made one app and put on form grid view . I write the informations to the gridview but when i restart app ther are gone .Question is : How to save a access databse in c# and all records!!??
Thx
nemanja
|
|
|
|
|
Hi.
Can anyone give me a general gude (or a link to some resources) on the subject of different image formats?
But let me explain more specifically: I have a control that shows a lot of text items whose size & format depend on the content itself. This means that every time the control is repainted, a lot of text rendering occurs. To go around this problem I use a very simple idea - render the text to an image an draw the image until the text changes.
The only problem with this idea is the consumption of a lot of RAM.
What can I do to reduce the amount of memory I use? GDI+ offeres only the abstract Image class (Bitmap & Metafile as its descendents) for Drawing Images on the screen.
Is there a way to reduce the colors or perhaps use some sort of compression when I save the Images in the in-memory buffer?
Thank you.
|
|
|
|