|
|
They can leave in the same solution so you can P/Invoke the C# or the unmanged code from C#
Al
|
|
|
|
|
In my MFC application, I draw lines over graphics and text
controls.
void CAboutDlg::OnButton1( )
{
CClientDC dc( this );
dc.MoveTo( 0, 0 );
dc.LineTo( 200, 200 );
}
The black line will draw over anything on the form.
--------------------------------------------------------
Now, in C# I cannot figure out how to draw on 'top' of the
controls.
private void Button1_Click(object sender, System.EventArgs
e)
{
Graphics g = CreateGraphics( );
g.DrawLine( Pens.Black, 0, 0, 200, 200 );
}
When I want to draw this line, it draws on the background
and does not draw over the bitmaps or text.
So, how do I draw on top of all the objects in a form?!
Transparent controls are not an option in this case.
Thanks in advance!!
|
|
|
|
|
because you tell him to create a graphics for the Window Form you are using
ex : suppose the text you want to put on the form is a label called "lab"
- make this :
Graphics g = lab.CreateGraphics();
instead of CreateGraphics because if you only write CreateGraphics, it's the sams as this.CreateGraphics.
Do you understand ??
I hope I help you
Jonathan Pouliot
|
|
|
|
|
Yes, I definitely understand. Unfortunately, it's not that easy.
I am needing to draw from one control to another across the entire form. The code you showed me basically only lets me draw within one control.
The final application has two fingerprint images and lines connecting identifying features between the two.
|
|
|
|
|
hi
i have stored form names in an arraylist. i need to create an object of each form in the arraylist and display it....
but when i create an object say f1 of arraylist frmnum[0]....it gives an error...
i have no idea how to go about this.....do i need to use typecasting....if yes ....please tell me how
bye
|
|
|
|
|
Yes is the answer to your question, you will need to typecast whatever you are getting back out of the ArrayList to the value type you need. This code cycles through the ArrayList arrlstApts which holds an array of points. To assign the value into apt we must cast it as such (Point[])
for(int i = 0; i < arrlstApts.Count; i++)
{
Point[] apt = (Point[])arrlstApts[i]
}
Nick Parker
|
|
|
|
|
i tried to typecast to Form type like this:
for(int i = 0; i < frmnum.Count; i++)
{
Form[] apt = (Form[])frmnum[i];
}
but it is giving an exception error saying "System Invalid Cast Exception" occurred
Additional Information :Specified Cast is not valid.
please tell me how to do it!
|
|
|
|
|
Maybe it is silly question.Is it possible to bind the Text property of ListBox to the column of database? If I set the DataSource and DisplayMember it shows all of the column in listbox,but I want to show each field seprately and use BindingContext.Position++ to show records in listbox.Is that possible?
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Anyone have the code worked out to scan every file in every directory on a hard drive to locate a single file possibly using DirectoryInfo and FileInfo?
Kyle
|
|
|
|
|
You could do something like this, inside the loop I am adding the file to a listbox:
string m_CurrentDirectory = "C:\";
string[] AllFiles = Directory.GetFiles(m_CurrentDirectory, "*.*");
foreach (string aFile in AllFiles)
{
string aFileName = GetFileNameFromPath(aFile);
this.listBox1.Items.Add(aFileName);
}
Nick Parker
|
|
|
|
|
Thanks Nick. This works well for a single directory but I need to develop a routine that will search not only the root of drive C but also every sub-directory until the entire harddrive has been searched.
Kyle
|
|
|
|
|
public void SearchHardDrive(string harddrive)
{
DirectoryInfo di = new DirectoryInfo(harddrive);
SearchDirectory(di);
}
private void SearchDirectory(DirectoryInfo di)
{
DirectoryInfo [] dirs = di.GetDirectories();
foreach(DirectoryInfo dir in dirs)
{
SearchDirectory(dir);
}
FileInfo [] files = di.GetFiles();
foreach(FileInfo file in files)
{
DoSomethingWithFileInfo(file);
}
}
private void DoSomethingWithFileInfo(FileInfo file)
{
} Enjoy
[Edit: Okay, I'm an idiot I click on the wrong post to reply too ]
James
Simplicity Rules!
|
|
|
|
|
James T. Johnson wrote:
[Edit: Okay, I'm an idiot I click on the wrong post to reply too ]
No way James, I didn't have time to reply to Kyles response yet. Thanks
Nick Parker
|
|
|
|
|
Thanks guys,
Here is an approach that works well.
Kyle
using System.Management;
string drive = "\"c:\"";
string filename = "\"test\"" ;
string extension = "\"exe\"";
string qry = String.Format( "select * from cim_logicalfile where drive={0} and filename={1} and extension={2}", drive, filename, extension);
ManagementObjectSearcher query = new ManagementObjectSearcher(qry); ManagementObjectCollection queryCollection = query.Get();
foreach(ManagementObject mo in queryCollection)
{
Console.WriteLine( "Name '{0}' :Path: '{1}' ",mo["Name"], mo["Path"]);
}
[Edit: The : P shows up as a smily face. Although I am happy with this result the smily face was unintentional. ]
|
|
|
|
|
I am trying to recreate the sidebar used in Explorer in Win XP in one of my programs. You know, the cute blue (or silver or green) thing with all the pretty icons and animations? Okay, I know, the first thing you did was probably turn that thing off. But I really want to have that look in a few of my C# forms.
I've had marginal success recreating the look using my own controls that call the UxTheme library. This is messier than I'd like, however, and doesn't include all the neat animation and other features that Explorer has.
This being Microsoft, I'm sure they abstracted that side bar into an object, possibly even a control of some sort. Does anyone know if this is accessable? Has anyone found any sort of documentation on the subject, even a little snippet? (I built my version of the sidebar using barely a few lines of information on UxTheme.dll, so I'm used to having a lack of documentation for these new XP display styles.)
Or has someone on Code Project already addressed this, and I missed it?
Thanks.
---------------
Jeremy Fuller
|
|
|
|
|
Does anyone know if you can make winforms skinnable? If so are there samples that I can look at? I have a control that I bought from softshape.com that allowed me to write skinnable software in vb 6 and I'm looking for the same tool or method within .NET to do the same thing.
|
|
|
|
|
Hi. there
Well, Now I'm make some kind of HTML editor with C#.
I'm try to drag-drop some HTML tag in DHTMLEdit control.
But I can't...
How can I drag-drop "HTML tag" in DHTMLEdit...
I wrote source like this...
that is what I want drag(HTML tag) in DHTMLEdit contol.
---------------------------------------------------------------------------
private void schemaTreeView_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e)
{
string s = e.Item.ToString();
switch (s){
case "TreeNode: VATDOC" :
s = "<input type='checkbox' checked value='ON'> </input>";
break;
default:
break;
}
DoDragDrop(s , DragDropEffects.All);
}
---------------------------------------------------------------------------
and you know, Drop in DHTMLEdit control, It will be work automatically so...
When I try to drop "<input type='checkbox' checked value='ON'> </input>", but it will be work like this "& lt;input...... & gt;......"
I think, DHTMLEditor has some kind of parser that work change "<" to "& lt;"...
somebody know How can I drag-drop HTML tag in DHTMLEdit control?
PS) sorry for my poor english.. ^^;;;
=^.^=
|
|
|
|
|
We have our own abstract class, inherited from Windows.Forms.control,and has some base methods we will use in it. Now we create our user control, which inherited from this abstract class, then we found our new user control can not use some features from Windows form designer, does anyone have the same situation, and how to deal with this?
Thanks.
|
|
|
|
|
Sometimes when you manually edit the code, the form designer gets confused and stops working. Happens to me all the time
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
I have that problem too!
And I don't like it!
One time I had to increase the size of my window but when I compiled it was the old size of the window!!!
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Anonymous wrote:
then we found our new user control can not use some features from Windows form designer
What kind of features?
|
|
|
|
|
Actually, the abstract class our user control inherited is Windows.Forms.UserControl ( I say Windows.Forms.Control before, don't know if it makes any difference). When our new created usercontrol inherited this abstract class, you can not see it totally from design view.(The error shows the abstract class can not be loaded, etc. But we referenced this abstract class in the project, there is no compile error). Interestingly, when you remove inheritance, it can be shown in design view correctly.
Any idea?
|
|
|
|
|
This is a known "bug" with VS.NET; a couple solutions available but each require you to change the design.
First is to take all of the methods that would normally be left to be implemented and put it into an interface; then make the end usercontrol implement that.
Second is to provide dummy implementations that just throw a NotSupportedException or some other exception. Make sure to mark these methods as virtual
James
Simplicity Rules!
|
|
|
|
|