|
the answer for this question was posted back a few weeks ago (maby months i cannot remember) please search for it
|
|
|
|
|
Is there a way to make an application like paintbrush. With VC6, you can use the SDI using the CView. Thanks
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
Here's a link to a (very) complicated Paint program:
http://rbrewster.members.winisp.net/pdn.html
It's probably a lot more than you're looking for but it has some nifty custom controls that are very informative.
Here's a link to a VC++ program on this site by Christian Graus:
http://www.codeproject.com/vcpp/gdiplus/doodle.asp
It is also informative but if I remember it's not managed code, although I'm sure you could do the same work even easier in C#/.NET. I should post my own C# paint program!
vir·tu·al re·al·i·ty
n. Abbr. VR
A computer simulation of a real or imaginary universe in which Microsoft APIs are thoroughly documented and behave in an entirely logical manner.
|
|
|
|
|
Hi guy , i would like to have a Find search function like in Ms Excel to search for specific keyword in the list view. Could anyone help me to do so.
Currently i can only get the index of the item in the list view but i don't know how to make the findnext function work, i.e. return the index of the list view item then if the findNext invoke again, the next index of list view will be returned until there is no more match.
Here is the code
//flag : 1 for match case, 0 for match whole word
public System.Collections.ArrayList ListViewItemIndex(System.Windows.Forms.ListView lstView,string strKeyword,int flag)
{
int itemIndex=-1;
System.Collections.ArrayList list = new System.Collections.ArrayList();
foreach(System.Windows.Forms.ListViewItem item in lstView.Items)
{
foreach(System.Windows.Forms.ListViewItem.ListViewSubItem subItem in item.SubItems)
{
if(flag==1)
{
if(subItem.Text.IndexOf(strKeyword)>=0)
{
itemIndex = item.Index;
list.Add(itemIndex);
}
else
itemIndex = -1;
}
if(flag==2)
{
if(subItem.Text.Equals(strKeyword)){
itemIndex = item.Index;
list.Add(itemIndex);}
else
itemIndex = -1;
}
}
}
return list;
}
Thank you
Popoxinhxan
|
|
|
|
|
HI~
We use "Application.Run(new Form1()) to start a thread of a program.
Can we not use Application.Run(new Form1()) , but the thread is still running (waiting for the command?). I would not like a form appear on the screen. Thanks~
|
|
|
|
|
Instead of doing Application.Run(new Form()) do Application.Run(new AppContext()) where AppContext is a class that derives from ApplicationContext. This is used to define when your application exits. But you can also use it delay when to show the main form, or you can go without showing a main form.
|
|
|
|
|
Hi all,
I am creting a Bitmap image by using a two dimensional array of pixel data.
here is the procedure that i have gone thru...
first I have read the height and width of the original image which is (2544 X 1650).. since 1650 is not divisible by 4 i have used extra 2 columns to make it 1652 which is divisible by 4 (my actual array is 2544x4952 [since for R =1650, G=1650, B=1650 and 2 extra columns]). Now after copying each pixel value in the array for each line at the end i am inserting zeros for the extra 2 columns. Can we use an int array of data for this function?...I have checked for the approximate size of the resulting imge which goes around 12MB less than the specified 16MB for this function).Now I am calling the CreateBitmap function as follows...
hBitmap = PlatformInvokeGDI32.CreateBitmap( Width, Height, 3, 24, PixelData);
but this function is returning me a null value.
Am i calling it right ( I mean arguments in the function). I am using 1650 as the value for width argument (is it right).
then I am doin...
m_Bitmap = System.Drawing.Image.FromHbitmap(hBitmap);
Please help me how can i create a bitmap image by using above functions....
here is my source code snippet...
...
int[,] PixelData;
int Height=0, Width=0, j=0;
if(DialogResult.OK == openFileDialog.ShowDialog())
{
IntPtr hBitmap; ChosenFile=openFileDialog.FileName; this.Text = ChosenFile; PixelData = ConvertFile(ref Height, ref Width);
hBitmap = PlatformInvokeGDI32.CreateBitmap( Width, Height, 3, 24, PixelData);
if (hBitmap!=IntPtr.Zero)
{
m_Bitmap = System.Drawing.Image.FromHbitmap(hBitmap);
}
else
j=0;//just for a break point i initialized it
this.AutoScroll = true;
this.AutoScrollMinSize = new Size ((int)(m_Bitmap.Width * Zoom), (int)(m_Bitmap.Height * Zoom));
this.Invalidate();
}
public class PlatformInvokeGDI32
{
#region Class Functions
[DllImport("gdi32.dll",EntryPoint="DeleteObject")]
public static extern IntPtr DeleteObject(IntPtr hDc);
[DllImport ("gdi32.dll",EntryPoint="CreateBitmap")]
public static extern IntPtr CreateBitmap
(int nWidth, int nHeight, uint cPlanes, uint BitsPerPixel, int[,] lpvBits);
#endregion
#region Public Constructor
#endregion
}
thanks in advance,
Suman
|
|
|
|
|
Can anyone please help?
I am able to create a private MSMQ queue using: .\private$\MyQueue. However, when I try to do the exact same thing over HTTP, it fails.
MessageQueue.Create parameter string is:
string strQueuePathName = "FormatName:DIRECT=HTTP://127.0.0.1/msmq/private$/MyQueue"
When I check for:
if(MessageQueue.Exists(strQueuePathName)) it says that it cannot check for this path.
I tried may combinations, sometimes it'll fail sometimes it doesn't complain, but when you into Computer Management tool, under Services and Applications, Private Queues, the queue is Not created.
Here's my code:
string strQueuePathName = @"FormatName:DIRECT=HTTP://127.0.0.1/msmq/private$/MyQueue";
private MessageQueue GetQ(string strQueuePathName)
{
MessageQueue mq = null;
if(MessageQueue.Exists(strQueuePathName))
mq = MessageQueue.Create(strQueuePathName);
else
mq = new System.Messaging.MessageQueue(strQueuePathName);
return mq;
}
Thanks in advance for your help.
|
|
|
|
|
I have a smart client that downloads a form, and I want to close the smart client form and open the downloaded form. I am doing so via:
Thread thr = new Thread(new ThreadStart(DownloadedForm));
thr.Start();
this.Close(); // closing smart client form, as no longer needed
this.Dispose();
private void DownloadedForm()
{
Application.Run(df);
}
Will this create any stability issues with the form 'df'?
|
|
|
|
|
I'm also trying this avenue, and it seems to be working fine, as well:
Form mainForm = new Form();
Form downloadedForm = new Form();
ApplicationContext cont = new ApplicationContext();
cont.MainForm = mainForm;
mainForm.ShowDialog();
// and then when I want to close this and start the other:
cont.MainForm = downloadedForm;
downloadedForm.ShowDialog();
mainForm.Close();
mainForm.Dispose();
Is this safer than the previous method I described?
|
|
|
|
|
Neither method will work. Once your app closes, any threads it started will also close. If you want to download and launch a form, you'll have to either download it as a seperate .EXE and launch that, or you'll have to keep your current app open.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
C# newbie looking for a simple way to access a control on a form, a label or progress bar, from another class.
If not a simple, a difficult one, or even the correct one will suffice.
BBB
|
|
|
|
|
It all comes down to references and access. One class must first have a reference to another. So, your form that wants to access a control on another form must have a reference to that form. You could pass a reference as a property, for example.
Second, that control has to be accessible. By default, the Windows Forms designer makes all controls you drag-and-drop onto the designer private, so other classes - even derivative classes - can't access the field. You can either change the accecss modifier (you can do this both in the PropertyGrid from the designer or in the code file). You could, however, enumerate the form's Controls collection and find the control by name, which would be accessible (just because the control's field is private doesn't mean the control itself is private - only the field that holds the reference to it is).
If these are parent/child forms, then you can use the Parent property, for example, of the child form, but you must make sure to cast it to the parent form's type in order to access fields by name. An example follows:
using System;
using System.Drawing;
using System.Windows.Forms;
class ParentForm : Form
{
static void Main()
{
Application.Run(new ParentForm());
}
Button openChild;
internal TextBox childText;
internal ParentForm()
{
Text = "Example: Parent Form";
openChild = new Button();
Controls.Add(openChild);
openChild.Location = new Point(8, 8);
openChild.Text = "Open Child";
openChild.Click += new EventHandler(openChild_Click);
childText = new TextBox();
Controls.Add(childText);
childText.Location = new Point(8, openChild.Bottom + 8);
childText.ReadOnly = true;
}
void openChild_Click(object sender, EventArgs e)
{
using (ChildForm form = new ChildForm())
form.ShowDialog(this);
}
}
class ChildForm : Form
{
TextBox myText;
internal ChildForm()
{
Text = "Example: Child Form";
myText = new TextBox();
Controls.Add(myText);
myText.Location = new Point(8, 8);
myText.TextChanged += new EventHandler(myText_TextChanged);
}
void myText_TextChanged(object sender, EventArgs e)
{
ParentForm parent = Owner as ParentForm;
if (parent != null)
parent.childText.Text = myText.Text;
}
} You should also read Access Modifiers[^] in the C# programmers reference.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi there!
I have a problem reading files.
I am using StreamReader readfile and making a = readfile.ReadLine();
I know that the file that I am reading contain words like
Simão, and instead of that the work that appears in string a is Simo.
The streamReader isn´t reading the caracteres like ç, à, á, etc, etc.
What is the problem?!! How can I solve it?!
Thank you very much
|
|
|
|
|
You need to know what codepage/character set the file is encoded with, and set the StreamReader appropriately. At a guess, I'd say your file is probably Windows-1252[^] (if you wrote it with Notepad, or most other text-handling programs). The .NET Framework default is UTF-8. The combination of code points 0xE3 ( = ã in 1252) and 0x6F ( o ) is not a valid UTF-8 character, so the 0xE3 gets discarded.
You should use the StreamReader constructor which takes an Encoding. You can get the user's current culture default code page from System.Globalization.CultureInfo.CurrentCulture.TextInfo.ANSICodePage .
If you're designing new formats I strongly recommend using one of the Unicode formats, either UTF-16 (which the Framework and Windows call 'Unicode') or UTF-8. The Framework's reader classes can auto-detect UTF-16. UTF-8 is more compact for text containing mostly western characters; for far-eastern text, UTF-16 gains an edge.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hi,
I'm trying to create a copy of a datatable using .Copy() but I get an exception. I have no clue why, especially since the exception occurs in designer generated code. My dataset is a typed dataset, and I pass a single datatable to a method.
The code is pretty simple...
private DataTable _dt;<br />
private DataTable _dt2;<br />
<br />
void Test(DataTable dt)<br />
{<br />
_dt = dt;<br />
_dt2 = dt.Copy();<br />
}
Message: Object reference not set to an instance of an object.
Source: System.Data/LookupNode.Bind
StackTrace: at System.Data.LookupNode.Bind(DataTable table, ArrayList list)
at System.Data.DataExpression.Bind(DataTable table)
at System.Data.DataExpression..ctor(String expression, DataTable table, Type type)
at System.Data.DataColumn.set_Expression(String value)
at System.Data.DataTable.CloneTo(DataTable clone, DataSet cloneDS)
at System.Data.DataTable.Clone(DataSet cloneDS)
at System.Data.DataTable.Clone()
at AdonisTech.Adonis2005.StayLibrary.tblParents_AlertsDataTable.Clone() in StayLibrary\DataSets\ParentDataSet1.cs:line 4327
at System.Data.DataTable.Copy()
at AdonisTech.Adonis2005.WinUI.frmAlerts..ctor(String formTitle, DataTable table, FormType formType) in WinUI\General\frmAlerts.cs:line 17
at AdonisTech.Adonis2005.WinUI.frmEditParent.btnAlerts_Click(Object sender, EventArgs e) in WinUI\Stay\frmEditParent.cs:line 1300
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
|
|
|
|
|
make sure you have instantiated dt before passing it as a parameter into your function.
|
|
|
|
|
Of course it is...
|
|
|
|
|
I am building an admin application for our website using winforms
and C#. Users (who don't know html) are required to maintain
content for the site. I would like to give them the ability to
bold, underline, create links, etc. for the site. All content in
stored in a database as html. Is there a component available for
this that isn't a full blown html editor? I don't need to build
pages with it, just edit text.
Thanks in advance,
Brett
|
|
|
|
|
I have heard good things about www.freetextbox.com, have not used it though. Well now that i have re read your question, you might also look at the writer project(http://gotdotnet.com/Workspaces/Workspace.aspx?id=ee974084-d5c2-44d5-a11b-b2efb96074f8)
it is a wysiwyg windows forms editor. Free textbox is prolly closer to what you need, but it is a asp.net control. =\
|
|
|
|
|
Thanks, Most of what I have seen are asp.net controls. Most of the winforms stuff is overkill. I will take a look at the links.
|
|
|
|
|
I am using a dtp on a form that has an OK button. If the user changes the hour on the dtp and hits the enter key, the OK button_Click event fires without the dtp hour getting updated. How can I prevent this behavior?
For example:
before entry, the dtpMyControl.Value.Hour == 1
the user enters a change so the control looks like 05:59:59
then hits the enter key (the '05' being highlighted)
the validation code that reads the hour still has dtpMyControl.Value.Hour==1.
|
|
|
|
|
I found my answer.
simply add a Focus call in the _Click handler like so:
private void buttonOK_Click(..)
{
...
buttonOK.Focus(); // If the dtp (or other) control didn't loose focus, it does now
...
}
|
|
|
|
|
Hi, guys
I need a time stamp, which can remember time when the source code is compiled for the first time. So DateTime.Now is useless.
How can I get it?
Thank you very much.
vigorous
|
|
|
|
|
You mean like the "File Created" date that every file on FAT/32, NTFS, and most other file systems has? If you want to access this from code, use the FileInfo class along with the local path of your assembly, which you can get form Assembly.GetExecutingAssembly().Location .
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|