|
Help me, please ! How can I get a content of RichTextBox as Image (or Bitmap, or Metafile) or save it to a graphic file (any format) ?
|
|
|
|
|
Read How To Print the Content of a RichTextBox Control By Using Visual C# .NET[^] and modify the Print method documented in the KB article so that it accepts a Graphics object as the last parameter instead of a PrintPageEventArgs (you'll need to pass a struct for margins as well). This will allow you to pass a Graphics object (ultimately, the HDC - or handle to a device context - is used) for printing or to save an image.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
HI~
I am using compact framework and
I have written a class which extend Microsoft.WindowsCE.Forms.MessageWindow
How do I register the window class in C# so that I can find the window by using the function "FindWindow" ??
Note that the handle of the message window is existed in the instance of the MessageWindow.
|
|
|
|
|
FindWindow is a native function, however if you look at the documentation for FindWindow[^] on MSDN you will see that if you pass null for the lpClassName parameter it will find any window whose title matches the lpWindowName paramter. The P/Invoke signature for FindWindow is as follows:
[DllImport("user32.dll")]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
This works if you pass null as the first parameter, however if you want to specify the class name, you will have to override the CreateParams and specify the ClassName property.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Yes.
However, the message window has no window title
So I cannot use the second parameters.
I would like to get the handle of a window which has no window title as the window is not a form and also the window is a class of of C#. Also I use compact framework so there is no System.Window.Forms.CreateParams. So...
How do I get the handle of the window?
Thanks
|
|
|
|
|
Hy everyone!
Could anyone of you tell me how to implement checking if the minimizebutton on my WindowsForm was clicked?
I had a solution which worked but well when I switched over to another application to drag&drop some data the application was minimized as well and no longer shown in the taskbar.
But what I want to do is:
When switched to another application to drag&drop data the application only moves to the background but is still be shown in the taskbar. If the minimizebutton was clicked then my application should minimize and not be shown in the taskbar (except the icon to resize my application once again).
Thanks!
Stephan.
|
|
|
|
|
hi,
Minimizing a form to an icon at run time generates a Resize event. The WindowState property reflects the current state of the window. If you set the WindowState property to 1 (Minimized), the Form is minimized independently of whatever settings are in effect for the MinButton and BorderStyle properties.
private void Form1_Resize(object sender, System.EventArgs e)
{
if(WindowState == FormWindowState.Minimized) >> check this
}
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
sreejith ss nair wrote:
this.WindowState.ToString()=="Minimized")
OUCH!!!!!
WindowState == FormWindowState.Minimized
top secret xacc-ide 0.0.1
|
|
|
|
|
hello all,
Is there anyway to decompile a framework function so that I can see exactly what it does? The reason I want to do this is that I am having a few issues with :
HttpServerUtility.MapPath(string)
The issues I am having are far to long and complicated to get into, but any help would be greatly appreciated.
Another option would be to somehow debug the method so I can see what data is actually travelling through it.
post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
Lutz Roeder does a 'Reflector' that might help. It has come in handy for looking into system assemblies on a number of occasions.
Try [^]
|
|
|
|
|
I have Reflector and it gets me part of the way towards solving my problem but not all the way.
A little more information might be useful here, I get the following exception :
[ArgumentNullException: Value cannot be null.
Parameter name: str]
System.Security.Permissions.FileIOPermission.HasIllegalCharacters(String[] str) +231
System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList) +88
System.Web.HttpRequest.MapPath(String virtualPath, String baseVirtualDir, Boolean allowCrossAppMapping) +305
Having used reflector to view the code for .MapPath(...) it does not seem to call AddPathList(...) or go anywhere near the System.Security.Permissions namespace. Which leads me to believe that reflector isnt giving me all the code.
Without getting into the nitty gritty of this, I have written an Apache webserver module that will allow me to serve ASP .NET applications with this webserver - it works brilliantly until I run anything that contains .MapPath.
post.mode = postmodes.signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned
> 42
|
|
|
|
|
N8url wrote:
It has come in handy for looking into system assemblies on a number of occasions.
Just as long as it doesnt jump into unmanaged code!
top secret xacc-ide 0.0.1
|
|
|
|
|
|
What Control would be a good idea to use if I want to be able to let my control get the keyboard focus? Can I make a usercontrol get the keyboard focus and react to keyboard events?
|
|
|
|
|
UserControl should repond by default to key strokes.
For a custom control, you mite need to enable:
SetStyle(ControlStyles.Selectable, true);
top secret xacc-ide 0.0.1
|
|
|
|
|
Hi all,
I'm just wonder if it is possible to use C# to manipulate data and draw charts in excel. Currently I do know you can do that using Visual Basic / VBA. So for C#? Any idea?
|
|
|
|
|
|
I want to add tabpages to a tab control at runtime. And I should be able to specify those tabpages' names at runtime as well.HOw can I achive this?
samitha
|
|
|
|
|
The same way the designer does it - this isn't magic like Visual Basic (6 and below). Designer code is serialized to source code; taking a look at that would be a first step to understanding.
The TabControl has a collection property - TabPages - that you can add instances of a TabPage to. If you read the .NET Framework SDK for both of these classes, setting a title and adding a page to a tab control should be obvious:
TabPage page = new TabPage("My Caption");
tabControl1.TabPages.Add(page);
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
as you have mentioned I have put my code as follows
//this method is called from the main windows form
public void AddNewTabPage()
{
if(tabReportPages==null)
{
this.InitializeComponent();
}
System.Windows.Forms.TabPage tabPage1 = new System.Windows.Forms.TabPage("test");
//
// tabPage1
//
tabPage1.Location = new System.Drawing.Point(4, 22);
tabPage1.Name = "tabPage1";
tabPage1.Size = new System.Drawing.Size(536, 310);
tabPage1.TabIndex = 0;
this.tabReportPages.TabPages.Add(tabPage1);
//....continues for the othe tab pages
tabPage1.Show();
tabPage1.BringToFront();
tabPage2.Show();
//..continues for the other tab pages
}
but any of the tab pages are not showing..why is that?(the tab control is added to a user control)
samitha
|
|
|
|
|
hi,
i have a tab control with one tabpage and a button in my form. On button click i am executing this much code.
TabPage Newtab=new TabPage("ha ha");
this.tabControl1.TabPages.Add(Newtab);
Is the same you want ?
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Hi there!
Is there a way to detect the DragDrop event from form to desktop? Most of the articles here are doing the other way
or implementing COM interop (IShellLink...)
I just want my program to detect that the drop operation
was executed in the desktop and not within my form.
Thanks!
|
|
|
|
|
The only way to do that is not something the .NET Framework base class libraries (those installed with the .NET Framework) support. You must use an IStream as a storage medium for drag and drop, something the .NET Framework doesn't support.
I have carried on a very long thread about this here on this forum before. I recommend you search for it (try keywords like IStream or STGMEDIUM and watch for messages from myself and "The Catalyst" - the original poster with the same problem). Reading and understanding the COM interfaces and implementations involved is a must, so go to http://msdn.microsoft.com/library[^] and read in the Platform SDK about the drag and drop shell interfaces.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am trying to adapt the product registration sample code supplied with Inside Visual Studio .Net. The server side asp in the sample reads an XML stream from a request header into an XMLDocument and assigns it to string variables as so:
private void Page_Load(object sender, System.EventArgs e)
{
//Load registration info XML from the request header:
System.IO.StreamReader sr = new System.IO.StreamReader(Request.InputStream);
Response.ContentType = "text/text";
string strXML = sr.ReadLine();
//
//should be able to replace the code below
//with readXML from the input stream directly
//into the DataSet as so:
//
//Registration1 registration = new Registration1();
//registration.ReadXml(sr, XmlReadMode.Auto);
//
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
strXML = System.Web.HttpUtility.HtmlDecode(strXML);
xmlDoc.LoadXml(strXML);
//Unpack the registration info using XPath:
string firstName = xmlDoc.SelectSingleNode("Registration/FirstName").InnerText;
string lastName = xmlDoc.SelectSingleNode("Registration/LastName").InnerText;
string companyName = xmlDoc.SelectSingleNode("Registration/CompanyName").InnerText;
string address = xmlDoc.SelectSingleNode("Registration/Address").InnerText;
string aptSuite = xmlDoc.SelectSingleNode("Registration/AptSuite").InnerText;
string city = xmlDoc.SelectSingleNode("Registration/City").InnerText;
string state = xmlDoc.SelectSingleNode("Registration/State").InnerText;
string zip = xmlDoc.SelectSingleNode("Registration/Zip").InnerText;
string country = xmlDoc.SelectSingleNode("Registration/Country").InnerText;
string phoneAreaCode = xmlDoc.SelectSingleNode("Registration/PhoneAreaCode").InnerText;
string phone = xmlDoc.SelectSingleNode("Registration/Phone").InnerText;
string email = xmlDoc.SelectSingleNode("Registration/EMail").InnerText;
//TODO: Store the registration info for later use...
//
//if ProductRegistrationSQL is the database and
//the cols defined the same as the strings above
//and XML stream read directly into the dataset
//it should be a simple matter to insert the row //into the database as so:
//
//sqlDataAdapter1.Update(registration);
//
Response.Write("Thank-you for registering, "+firstName+"!");
Response.End();
}
Being new to C# and ADO .Net, I'm having a tough time with the four-in-one update concept. I've used the wizard in designer to create the select, update, insert and delete commands and I can see them in the property page for the adapter. But I just don't get how in the code to tell update that what I want to do is insert, not update.
This should be child's play but I'm stumped. What am I missing?
|
|
|
|
|
A DataRow stores change information, such as whether or not it is new, updated, or even deleted. When you use DataAdapter.Update , this information is used to determine which property - SelectCommand , InsertCommand , UpdateCommand , or DeleteCommand - is executed for a particular row. When the DataAdapter.Update is finished updating the data store, AcceptChanges is automatically called on the DataSet (or DataTable , depending on how you called Update ), so there's no need for you to do so.
A DataAdapter is really only helpful when dealing with DataSet s, however. Otherwise, stick to using parameterized queries and IDbCommand implementations (like the SqlCommand or OleDbCommand class) to update the data store using ExecuteNonQuery or something along those lines (depending on what SQL statement you're executing and what you expect returned).
Microsoft MVP, Visual C#
My Articles
|
|
|
|