|
You could just create a new form then do something like...
<br />
ConfigDialog dialog = new ConfigDialog();<br />
if (dialog.ShowDialog == DialogResult.OK)<br />
{<br />
Application.Run(new DXForm());<br />
}<br />
Make sure that your OK button sends the dialog ok message. This is the DialogResult property of the button.
|
|
|
|
|
|
somebody tell me can use IDocHostUIHandler can relize this idea,but how can do this by c#?
ok
|
|
|
|
|
IDocHostUIHandler is defined in the MsHtmHst.idl file. Basic idea is you can write your own idl file and use the midl compiler to generate the type library. Following that you can use the .NET Framework's command line tool tlbimp to generate a .NET assembly you can include within your application.
[
uuid(47F05070-FD66-45cc-AD99-74260F94A16B)
]
library WebInterop
{
import "MsHtmHst.idl";
enum tagDOCHOSTUIDBLCLK;
enum tagDOCHOSTUIFLAG;
enum tagDOCHOSTUITYPE;
interface ICustomDoc;
interface IDocHostShowUI;
interface IDocHostUIHandler;
interface IDocHostUIHandler2;
interface IHostDialogHelper;
}
Then create the type library:
midl WebInterop.idl /tlb bin\WebInterop.tlb
Then create the .NET assembly:
tlbimp bin\WebInterop.tlb /out:bin\WebInterop.dll
Now create a class that inherits from IDocHostUIHandler and of course implements the appropriate methods.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hi,
I'm overloading the ++ operator for my Day Class. I have the implementation for this overload within my class and when I tested this in the debug mode, my Day which is supposed to increment as I've coded doesn't increse. It basically gives out an object of type Day itself with the next date. Here is my code. Any help with this would be appreciated. Please do help me out with this.
<br />
public static Day operator ++(Day d)<br />
<br />
{<br />
<br />
Day nxtDay;<br />
<br />
int nxtDate;<br />
<br />
<br />
try<br />
<br />
{<br />
<br />
nxtDate = d._dayofmonth + 1;<br />
<br />
nxtDate += 1 ;<br />
<br />
nxtDay = new Day(new DateTime(d.Year, d.Month, nxtDate));<br />
<br />
}<br />
<br />
catch (Exception e)<br />
<br />
{<br />
<br />
e.GetType();<br />
<br />
int nxtDayMonth = (d.Month == 12) ? 1 : d.Month + 1;<br />
<br />
int nxtDayYear = (nxtDayMonth == 1)? d.Year + 1: d.Year;<br />
<br />
nxtDay = new Day(gc.ToDateTime(nxtDayYear,nxtDayMonth,1,1,1,1,1));<br />
<br />
}<br />
<br />
return nxtDay;<br />
<br />
}<br />
Thanks
~~~~~~~~~~~~~~~~~~~~~~~~
Shravan Addaypally
.NET Apps Developer
BellSouth Billing Inc.
Birmingham, AL 35205
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
This might seem like a dumb question, but why not use the already built-in DateTime object? Check this example out from MSDN:
<br />
System.DateTime dTime = new System.DateTime(1980, 8, 5);<br />
<br />
System.TimeSpan tSpan <br />
= new System.TimeSpan(17, 4, 2, 1); <br />
<br />
System.DateTime result = dTime + tSpan;<br />
<br />
It seems to me to get the same job done without all the hassle of making your own object.
~javier lozano
(blog || email)
|
|
|
|
|
As Javier said, just use the DateTime structure.
A few things, though: why are you just calling e.GetType without actually using it? If you don't plan on using the exception for information (and I'm betting you are just calling e.GetType to get rid of the warning about declaring a type that you don't use), then don't declare it. Simply using catch or catch (Exception) is suitable (both of those result in the same behavior).
Finally, is this a class or a struct you're using? A struct is a value type, so any changes you make to it happen on a copy - not the original object. A reference type (a class) will always be the same object, though (refers to the same object, rather). Depending on how you use your Day struct (assuming it's a struct), this could be the problem why its value appears unchanged.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi
1. What is the best way to transfer a binary file over a network not using ASP and web service?
2. If I have a program that are 3 tier app have many data communication. like dataset, primitive data, binary files etc.... What is the communication protocol I should use? socket? remoting? webservice? what is their advantage and disadcantage?
Regards
Joel
|
|
|
|
|
joelwu wrote:
1. What is the best way to transfer a binary file over a network not using ASP and web service?
Whatever works for you in a given situation is best. If you use .NET Remoting (or Web Services, but you said you weren't wanting that), you could use DIME - and industry startard for efficiently sending binary data without encoding it (like base64 encoding) using SOAP, part of the Web Services Enhancements 2.0[^] for Web Services (works also with .NET Remoting with a little extra work). You could also just use a TcpClient and TcpListener (depending on whether you need to write a client, server, or both - respectively) to establish a connection and send byte[] arrays using the NetworkStream . If both are .NET clients, you can use runtime serialization (see the System.Runtime.Serialization namespace members) so long as both the client and server have access to the same types being serialized (so shared assemblies) - but this is essentially .NET Remoting so I'd recommend going with that infrastructure instead of defining your own (much more extensible, well though-out, and heavily tested).
joelwu wrote:
2. If I have a program that are 3 tier app have many data communication. like dataset, primitive data, binary files etc.... What is the communication protocol I should use? socket? remoting? webservice? what is their advantage and disadcantage?
This information is widely available on the web. I recommend doing a google search, picking up a good book (like "Advanced .NET Remoting" from Ingo Rammer[^]), or checking out some of the Microsoft resources like http://msdn.microsoft.com/webservices/[^] as well as key topics in the .NET Framework SDK[^]. Many, many articles have been written comparing the two and such a discussion would be extremely length (and redundant) in a forum such as this.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
This question has been asked many times and in several forums without a clear resolution.
Despite setting Basic-Auth credentials for a C# client on the service instantiated from a proxy generated using wsdl.exe, the HTTP header does not include the Authorization line.
Is there any specific configuration or permission requirement?
Thanks.
|
|
|
|
|
I need to be able to disable some things from happening while a window is being resized, i.e. while the window is being dragged with the left mouse button down, and have these things be re-enabled when the resizing is done. Does anybody know how to do this properly. I thought I could intercept the MouseDown and MouseUp events and use that to set a flag that could be read in the Resize event and used to disable stuff (and re-enable when the mouse button is released), but it seems the MouseDown and MouseUp events don't get fired when the pointer is on the border of the a window (where you grab it to drag it) instead of actually in the window.
Any ideas?
"Where do we go to get our good name back?...we go where we always go when a dramatic change is needed. We go to the ballot box" - Al Gore 5/26/04
|
|
|
|
|
The MouseDown and MouseUp events are only fired with the client area (the actual control area). They are not fired for the window frame. In order to handle these "events" (notification messages), override WndProc in your Form like so:
bool mouseDown;
const int WM_NCMBUTTONDOWN = 0x00a7;
const int WM_NCMBUTTONUP = 0x00a8;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_NCMBUTTONDOWN) mouseDown = true;
else if (m.Msg == WM_NCMBUTTONUP) mouseDown = false;
base.WndProc(ref m);
} Now your state variable (mouseDown ) should be assigned correctly.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i wanna to use the following code to get
hte system imagelist ,but it doesn't works well,the iconCount always equal 5,and so
i can't get the correct imagelist,who can tell me what's wrong with it.
[DllImport("comctl32.dll")]
private static extern int ImageList_GetImageCount( IntPtr himl );
public static ImageList GetSystemImagelist(bool isSmall , bool isSelected )
{
SHFILEINFO info = new SHFILEINFO(true);
int cbInfo = Marshal.SizeOf(info);
SHGFI flags = SHGFI.SHGFI_SYSICONINDEX;
SHIL size ;
if(isSmall == true)
flags |= SHGFI.SHGFI_SMALLICON;
else
flags |= SHGFI.SHGFI_ICON;
if(isSelected == true)
flags |= SHGFI.SHGFI_OPENICON;
ImageList imageList = new ImageList();
IntPtr imageHandle = SHGetFileInfo("C:\\",0,out info, (uint)cbInfo,flags);
IntPtr iconHandle = IntPtr.Zero;
int iconCount = ImageList_GetImageCount(imageHandle);
for (int i = 0; i < iconCount; i++)
{
iconHandle = ImageList_GetIcon(imageHandle, i, 0);
imageList.Images.Add (Icon.FromHandle(iconHandle));
}
return imageList;
}
|
|
|
|
|
FYI, a system image list is the image list kept by the Windows shell for purposes of caching icons. What you're doing is simply getting the associated icon for a file or device.
See my previous reply to a similar thread at http://www.codeproject.com/script/comments/forums.asp?msg=585938&forumid=1649#xx585938xx[^]. This actually uses a fake filename, however. Just set the second parameter to SHGetFileInfo to 0 if you want to get the icon for a real file. This code also inserts into a large and small image list. There is absolutely no reason to P/Invoke any of the Common Control Image List APIs - they are encapsulated by the ImageList already (just as most of the Windows Forms controls encapsulate the Common Controls).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
thank you very much ,it is so kind of you ; i was confuesd by the usage of c++,in c++ ,i can do it very easily by the following code:
void GetSystemImageList(CImageList * pSmallList, CImageList * pLargeList)
{
SHFILEINFO ssfi, lsfi;
HIMAGELIST hSystemSmallImageList = (HIMAGELIST)
::SHGetFileInfo((LPCTSTR)_T("C:\\"), 0, &ssfi,
sizeof(SHFILEINFO), SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
pSmallList->Attach(hSystemSmallImageList);
HIMAGELIST hSystemLargeImageList = (HIMAGELIST)
::SHGetFileInfo((LPCTSTR)_T("C:\\"), 0, &lsfi,
sizeof(SHFILEINFO), SHGFI_SYSICONINDEX | SHGFI_ICON);
pLargeList->Attach(hSystemLargeImageList);
}
|
|
|
|
|
You're still basically doing the same thing with the code I gave you, but to call native APIs in C# or VB.NET you need to P/Invoke native functions and declare the necessary interfaces, structs, and consts. Other languages may require you to do the same thing, but some (like MC++) allow you to call them directly (though in MC++ use of native APIs constitutes a mixed-mode assembly, which has additional CAS restrictions by nature).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Helloz plzz any body help me that ow to capture the desktup and save thi image in a bitmap. plzz guide in a step by step approach.
cheers
Rizwan Ahmed
|
|
|
|
|
jinnbaba wrote:
Helloz plzz any body help me that ow to capture the desktup and save thi image in a bitmap. plzz guide in a step by step approach.
Your english is rough to say the least, however regarding you question there are many articles covering how to P/Invoke the proper GDI functions used to perform this task. In fact a quick search provided this article here on CP: Image Capture[^]
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hello, I have a quick question.
You develop a Windows-based application that enables users to update customer contact information. Your application uses a DataSet object to maintain the customer data while users are reviewing and editing it. When a user finishes updating the data, your application uses the DataSet.WriteXml method to create an XML data file. The tag name of the root element of the XML data file must be <customerinfo>. You need to add code to your application to ensure that this tag name is set correctly. Which code segment should you use?
A . dsCustomer.Namespace = “CustomerInfo”
B . dsCustomer = New DataSet(“CustomerInfo”)
C . dcCustomer.Prefix = “CustomerInfo”
D . dsCustomer.WriteXml(“CustomerInfo”)
I thought it was A, but the book says B.
What do you guys think?
Thank you very much
|
|
|
|
|
I think you just copied and pasted you homework assignment. Try coding it yourself FIRST, then ask specific questions about any C# code issues you run into.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
No, this is not a homework question.
This is one of the sample questions in one of my books that I'm using to study for the 70-316.
The book said that you use the dataset constructor. However, i saw this question online, and the answer online said to use the namespace property.
I thought the parameter passed to the data set consructor was just the name of the data set. I went to MSDN and looked at the namespace property but I couldnt find anything that it set the root element.
I dont have any coding access right now, and was just wondering if anyone can help me out.
Thank you
|
|
|
|
|
Flack wrote:
The book said that you use the dataset constructor. However, i saw this question online, and the answer online said to use the namespace property.
A namespace can not directly contain a field or method without a class . A namespace provides a way to define scope, thus allowing globally unique types.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Flack wrote:
This is one of the sample questions in one of my books that I'm using to study for the 70-316.
Further proof that certifications don't mean much, huh?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
If you read the .NET Framework SDK (which will teach you more than a book - especially since certifications typically prove nothing), in order to name the DataSet you pass either the name (which will be the document element, or "root element") to the constructor or instantiate with the default constructor and assign the DataSetName property after its instantiated. Namespace allows you to declare an XML namespace for the DataSet XML document or fragment.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Can anyone tell me how can I read from/write to the parallel port in VC#?
Thanx
ahmedadel
|
|
|
|