snarfblam
Leaders-
Posts
2156 -
Joined
-
Last visited
-
Days Won
2
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by snarfblam
-
Transparent labels should work. They render themselves via GDI+, which works on all platforms. Things like semi-transparent forms, on the other hand, depend on the Windows 2000/Xp layered windows feature and only work on Xp/2000.
-
What sort of image and what is the purpose of the text? Jpegs have support for metadata, but I don't know the specifics. Gifs, I don't know about. Bmps I don't think so. PNGs, I have no idea. You can append text after image data, at the end of an image file, and most software will still load the image all right and ignore the extraneous data, but there is never a guarantee in that case. In any case, I don't think that opening an image file in notepad and adding text is a good idea. A lot of image formats have all kinds of offsets stored in them and if you add/remove data, these offsets change, and if you don't update the offsets bad things happen.
-
If you are replacing the text in the string, and you search the rtf, you should make the replacement in the rtf. If you search the plain text, you should make the replacement in the plain text. If you are trying to position the cursor within the text box (which is done by the plain text position) you must search the plain text. As long as you do one of the above, you shouldn't run into a misalignment issue. You can not search the rtf and use that to position the cursor or selection unless you want to parse the rtf yourself and calculate the correct offset. From what I see, you must either search the plain text instead of rtf, or make the replacement in the rtf instead of plain text. If you are worried about positioning the cursor correctly after modifying the rtf, you can search both the rtf and the plain text to find both offsets, make the rtf replacement and position the cursor using the plain text offset you found. Hope I understood your question right or at least said something somewhat useful.
-
I recommend you start by looking at MSDN and searching Google with this kind of question. You get a kind of instant gratification. If you look at the Properties window when a label is selected, you will notice that one of the colors that you can set (under the "Web" tab, I think) is Transparent. It is important to understand the behavior of transparent controls in .Net, though. Because of the way that transparent controls are drawn the only thing that will show through a transparent control is that control's parent container (either the gray/tan blank surface, the container's background image, or whatever is normally drawn in the parent container). This may or may not become a problem for you. If the control overlaps another control, the control will appear to "cut a hole" in the other control where they overlap. For instance, if a transparent label overlaps a button, in the area where they overlap, instead of seeing the button under the label, the underlying form will show through the overlapping area.
-
.Net is not designed or intended for this. Even if you embed the entire base class library into the executable (which possibly could be done with ILMerge), the runtime still performs all run-time type operations/checks, garbage collection, object allocation, etc. etc.. The executable you deliver would be so bloated, you probably might as well distribute the .Net redistributable with an installer. You can NGen it to skip the JIT compilation at runtime and ILMerge extra libraries to avoid extra dependencies, but that's about as far as you can go as far as I know. Maybe you should just make the switch to C++... either that or make an IL compiler/linker for x86. That'd be nice.
-
If you are worried about threads, I would focus on objects where you are making asynchronous calls, like Control.BeginInvoke(). Generally, I don't think that simply instantiating most objects will create another thread. Also, perhaps if you are doing some serious multithreading, the thread pool might be creating more threads for you. Honestly, I don't know too much about multithreading and I'm really just speculating here. What does this form that is suspected of causing memory leaks do? Does it use alot of any sort of uncommon resource or some sort of class you are new to? Third party libraries? Are you using any particularly "creative" programming techniques? Especially double check frequently called functions, but that is not necessarily where the problem lies.
-
Dim table_style As New DataGridTableStyle table_style.MappingName = "Rubrica" table_style.ReadOnly = True [u]Dim column_style As DataGridColumnStyle[/u] [u]column_style.NullText = ""[/u] table_style.GridColumnStyles.Add(column_style) dgKharta.TableStyles.Add(table_style) If you declare a variable, but never point it to an object you will have a null reference. If it is MustInherit, that means that there is either another class that derives from this class that you can instantiate, or there is a function somewhere that can return such an object. Looking through the MSDN in the DataGridColumnStyle...
-
The only way you can really run into a memory leak in .Net is by allocating lots of unmanaged resources and not releasing them (either that or accidentally maintaining references to loads of managed objects). Look at the form's code. Does it create IDisposable objects and not dispose of them? Keeping a reference to IDisposable objects and calling their Dispose or Close method is a must. If, for example, you create GDI/GDI+ objects in the OnPaint method or Paint event and forget to dispose them, you are going to run into problems. Keep an eye out for particularly large objects, such as bitmaps or huge XML documents.
-
Just out of curiousity, what is displayed if you do something like this? MessageBox.Show(MyControl.Text.GetType().ToString())
-
There is a Windows API function (DrawAnimatedRects) that will draw the minimize animation from anywhere you want to anywhere you want. Once you have that, you can do the animation, then call the Hide method on the form. I recommend checking the user's settings before you show the animation for the sake of those who have the window maximize/minimize animations turned off.
-
Yes, it works fine with punctuation. All of the following should work: "Red/White/Blue" "Purple has a red-blue hue" "(blue)red" "System.Drawing.Colors.Blue, System.Drawing.Colors.Red"
-
I'm not sure if I understand the problem, but I think it might be that you don't realize that a delegate can be tied to a particular instance. Class SampleClass Dim Value As String Delegate Function BlankFunction() As String Public Function GetValue() As String Return Value End Function Public Sub New(ByVal Val As String) Value = Val End Sub Shared Sub ForExample() Dim MySample1 As New SampleClass("1") Dim MySample2 As New SampleClass("2") Dim MyDelegate1 As BlankFunction = AddressOf MySample1.GetValue Dim MyDelegate2 As BlankFunction = AddressOf MySample2.GetValue 'Note that when we call the delegate, we do not have to specify which object 'to call the function on. That information is stored in the delegate. MessageBox.Show(MyDelegate1) MessageBox.Show(MyDelegate2) End Sub End Class
-
Bri, you are a bit too quick to shoot down Visual Basic functions. You don't even give a reason why. Don't take this post personally, but I hate to see misinformation so I am making a few corrections. As far as Visual Basic functions and classes go, John, what you need to do is put the effort in and research and understand Microsoft.VisualBasic functions and Visual Basic keywords, consider your needs, and do what works for you. For example, to make the learning process easier, you might want to stick with the VB functions you know, and use the "more .Net" functions as you learn them, but you should also consider that if you are looking to work with or get help from other .Net programmers, you should be wary of features and functions unique to Visual Basic because they make it difficult for C#/managed C++/etc users to work with you. Also understand that Microsoft considers all functions and classes in the VisualBasic namespace to be part of the Visual Basic language, granted that while some programmers agree with this, most disagree. Also, you need to understand what is going on under the hood when you use VB commands. For example, for conversions between numeric types, CInt, CLng, CBool, and CShort are all inlined. This is neater and more succinct in terms of code, and more efficient at runtime, and the compiled code is completely CLS compliant and language neutral. ReDim is merely an abbreviated syntax for array creation. And then many VB functions merely wrap other .Net functions to provide VB6 users a familiar alias, and have no significant effect of performance. Also, Bri's understanding of CType/DirectCast is not entirely accurate. CType will try to cast a value if possible, and if that is not possible it will try to convert the value (i.e. convert a numeric value to its string representation), and if that fails, and exception will be thrown. DirectCast will only cast and will not convert, which means it performs very slightly faster but throws exceptions when a conversion may be available. The TryCast keyword, on the other hand, will return null when a cast fails rather than throwing an exception. Also, you can set a TextBox's Text property to null. In fact, most properties of most classes will treat a null string exactly the same as an empty string. The Visual Basic = operator considers the two (null and empty string) to be equal. As far as your question, what to compare to, well, what have you tried? Whip up a test project and see what works and what doesn't.
-
What exactly is the problem? Do you need a way to detect if you are on the right thread? If so and you are using .Net 2.0, there is a InvokeRequired function that tells you. I don't understand what you are saying about a cast.
-
To be fair, \b is documented in MSDN to be an escape for the backspace character. A search for regular expressions "word boundary" in the .Net 2005 help yields very little helpful information. You could browse documentation all day and never find it.
-
It looks like you are performing your DirectX rendering in the OnPaint method along with the GDI+ rendering. My guess is that what is happening is when OnPaint is called, you render the entire control with DirectX (which will draw over anything on the control, including previous GDI+ rendered graphics) and then do the GDI+ rendering, which is clipped (I don't know whether this is automatic or if you are taking the clip rect into account) to only draw what has been uncovered. Assuming that this is the case, you simply need to take into account the clip rectangle when you do the DirectX rendering so that you don't draw over part of a control with DirectX that won't be finished with GDI+ because of clipping.
-
Why not something like this? \bred\b.*\bblue\b|\bblue\b.*\bred\b The word boundary escape is pretty magical. It makes difficult things very easy. The regex is basically this: either "red" as a word, followed by "blue" as a word, with anything or nothing in between, or the other way around. It would require a single line option and case-insensitivity to work, but it should do the trick. I used all of mskeel's test phrases and got the expected results.
-
problem displaying leading spaces in AxWebBrowser
snarfblam replied to JLSEsq's topic in Windows Forms
Why don't you post some sample HTML that produces this effect? -
There is absolutely nothing with that. It can be very useful sometimes. For example, just say that instead of using a foreach loop, you decided to be crazy and use the IEnumerator yourself. Instead of writing code like this: string[] stuff = new string[] {"A", "B", "C"}; foreach(string s in stuff) { MessageBox.Show(s); } You could write code like this: string[] stuff = new string[] {"A", "B", "C"}; IEnumerator stuffEnumerator= ((IEnumerable)stuff).GetEnumerator(); while(stuffEnumerator.MoveNext()) { MessageBox.Show((string)(stuffEnumerator.Current)); } Granted the code is not pretty and not worth the extra effort, but it demonstrates exactly what the While(Function()) type of loop is good for: when an object has a function that performs an action and returns a value that indicates that it should continue to be looped on/enumerated. In fact, this is exactly the pattern that compilers use for enumerable objects other than arrays. This is decompiled code from a foreach on a List<> object. List<int> list1 = new List<int>(); List<int>.Enumerator enumerator2 = list1.GetEnumerator(); try{ while (enumerator2.MoveNext()) { int num1 = enumerator2.get_Current(); } } [Edit]I guess mskeel writes replies alot faster than I do. And you too, cags.[/edit]
-
The difference is between client-side and server-side. Asp is server-side. It runs on the server, not the end-user's machine, which means that it can't interact with the user in the same manner that a WinForms application can. If you want your web pages to be more interactive, you need to look into something like JavaScript, which runs client-side (but your source will always be available to the user).
-
Not bad. I found the specs for the file online, but I wasn't in the mood for jumping in and making my own complete Win32 icon class. Guess you have more patience than I. What I was trying to do is create a program that will batch process a folder and convert PNGs to ICOs and vice-versa, so that all my graphics that I frequently use for my applications will be available in both formats, saving me the trouble of firing up GIMP or Photoshop and converting them each time I want to use a PNG as an icon. I've made the program one-way so far; using the Icon.ToBitmap method to easily create bitmaps from icons. The problem is that I was using Bitmap.GetHicon to convert bitmaps to icons, which worked great, but Icon.Save creates nasty 16 color icon files. Thanks.
-
From what I understand, the only significant difference between a Span and a Div is that a Div is a block-level element, whereas a Span will have no effect on layout whatsoever. If you put <span> tags around one sentence in a paragraph, the only effect it will have is the formatting from your CSS. If you put a <div> tag instead, that sentence will be displayed as a separate paragraph.
-
In VB.Net, the only control for whether or not integer overflow checking is enabled (as far as I know) is to set it in the project's properties (or using the /removeintchecks switch if you are using the command line). This will effect every integer operation in the assembly though.
-
All windows on the screen? Use the Windows API. There is a function do get the desktop window. Then there are functions to enumerate child windows of a window. Since the desktop window is the ultimate parent of all windows, a recursive enumeration will grab every window that exists. There are function to get information about windows too. You just need to do some research on Windows API functions concerning windows. A google search and a Windows API utility (such as the API Viewer included with VB6, or the even better, free "ApiViewer 2004").