|
has anyone used these products?
if so can they be used while tables are locked?
|
|
|
|
|
I'm converting a C++ application to C# (yes - I know, dumb thing to do). The issue I've run into is when I put text into a text box, in C++ I could just add a \n to get a new line. Now, in C# text boxes, I have to add \r\n to get the same result.
Why? Is there anyway I can get around this?
- Bruce
BRCKCC
|
|
|
|
|
you can use System.Environment.NewLine to add the new string.
|
|
|
|
|
I have an array of bytes -- created dynamically during program execution -- that make up the color bits of a bitmap image. Is there a way in C# to create a Bitmap object that uses this array as it's data? I'd like to be able to save this to a file as a bitmap and I haven't been able to find any kind of documentation for this. As a temporary solution, I'm copying the data pixel by pixel into the array, but this seems very ludicrous. I know in C++ I was able to put a bitmap header on the data and presto, instant bitmap. I'd love to be able to do something similar in C#. Someone please help!
Thanks in advance.
|
|
|
|
|
I recomand creating a new Bitmap object and set it's pixels with the SetPixel procedure
Bitmap bmp = new Bitmap(width, height);<br />
bmp.SetPixel(x, y, color);
Then you can do wathever you want with the object, even save it into the memory with the Save procedure
I hope you understand...
By the way... visit http://nehe.gamedev.net[^]
|
|
|
|
|
That's actually what I'm already doing (I had to have something working temporarily). But this is a very slow way of doing things and for the program I'm working on, speed really matters. Thanks for the suggestion, though
|
|
|
|
|
In C# you can lock the bitmap in memory and put the bytes under the header:
<br />
Bitmap bmp = new Bitmap(width, height);<br />
BitmapData bmpData = bmp.LockBits(new Rectangle(0,0, bmp.Width, bmp.Height), bmp.PixelFormat);<br />
<br />
Marshal.Copy( byteArray, 0, bmpData.Scan0, byteArray.Length );<br />
<br />
bmp.UnlockBits(bmpData);<br />
bmp.Save(fileName, imageFormat);<br />
|
|
|
|
|
I am writing a user control that encapsulates System.Windows.Forms.Control objects. In the paint event of my user control, I want to paint to my user control the graphics that would appear on the encapsulated control. I have tried:
Graphics cg = Graphics.FromHwnd(control.Handle);
and
Graphics cg = control.CreateGraphics();
then passing that Graphics object to the base paint event of my user control, but that doesn't work either. Can anyone help?
|
|
|
|
|
sortamusic wrote:
I want to paint to my user control the graphics that would appear on the encapsulated control.
A simple and dirty way to paint the graphics that apears on a control to another is to copy it with the BitBlt function :
[System.Runtime.InteropServices.DllImport("gdi32.dll")]<br />
public static extern long BitBlt (IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);
Get the source and destination hDC from the graphics with (Graphics)g.GetHdc(); , call BitBlt and release the hDCs (Graphics)g.ReleaseHdc(hDC);
I hope you understand...
|
|
|
|
|
Thank you for your help! It has certainly put me in the right direction. I am still having a problem with it though. Instead of drawing the graphics of my underlying control, the graphics being painted are from a screen shot. Here is the code I am using:
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
if (control != null)
{
Debug.WriteLine( "Drawing graphics of control: " + control.GetType().FullName );
//Get the source and destination hDC from the graphics with
//(Graphics)g.GetHdc();, call BitBlt and release the hDCs (Graphics)g.ReleaseHdc(hDC);
Graphics cg = control.CreateGraphics();
IntPtr hdcSrc = cg.GetHdc();
IntPtr hdcDest = g.GetHdc();
BitBlt(hdcDest, 0, 0, this.Width, this.Height, hdcSrc, 0, 0,
(int)BitBltConstants.SRCCOPY);
g.ReleaseHdc(hdcDest);
cg.ReleaseHdc(hdcSrc);
return;
}
}
The variable 'control' is the control that I want to grab the graphics from and paint onto the control using this paint method. One problem might be that the 'control' control is never visible to the user. The SRCCOPY constant has a value of 0x00CC0020. Any suggestions?
|
|
|
|
|
The bitblt method is a quck and dirty method witch may fail (your case). Because your control is never visible to the user it is never draw so it can not be copied (you goted an screen shot maybe because you gave the source X and Y (0,0) instead of the control location)
But from what I have read from your last post I sugest the followng method :
Let's say we have control A and want to render on control B everithing what is on control A. Control A is rendered by a procedure (usualy Paint). So you must intercep every OnPaint (or the rendering procedure) for control A and create a new PaintEventArgs based on the one recived by the procedure but with the Graphics changed (changing the graphics means suppling the graphics from control B) and then call the base with the new PaintEventArgs. Piece of cake
I hope you understand...
By the way... visit http://nehe.gamedev.net[^]
|
|
|
|
|
Asked that question before, but didn't get an answer to my question.
My problem is the following:
I'd like to make my standard Form completely transparent. To do that I set TransparencyKey property to BackColor:
private void Form1_Load(object sender, System.EventArgs e)
{
this.TransparencyKey = this.BackColor;
}
This way the form in fact becomes transparent, but when it is shown, there is a short black flicker until the background gets transparent. A way I figuered out to get rid of that is to set the BackColor to pure black, too:
this.BackColor = Color.Black;
But this is no satisfying solution. To figure out what was going on I replaced the OnPaintBackground function with my own one, which simply does nothing:
protected override void OnPaintBackground(PaintEventArgs e)
{
//empty
}
The result is a black background. This background doesn't appear when BackColor is set to black as mentioned above. Does this happen on your machines, too?
Thanks,
3Dizard
|
|
|
|
|
3Dizard wrote:
This way the form in fact becomes transparent, but when it is shown, there is a short black flicker until the background gets transparent.
I noticed that to, and I haven't figured out why. But this "problem" appears at the first call, so if you change the opacity or the transparency key the second time it doesn't acts like the first one.
I hope you understand...
|
|
|
|
|
|
hello,
here i have a code fragment i want to execute with the Pocket PC Emulator or my real Pocket Pc Device:
using System;
using System.Runtime.InteropServices;
using System.Threading;
using System.IO;
namespace SmartDeviceApplication1
{
class Test
{
static AutoResetEvent evt;
static int count = 5;
static void Main(string[] args)
{
if (args.Length > 0)
{
try
{
count = int.Parse(args[0]);
}
catch (Exception e)
{
e.ToString();
}
}
evt = new AutoResetEvent(false);
Timer t = new Timer(new TimerCallback(TimerCallback), null, 0, 5000);
evt.WaitOne();
}
static void TimerCallback(object state)
{
Console.WriteLine("Enumerating windows at {0:t}...", DateTime.Now);
string title = new string('\0', 260);
int ret = GetWindowText(GetForegroundWindow(), title, 260);
if (ret != 0)
System.Console.WriteLine(title.Substring(0, ret));
}
[DllImport("user32.dll")]
static extern bool EnumWindows(EnumWindowsProc proc, IntPtr lParam);
delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
static extern int GetWindowText(IntPtr hWnd, [Out] string title,
int maxCount);
[DllImport("user32.dll")]
private static extern IntPtr GetForegroundWindow();
}
}
But when i want to deploy the foolowing error occurs:
A managed MissingMethodException
occured at
Test:TimerCallback+0x25
Test:TimerCallback+0x25
Timer:ring+0x59
Ok to terminate.
I do not know why this error occurs?? - Hopefully somebody is able to explain me what i do wrong?? I know that is something that a dll does not exist, but i do not know what exactly went wrong and how can i correct it??
thanks in advance.
pat
|
|
|
|
|
Hi,
I've got a user control that inherits from a parent control with a bitmap-filled label. I've got another user control that I want to go in front of it.
Since the base class InitializeComponent gets called first, the bitmap background label gets into the controls array first. Is there anyway to specify 'bring-to-front' on the second user control? I know in web you use z-order, but not sure how to do it here.
thanks,
Deanna
|
|
|
|
|
|
I get this problem on excel 2000 and works good with 2003. When I try to download a csv sent to a client browser, excel treats each line as a content of a single cell. For eg.
"18","000012345","Male" say this is the data in the csv file. When this is sent to the client browser the open/save dialog appears and if I choose to open, this information is put in one cell rather than being treated as separate cell information which Excel 2003 does. After this if I choose the File->save option to save this as a .csv file it appends a extra double quotes for each field and is distorted.
But if I save the file and then open everything seems to be right. Why is this happening? Is there a workaround for this issue?
|
|
|
|
|
Hi.
How do I compile a C# .net program via command line that uses Windows Forms?
I get an error message when I put "Using System.Windows.Forms". I know the code is correct as it is a simple example. I know I'm just missing something minor. How do I get it to find the forms library, or do I have to specify something else when compiling via command line?
|
|
|
|
|
Martin Marvinski wrote:
I get an error message when I put "Using System.Windows.Forms". I know the code is correct as it is a simple example.
No, if it is exactly as you typed it, it's wrong. C# is case-sensitive so it should be "using System.Windows.Forms;" Your example could be compiled with the following statement:
csc /target:winexe YourFile.cs
You can find more information for command line builds here[^] on MSDN.
- Nick Parker My Blog | My Articles
|
|
|
|
|
I have just encountered an interesting focus problem, which after doing some testing & searching I am at a loss to explain.
I have a COM object that under certain circumstance will show a form. This is a simple form with 2 buttons (ok, cancel) and a listview. By default the OK button has focus (through code by setting .Focus() , and through design by setting its tab order to 0).
The form is launched using [form object].ShowDialog()
When the form is displayed the button has focus because if I press return the code behind the button is executed (I am not using the AcceptButton property on the form) - the curious problem is how the button is rendered.
Normally if a button has focus a dotted line is drawn just inside the buttons bounds and the button shadow is enhanced. On the COM launched form the shadow is drawn but the inner line is not, but if I tab around to the button again it does have the dotted line.
If I add a Main() function to the form and launch it directly then the button is rendered correctly (with the shadow and the dotted line)
Does anybody have any ideas of what direction I should go to find a solution to this problem?
post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
I need a button with a drop down arrow like the back button in internet explorer--preferably writen in C#. Where can I find one, or how could I make one? (I'm trying to avoid overriding the OnPaint function) Thanks.
|
|
|
|
|
|
I am somewhat young in C# but what has worked for me is to add a context menu to the button.
|
|
|
|
|
Hi,
I want make;
For instance I have a on web service function A(File myFile). I want to send
the file abc.xml to A function and want to read the content of abc.xml from
inside of A function with XmlTextReader(File). How can I do this?
Any help would be appriciated,
Kind Regards,
Arda
-
When in doubt, push a pawn!
-
|
|
|
|