|
Yes. That's one of the things that SendMessage does. If you're not sure how to use it, read about the P/Invoke (Platform Invoke) functionality of C# and .NET.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Hi.
im new to c# so pls bear with me and teach me.....
i have created an MDI app, so i have three forms. frmMain , frmChild1 and frmChild2.
in frmMain i have a button which will call frmChild2..
button click event
{
frmChild2 c2 = new frmChild2();
this.MdiParent();
c2.Show();
}
and in frmChild2 i have a button callin frmChild3(this is also a child of frmMain)
button click event
{
frmChild3 c3 = new frmChild3();
/* how do i assign frmMain as the parent form?... */
c3.Show();
}
i also have another problem when i click the button twice, two identical forms pop up...how do i check to see if the form is already open, just direct the user to it and if its closed then open one?...
|
|
|
|
|
At the button click event in form2 use
objfrm3=new frm3();
objfrm3.MdiParent=this.MdiParent;//Assigns Parent of frm2 as parent of frm3
objfrm3.Show();
and regarding your problem of multiple forms opening
use a counter to count no of instances of form and before instantiating check the value of the counter
|
|
|
|
|
Is it possible to use Cache in a windows form application? if yes, how do i do that? pls advice...
|
|
|
|
|
Sure. But the methods used depend entirely on what your trying to cache.
RageInTheMachine9532
|
|
|
|
|
Basically values from the database that has been stored into a hashtable... this hashtable will then later be inserted into a cache... i have tried doing it in asp.net by using System.Web; using System.Web.Caching to enable the use of Cache. so now i m actually wondering whether this could be used in a windows form application. can a windows form application call to this cache...?
|
|
|
|
|
|
You could use the Web.Caching class to do what you want.
If your app isn't web based, you might also want to look at this MSDN .NET Caching Guide[^] for some other ideas.
RageInTheMachine9532
|
|
|
|
|
Yeah the application that i m doing isn't web based...
For web based, i implemented something like this...
// Global Declaration
private Cache m_Cache;
// Constructor
m_Cache = HttpRuntime.Cache;
// The implementation
if ( m_Cache["Sql"] == null )
{
/*
1. Get Data To Be Cached From Database Into A DataSet
2. Insert DataSet To HashTable
3. Insert HashTable to m_Cache
*/
}
else
{
/*
Get The Required HashTable From Cache
*/
}
But then for my Windows Forms Application ( Isn't Web Based ), i wanna do it something like how i did it with the HttpRuntime.Cache but then i can't coz i don't wanna use Web.Caching Class. I know that by using Hashtable is already a form of caching, but how do i initialize a Hashtable for a runtime cache? i mean something like this...
// Global Declaration
private Hashtable m_Hashtable;
// Constructor
m_Hashtable = HttpRuntime.Cache; // Which is impossible coz i m not using Web.Caching Class.
Pls Advice...
|
|
|
|
|
Hi,
I want to hide the scroll bar of Panel without giving autoscroll property "false". I scroll that Panel from the other button's event by using win32 api. If I set autoscroll property to "false", panel cannot scroll. I don't want to see the scrollbar in Panel, but I want scroll Panel. How do I do?
Regards,
|
|
|
|
|
I'd recommend not using autoscroll ability. Instead, handle scrolling yourself, use vertical and horizontal scrollbar controls.
Don't forget, that's Persian Gulf not Arabian gulf!
Murphy: Click Here![^] I'm thirsty like sun, more landless than wind...
|
|
|
|
|
Does anyone have any examples of using C# to communicate with a RS232 device much like the MSComm component that is included in VB6?
|
|
|
|
|
|
I need to know how to retrieve the path of an image that is a picture box for a program that I am building. Any points in the right direction would be greatly appreciated.
Happy Programming!
WWW::CodeProject::BNEACETP
|
|
|
|
|
Since a PictureBox only displays an image passed to it through it's Image property, there is no way to ask the PictureBox where it came from. This would have to come from the Image object that is passed to the PictureBox. This could either be a Bitmap object or a Metafile object. In either case, neither exposes a property to see what the source file is. If your setting the Image property thru code, you should already have the filename stored in a variable when you created the Bitmap object to pass to PictureBox.
Now, I know what your thinking. You can set the Image property of a PictureBox in design mode. True, but the image is then stored in the executable as a resource when your project is compiled. The original filename isn't stored as part of the executable, but is stored in the project source files, inacessible to the running executable.
RageInTheMachine9532
|
|
|
|
|
the .NET app saves the image inf in resourse files,
I don't know how to retrieve the path but you can save the image in specified using
PictureBox.Image.Save(....
|
|
|
|
|
I need to create a activex or control to get web page snapshot and save it as an image (gif or jpeg).
I don't know if its possible with c#.
Could you please help me by sending any example or link?
Thanks a lot.
|
|
|
|
|
*Apology in Advance*
ALT+PRTSCRN ?
What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
|
|
|
|
|
..
I know that one but my problem is that I need only the content area and that too programatically. Something like this site is doing:
http://www.tonec.com/download5.html
but its doing so many things and I just need to create a snapshot of web page content area as jpeg file.
The project I have needs to add a button in IE toolbar and when clicked, create a snapshot of web page content area into image file jpeg/gif.
Any ideas??
|
|
|
|
|
Sorry, I just couldn't resist; personally, I'd pay the $75, since I'd spend about that much of my time trying to figure out a way to do what they've already done.
What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
|
|
|
|
|
So i think it would be handy if I could write a function that does this:
If \\server\share\binary.exe is managed code
Do this
Otherwise it is not managed code
Do that
Is such a thing possible?
Thanks,
Ian
|
|
|
|
|
I know this function works with managed and unmanaged dlls. You could try it with executables though:
public bool IsManaged(string filePath)
{
byte[] Data = new byte[4096];
FileInfo file = new FileInfo(filePath);
FileStream fin = file.OpenRead();
int read = fin.Read(Data,0,Data.Length);
fin.Close();
if ((Data[1] << 8 | Data[0]) != 0x5a4d)
return false;
Int32 iWinNTHdr = Data[63]<<24 | Data[62]<<16 | Data[61] << 8 | Data[60];
if ((Data[iWinNTHdr+3] << 24 | Data[iWinNTHdr+2] << 16
| Data[iWinNTHdr+1] << 8
| Data[iWinNTHdr]) != 0x00004550)
return false;
Int32 iLightningAddr = iWinNTHdr + 24 + 208;
Int32 iSum=0;
Int32 iTop = iLightningAddr + 8;
for (int i = iLightningAddr; i < iTop; i++)
iSum|=Data[i];
if (iSum == 0)
return false;
else
return true;
}
Got this from a blog entry here:
http://blogs.msdn.com/adam_nathan/archive/2003/10/26/56786.aspx[^]
Hope this helps,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
Hello,
Is there a file properties dialog control in C# (similar to the OpenFile dialog)? Something similar to what you see when you check a files properties using Windows.
Right now I am using FileInfo and FileAttributes to get the necessary info but if there is a ready made dialog that would be great (though I can't seem to find one).
Thanx a lot,
-Flack
|
|
|
|
|
No, there is no FileProperties Dialog native to C# or the .NET Framework. The easiest solution is to build your own dialog.
RageInTheMachine9532
|
|
|
|
|
If you know the path to the existing file, you could P/Invoke SHObjectProperties :[DllImport("shell32.dll", CharSet=CharSet.Unicode)]
private static extern bool SHObjectProperties(
IntPtr handle,
[MarshalAs(UnmanagedType.U4)] SHOP type,
[MarshalAs(UnmanagedType.LPWStr)] string path,
[MarshalAs(UnmanagedType.LPWStr)] string initialPage);
[Flags]
private enum SHOP
{
PRINTERNAME = 1,
FILEPATH = 2,
VOLUMEGID = 4
}See http://msdn.microsoft.com[^] for more information about this API.
Microsoft MVP, Visual C#
My Articles
|
|
|
|