Jump to content
Xtreme .Net Talk

snarfblam

Leaders
  • Posts

    2156
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by snarfblam

  1. I don't believe that there is an About form which comes standard with .Net, but they are easy enough to make. As far as help, there are chm and HtmlHelp compilers available (but hard to find, in my experience). Help files made with these will open in standard Windows help windows. I personally generally either stick to HTML help, or if I am looking for something more professional, I have gone as far as designing my own (relatively simplistic) help system with an XML based help file (I can send the code your way if you really want, but it's nothing special).
  2. A similar reply has already been posted. Also, this thread has had no new posts for over a month and should be considered inactive. I hope that I am not out of line when I recommend refreshing yourself on the Posting Guidelines.
  3. If I understand you correctly, this should help. In order to get the hDC of a System.Windows.Form object (since forms do not have a hDC property anymore) you must get the handle of the window and call the API function GetDC. Declare Function GetDC Lib "user32.dll" ( _ ByVal hwnd As IntPtr) As IntPtr Public Function GetAFormshDC(Form As System.Windows.Forms) As IntPtr Return GetDC(Form.Handle) End Sub
  4. Use the Graphics.FromImage method to create a graphics object which can manipulate a bitmap.
  5. Hmm... Microsoft is certianly taking a different direction with .Net. The framework comes with free compilers, there are free IDEs, and now they are even distributing their own IDE for free... how long can this hold up? My guess would be until the .Net platform becomes big enough that they can start making a serious profit charging more Microsoft-like prices (and after Java has taken a substantial hit, of course). Well... let's take advantage while we can.
  6. Instead of drawing to the window, you can draw to a bitmap and set the bitmap as the control's Image or BackGroundImage property, calling the Invalidate method to refresh the image.
  7. Let's forget about SetSuccess(). Just as an example, suppose you perform an operation and during that operation catch an exception. You would set the delegate to point to the ProcessError() function. If you reach the end of the process, you point the delegate at ProcessSuccess(). Again, this is just an example of a possible application of delegates, and not even a great one at that. A great example would be the event system in .Net. Down at the CLR level, events are not actually a unique entity. An event is just a variable of type MulticastDelegate, which inherits from Delegate and adds the ability to hold multiple function pointers for the sake of multiple handlers. When you use code like this: Public Event MyEvent '... AddHandler Me.MyEvent, AddressOf MyFunction '... RaiseEvent MyEvent() it is essentially compiled as something similar to 'Our multicast delegate is stored in this variable Public MyEvent As System.Delegate '... 'Here we add a new callback to our multicast delegate via Delegate.Combine MyEvent = System.Delegate.Combine(MyEvent, AddressOf MyFunction) '... 'Raise the event MyEvent.Invoke() 'Call callback function [/Vb] In other words, the entire event system in .Net relies on callbacks, which rely on delegates. And now you are thanking your lucky stars that we have delegates.
  8. There are all different uses. You can use a delegate for a callback function. Suppose you need to call a function which varies based on a certain condition. You can check the condition each time you need to call the function... If MyString = "Error" Then ProcessError() ElseIf MyString = "Success" Then ProcessSuccess() ElseIf MyString = "Inconclusive" Then Conclude() ' ... this could go on and on End If Instead, as when the condition changes, point a delegate to the appropriate function... [Vb] Public Sub SetSuccess() MyFunction = AddressOf Success() End Sub 'And when we need to call the appropriate function, we only need a single line of code... MyFunction() [/code] This could be used for optimization for speed. It could be used to organize or simplify code. There are lots of other uses for delegates. I'll bet some other people could post some other basic uses, but you could also get creative. You could create a history feature (as in that of Photoshop) that maintains a list, in the form of an array of delegates (and an array of their parameters, if necessary), of functions needed to undo/redo actions.
  9. I personally would prefer a cheesy VS control in a lot of situations. You don't have to pay extra for it; it comes with VS. It also doesn't require additional dlls to be distributed with your app (I am still a big fan of single-file application that don't require any deployment projects or additional files).
  10. Could you post the code?
  11. Well, I'll tell you what I know. Anyone who want to use a .Net application (on their machine or from a network) must have the .Net Framework installed. It can be downloaded (somewhere) on microsoft.com or through Windows Update (I believe that it comes with Service Pack 2 as well). And, although you can run a program from a server, the program will run with limited permissions, which, depending on your needs, may or may not be a problem.
  12. I get it. You were multiplying instead of bitshifting, so you needed to take care of the most signifigant bit. Well... glad you got the issue sorted out.
  13. The root namespace will be the name of the project unless you have explicitly changed it. Make sure that the "Compile Action" property of the icon file is set to "Embedded Resource".
  14. .Net 2005 contains a toolstrip button. As far as I understand it is a glorified, MS Office style toolbar.
  15. I wouldn't see this as a problem as the cursor probably doesn't spend that much time over the buttons, and since this is the normal behavior anyways, I don't see that really confusing anyone.
  16. You are compiling the cursor as an embedded resource, right? [Vb] 'VB Dim X As New Cursor(Me.GetType, "Rootnamespace.Filename.withextension") // 'C# // 'subfolders is the folder relative to the project path, and should be // 'omitted if the cursor is in the root project path Cursor(X = New Cursor(this.GetType(), "Rootnamespace.subfolders.Filename.withextension")) [/code]
  17. How is it not allowing you to? Is is throwing an exception? If so, what exception?
  18. I don't know how to add a derived menu item to menus via the Windows Forms Designer (maybe someone knows how to do this with a macro or addin, or by inheriting or providing different designer classes). What you can do (this is what I do) is add the menu items, and do a search and replace to swap them out with your menu item class. Generally, you do not need to inherit the MainMenu class. You might want to, though. For example, I created an owner drawn menu class with the nifty graphics and side bar and gradients and what not, but didn't want to have to set all the different properties of all the different menu items, so I overrode the MainMenu class and added the color/sidebar/etc. properties to that, rather than the MenuItem class.
  19. You probably want to set e.handled to true to prevent extra carrige returns in multiline textboxes or the error sound in singleline textboxes.
  20. I reconverted your code. Just a few notes about your VB: VB.Net does support the bitshift operator, and you are anding with 0x3FFFFFFF, which you weren't doing in the C++ code, which confused me a bit. I couldn't test is and compare with the C++ code since I don't know what exactly the code does and I don't have a decent C++ compiler on this machine. Public Function calcrc(ByVal sfile As String) As Integer 'int crc, i; Dim i, crc As Integer 'char car; Dim car As Byte 'int ola=0; Dim ola As Integer = 0 'crc = 0; crc = 0 'FILE *File; Dim FILE As IO.FileStream 'File=fopen (file,"r"); FILE = New IO.FileStream(sfile, IO.FileMode.Open) 'fscanf (File,"%c",&car); car = CByte(FILE.ReadByte) 'While ola! = EOF() Do Until FILE.Position = FILE.Length - 1 '{ 'crc = crc xor (int)car << 8; crc = crc Xor CInt(car) << 8 'for (i = 0; i < 8; ++i) For j As Integer = 0 To 7 '{ 'if (crc & 0x8000) If CBool(crc & &H8000) Then 'crc = crc << 1 ^ 0x1021; crc = crc << 1 Xor &H1021 Else 'crc = crc << 1; crc = crc << 1 End If Next '} 'ola=fscanf (File,"%c",&car); car = CByte(FILE.ReadByte) Loop '} 'fclose (File); FILE.Close() 'return (crc & 0xFFFF); Return crc And &HFFFF End Function Yes. And no. In VB, you generally want to use the equals operator because it returns a boolean value and VB requires a boolean value for "If" statements. In C++ (just like older versions of BASIC) any non-zero value is interpeted as true in an "If" statement. And in VB, with option strict off, any non-zero value is implicitly converted to a boolean True value, offering the same behavior.
  21. First off, I recommend reading the MSDN article on this. If you want nice rollover effects, this is a quick and easy method I use, but it might not be so easy for a beginner: I create three different images for any skinned form I make. Each version contains all the graphics for the entire form, including any buttons, with one image for the normal state, one for rollover state, and one for pressed state. I made a custom control that paints itself with the proper region of the proper image (the image to use is based on mouse events and the region is obtained from the .Bounds property). It is a quick and easy way to create a decent skin in a relatively small amount of time.
  22. Likewise, I haven't noticed this difference. Since you are using layered windows, however, I suppose that this behavior might vary, depending on graphics hardware.
  23. Serial keys do not prevent "buddy swapping". You must implement some sort of method of verifying that not only are serial keys valid, but unique per installation, and at the same time, in the event that the user buys a new PC, he must be able to install on the new machine (uninstalling the old installation, of course) and use the same serial key without problems. The only way I know of to verify serial keys in such a manner is to "phone home", i.e. do it Windows Xp activation style. I am not a big fan of activating software, and it requires the implementer to have a server and an IP which will not change.
×
×
  • Create New...