|
I have created tab control with 5 tabs on a form. How can I draw or override onpaint() inside the area of any of the tabs?
Thanks
|
|
|
|
|
A TabControl holds one or more TabPages or TabPage derivatives. They get painted (well, the one that is current) just like any other Control. You either override their OnPaint() or add your paint handler to its Paint event.
The one thing that seems to puzzle a lot of users is the tabs themselves are drawn by the TabControl, not the TabPages, and can't be changed much through properties; if you want the tabs to look different, search the CP articles, there are a couple on that particular subject.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I believe you will need to subclass TabPage and override OnPaint in there to provide your own drawing. Alternatively handle each TabPage 's Paint event.
|
|
|
|
|
I am a newbie to C#. I am having hard time with subclassing the tabpage I guess. Is there any example or psuedo code that I can look at?
Thanks
|
|
|
|
|
Sure...
using System;
using System.Drawing;
using System.Windows.Forms;
namespace YourNamespace
{
public class CustomTabPage : TabPage
{
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
}
}
}
Instead of adding the standard TabPages to your TabControl, add these (once you have rebuilt your project it will appear in your toolbox).
|
|
|
|
|
hi guys
i write gps info into image but not display
whats problem
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
Image Pic;<br />
PropertyItem[] PropertyItems;<br />
<br />
string FilenameTemp;<br />
System.Drawing.Imaging.Encoder Enc = System.Drawing.Imaging.Encoder.Transformation;<br />
EncoderParameters EncParms = new EncoderParameters(1);<br />
EncoderParameter EncParm;<br />
ImageCodecInfo CodecInfo = GetEncoderInfo("image/jpeg");<br />
<br />
double dLat = 38.00000000000;<br />
double dLong = 48.0000000000;<br />
string Filename = "E:\\001.jpg";<br />
byte[] bLat = BitConverter.GetBytes(dLat);<br />
byte[] bLong = BitConverter.GetBytes(dLong);<br />
<br />
Pic = Image.FromFile(Filename);<br />
<br />
PropertyItems = Pic.PropertyItems;<br />
PropertyItems[0].Id = 0x0002;<br />
PropertyItems[0].Type = 5;<br />
PropertyItems[0].Len = bLong.Length;<br />
PropertyItems[0].Value = bLong;<br />
Pic.SetPropertyItem(PropertyItems[0]);<br />
<br />
PropertyItems = Pic.PropertyItems;<br />
PropertyItems[0].Id = 0x0004;<br />
PropertyItems[0].Type = 5;<br />
PropertyItems[0].Len = bLat.Length;<br />
PropertyItems[0].Value = bLat;<br />
Pic.SetPropertyItem(PropertyItems[0]);<br />
<br />
FilenameTemp = Filename + ".temp";<br />
<br />
EncParm = new EncoderParameter(Enc, (long)EncoderValue.TransformRotate90);<br />
EncParms.Param[0] = EncParm;<br />
<br />
Pic.Save("e:\\0001.jpg", CodecInfo, EncParms);<br />
<br />
<br />
}<br />
private static ImageCodecInfo GetEncoderInfo(String mimeType)<br />
{<br />
int j;<br />
ImageCodecInfo[] encoders;<br />
encoders = ImageCodecInfo.GetImageEncoders();<br />
for (j = 0; j < encoders.Length; ++j)<br />
{<br />
if (encoders[j].MimeType == mimeType)<br />
return encoders[j];<br />
}<br />
return null;<br />
}<br />
thanks a lot
|
|
|
|
|
There is an article on an Exif library here on CodeProject:
ExifLibrary for .NET[^]
Perhaps that might help you - I had to change some code for updating GPS values, but according to the author that should already be fixed now.
|
|
|
|
|
Hello.
I have a programm that scans the selected folder and adds all the files' names to the listbox.
I'm running the scan function in a separate thread. But, still the main form is freezing.
Here is my code:
private void button2_Click(object sender, EventArgs e)
{
Thread mThread = new Thread(myThread);
myThread.Start();
}
public void myThread()
{
AddFiles(label1.Text);
}
public void AddFiles(string targetDirectory)
{
if (listBox1.InvokeRequired)
{
AddFilesAdd method = new AddFilesAdd(AddFiles);
listBox1.Invoke(method, new object[] { targetDirectory });
return;
}
if (progressBar1.InvokeRequired)
{
AddFilesAdd method = new AddFilesAdd(AddFiles);
progressBar1.Invoke(method, new object[] { targetDirectory });
return;
}
string[] fileEntries = Directory.GetFiles(targetDirectory);
foreach (string fileName in fileEntries)
{
this.listBox1.Items.Add(fileName);
progCounter++;
progressBar1.Value = progCounter;
}
string[] subdirectoryEntries = Directory.GetDirectories(targetDirectory);
foreach (string subdirectory in subdirectoryEntries)
{
numberOfFolders++;
AddFiles(subdirectory);
}
|
|
|
|
|
Hi,
your code looks a bit weird to me. Here are some comments:
1.
AddFiles(label1.Text); is strictly not OK, you are touching a Control from a thread other than the main one. A better approach is to read label1.Text before launching the thread, then pass the string to it somehow (class member, or ThreadStart parameter).
2.
the progressbar code will never execute: progressBar1.InvokeRequired and listBox1.InvokeRequired are bound to have the same value, so either the first if block's return will fire, or both if blocks will be skipped.
3.
the whole threading approach is flawed: there really isn't any code running on the separate thread, all it does is cause the outermost AddFiles() to run on the main thread, so the hierarchical scan is all on the main thread (which will be very busy and uncapable of serving the GUI).
Solution: split the action in two parts, the first part scanning the file system and storing strings in a collection (all on the separate thread), the second part adding the collection's content to the ListBox.
4.
Lastly, this is a typical job a BackgroundWorker is good at. It would do the scanning in the DoWork handler, and the ListBox updating in the RunWorkerCompleted handler. You wouldn't need to call Invoke at all, the BGW does that for you.
PS: you may want to read this my little article[^] on the matter.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
how read and write from/to stream color and points of line
|
|
|
|
|
I guess you need a BinaryWriter[^].
I must get a clever new signature for 2011.
|
|
|
|
|
You know, Goodgle is a wonderful tool. I've been programming on and off for 30 years, and I still find it useful. Streaming in C#[^]
Normally, I wouldn't be this sarcastic, but every single question you have ever asked has been voted 1 by multuiple people[^]. 1 = Bad by the way.
You have been told before, many times, please respect the forum rules. Don't ask for source code, state clearly what your problem is and what errors you are getting if any, and don't ask for information which is easily Googled.
|
|
|
|
|
In fairness he is not alone; there are plenty of regulars who still will not try Google or MSDN despite one of those being the answer to nearly every query they post.
I feel your pain!
I must get a clever new signature for 2011.
|
|
|
|
|
You need to add the ImUpShitCreek and IDontHaveAPaddle interfaces.
|
|
|
|
|
That is harsh, cruel and uncalled for!
Good work, keep it up.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
Hello,I'm writting a extend Webbrowser,that I hope to disable scripts in my webbrowser.Idispatch interface can make it ,but I don't know how to implement it. And I have not found some materials with c#.Can someone tell me how to implement it and implement The Invoke method?
|
|
|
|
|
WebBrowser.ScriptErrorsSuppressed = true;
This will suppress the script errors.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
I mean no script run in my webbrowser,not suppress the script errors.But thank for your answer.
|
|
|
|
|
You can't do it unless you want to disable scripts for IE itself.
When people drop a WebBrowser control on a form, then say they're writing their own browser, they are NOT writing their own browser. All you're doing is reusing Internet Explorer in your own app. All of the settings that you see in Internet Explorer (Tools -> Internet Options menu) apply to the WebBrowser object. If you modify the settings in IE, the WebBrowser object uses the same settings. So, if you disable script execution, you will also disable script execution in every instance of IE that the user also launches. Your application cannot keep its settings seperate from IE.
|
|
|
|
|
Hi,
1-
On my laptop, I have developed an application called MyApp in Visual C# 2010 Express which connects to sql server 2005 express.
Works fine.
2-
As you know there is no installation mechanism with c# 2010 express, so as a test, I copied all the files (.dll, .exe, pdb...) from the release folder and placed them into c:\program files(86)\MyApp
3-
When running the .exe in this folder, error is shown on the screen as "Login failed for user user1". Then when the continue button is clicked on the error message, the application form appears with all the controls but empty data.
4-
It seems there is a problem with the login to the sql server, BUT note that the login does exist in the sql server as the application works fine when I run it in the visual c# 2010 express environment when developing it.
5- In the application, there is a class library project (The .dll in this project) which uses the connectionstring in the app.config file.
What do y ou think the problem is please?
Thanks
|
|
|
|
|
|
Thanks for coming back to me,
but note that I have mentioned that as I use the same machine to develop the application, the application is able to login to the database when running it through the development environment i.e. when I am developing the application but it fails when the .exe is run manually.
Any thoughts on that please?
|
|
|
|
|
arkiboys wrote: Any thoughts on that please?
Personally no, so I suggest you read up on the experience others have had and published about. Error messages tend to make very good Google search sentences.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Have you tried looking in your Debug folder?
I am reasonably sure you might find your data files in there...possibly including the file you store the login information in?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
The connection string is in the settings of a class library project which is now a .dll file.
I have included this file but I get the ERROR as descrived before.
Thanks
|
|
|
|