snarfblam
Leaders-
Posts
2156 -
Joined
-
Last visited
-
Days Won
2
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by snarfblam
-
Why can't you close the main window?
-
Don't you have to specifically target mono (idk, in #Develop, it gives you an option between microsoft and mono)? Also note that if you build an app on VB.Net 2003, and target framework 1.1 (this is the default setting), it will not run on 1.0. You must go to the project properties and set the target to "Both Microsoft .NET Framework v1.1 and v1.0 (advanced)".
-
Private Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Int32) As Short It is pretty simple to use. Try experimenting. I figured out how to use it by throwing it into VB6 and whipping up a quick test app. GetAsyncKeyState returned a negative value for the following keycodes when control and F1 are being held down: 17 (control), 162 (left control), 163 (right control), and 112 (F1). Here is a crazy idea: search MSDN. From http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/getasynckeystate.asp
-
An implicit conversion would be one like this, where the conversion is not explicitly stated (therefore, implied): Dim X As Integer = "12" Dim Y As Integer = 1.0F What is the behavioral difference between (int)String and Convert.ToInt32(String)? Shouldn't they both throw an exception if the number format is invalid and succeed if it isn't? (Also, note that functions like CInt are not there for legacy purpose. For conversion between numeric types, these "functions" are inlined, where as calls to the Convert class are not, and CInt is much easier to use than the clumsy CType casting syntax.)
-
Need help implementing GDI drawing in .net
snarfblam replied to qmp's topic in Graphics and Multimedia
My two cents about DirectX: Is it worth learning? If you will really benefit from it, yes. Is it as easy as GDI+? Not nearly. It is not incredibly difficult, but GDI+ is very intuitive, and practically self-explanitory. DirectX is worth the extra effort if you need a performance boost, but I do not regret putting off learning DirectX as long as I did. I managed just fine without it until now. -
I would imagine that the antialiasing settings could be in different places, depending on the software that came with your graphics card. I can access my antialiasing settings through the system tray or by going to Control Panel->Display->Settings->Advanced->GeForce4 Ti 4200 (my card)->Additional Properties->3D Antialiasing Settings. If your hardware is not set to override an application's preference, then unless you explicity enable antialiasing in your app, it shouldn't be antialiasing. P.S. Just a thought, have you considered that this might also be due to texture filtering? Do you have something like anisotropic filtering enabled?
-
Your user control could raise events that pass the relevant data. In the listview's SelectedIndexChanged event handler, you could raise your own event. (If you don't know how to implement events, check the MSDN.)
-
I certainly did not have the same problem. I took a form, added a picture box, assigned it an image that contained large portions of white, set the transparency key to white, and the white regions became transparent at runtime. Make sure that you have the transparency key set to exactly the right color, and of course, use a lossless image format for you skin. If you are assigning the image at runtime, try to set the transparency key after you assign the image.
-
I don't quite understand what you mean.
-
Another chapter in my never ending quest to micro-optimize. Anyone up for a long read? I was thinking about structs. I make a lot of use of them, because I hate to create garbage collected objects when they aren't neccessary. I prefer to let the memory be reclaimed when they go out of scope and save the memory used to manage the object. (Of course, I use classes when they are appropriate, too.) But I was wondering about using struct constructors. When you use the StructInstance = New Struct syntax, I would image that a new struct is allocated on the stack, initialized to default values, the constructor is called, then the newly allocated struct is assigned to the original. If you were to create a static intialization method, however, you could avoid the creation and intialization of a new struct on the stack. I reasoned, however, that the inefficiencies of using a constructor to assign a value to a struct would be optimized out. Of course, I had to see for myself. I coded a constructor, and disassembled it, and discovered that indeed, a new struct is allocatated, initialized to default values, the constructor is called (we are essentially initializing twice, here), and then is assigned back to the original struct. I did this with a release build because this is the build that the end-user will be using. I created a test struct with a constructor and a static method both of which could be used to initialize an already allocated struct. Public Structure TestStruct 'Members 1 through 5 Dim M1, M2, M3, M4, M5 As Single 'Using constructor to initialize Public Sub New(ByVal A As Single, ByVal B As Single, _ ByVal C As Single, ByVal D As Single, ByVal E As Single) M1 = A M2 = B M3 = C M4 = D M5 = E End Sub 'Using shared method to initialize Shared Sub StaticInit(ByRef Struct As TestStruct, ByVal A As Single, _ ByVal B As Single, ByVal C As Single, ByVal D As Single, ByVal E As Single) Struct.M1 = A Struct.M2 = B Struct.M3 = C Struct.M4 = D Struct.M5 = E End Sub End Structure And of course we have a function to test these two methods: Sub Test() 'Struct to be initialized Dim Struct As TestStruct 'Times to init struct Dim Times As Integer = 10000000 'Test static function Dim Start As Integer = System.Environment.TickCount For i As Integer = 0 To Times TestStruct.StaticInit(Struct, 1, 2, 3, 4, 5) Next Dim FirstTime As Integer = System.Environment.TickCount - Start 'Test constructor Start = System.Environment.TickCount For i As Integer = 0 To Times Struct = New TestStruct(1, 2, 3, 4, 5) Next Dim SecondTime As Integer = System.Environment.TickCount - Start 'Display results MessageBox.Show(FirstTime.ToString & " " & SecondTime.ToString) End Sub Well, I was dissapointed to see that the constructor, the easier and more intuitive method, ran considerably slower than the static intialization function. The results for six runs were as follows (timed in milliseconds, .ctor = constructor): Run .ctor Static | Run .ctor Static 1 551 160 | 4 521 190 2 531 160 | 5 521 190 3 541 160 | 6 521 190[/Code] In the last three runs, I reversed the order of the loops, testing the constructor first and then the static method. This also begs the question as to whether one method or the other is faster when initializing a struct when it is allocated, i.e. [font=Courier New]Dim X As New Struct()[/font] vs. [font=Courier New]Dim X As Struct : Struct.Init(X)[/font]. Using a similar test, these are the results that I got, again, switching the order of the tests on the second set of runs: [Code] Run .ctor Static | Run .ctor Static 1 360 170 | 4 441 170 2 351 160 | 5 351 170 3 350 170 | 6 361 170[/Code] It looked a little better for the constructor in the second test, but still disappointing. Of course, you're wondering when you will need to initialize ten million structs, and of course the answer is never. But maybe knowing that constructors aren't particularly efficient can help you sort out a bottle-neck issue someday, or give your Direct3D game a speed boost when you create hundreds or thousands of vertices.
-
Do you have a list of strings that you want to process? To use regex like that you would really need a more general format. Do you want to extract the last four chars in a string? Any occurances of two digits followed by two letters? The third word in each string?
-
Forms support a transparency key. Any color on the form that matches Form.TransparencyKey will be drawn transparently. This makes skinning real quick and easy. Just pick a color, say magenta, and in the background image, draw transparent areas as magenta. In the form's property, set the TransparencyKey to magenta. Pow! Nifty skins.
-
Also note that the Bitmap class has a constructor that accepts a filename. (Less typing is always a plus) Bitmap PictFromFile2 = new System.Drawing.Bitmap(filename); [/Code]
-
I love the collapsible code and regions. You can hide most of what you don't need at the moment and focus on what you are doing. I have to be honest, though. Long before I heard about it from Microsoft, the idea occurred to me, but my vision of collapsible code went further than Microsoft's, and I was slightly disappointed when I got VB.Net and it wasn't all that I had imagined. This is closer to my vision of collapsible code, and I am considering creating my own control with this functionality, but it is a shame that I will never be able to edit my VB code this way. It is almost like a class view (with the contents limited to the file you are viewing) except that when you expand a node, the full code is displayed. (Obviously, this image is fabricated.) http://ilab.ahemm.org/col.gif The collapsed code looks much less cluttered with only the identifiers and no keywords, and the programming elements (classes, methods, etc) are still identifiable by the images. I also think it would be nice if programming structures smaller than methods could be collapsed, as displayed in my image. Of course, this restricts you in some ways. You lose any control over white spaces beyond the ability to add blank lines. This might drive a C++ programmer insane. But overall, this would be my ideal code editor.
-
Need help implementing GDI drawing in .net
snarfblam replied to qmp's topic in Graphics and Multimedia
So... are you using VB6? If you are using .Net, you can invalidate only a specified region on a control. The control.Invalidate method has several overloads. Depending on the size of a control, it is very possible that invalidating the entire control would not cost enough performance to be of a concern. If it is about 100x100 or smaller, I wouldn't worry about it, but it sounds like you might be working with something larger. If you are using VB6, you might consider going to the Xtreme VB Talk boards. There is a link on the front page of this site. -
.NET Framework v2.0 --> 2002/2003 support?
snarfblam replied to ThePentiumGuy's topic in Water Cooler
But the VB.Net 2003 IDE isn't programmed to deal with things like generics and operator overloading. I don't know how these are handled in Vs 2005, but I think they might cause problems in the 2003 IDE. -
Something like Me.Cursor = Cursors.WaitCursor You get a list of predefined cursors, just like you do colors, pens, and brushes.
-
Cerainly works. I like the label better though. It's... smaller.
-
Need help implementing GDI drawing in .net
snarfblam replied to qmp's topic in Graphics and Multimedia
I haven't looked into the next version of GDI+. I don't see how this depends that much on the system either way, and I've never heard of a test where GDI+ performed better. Maybe someday that will change. Today, GDI is faster, as long as "what you're doing" is a simple bitblt, and it's never going to get slower. We can't make a program today based on standards that are expected to improve later, and this topic is not about which will be faster later, its about finding a solution now. gmp, I doubt that GDI+ will be unable to meet your needs. If you haven't already implemented a GDI solution, give GDI+ a whirl. It's "the way of the future" and you ought to get used to it, better sooner than later, and I think it is easier anyways. -
Perhaps what you need is the ListViewItem.SubItems property. Looking at the first item in your listview (LastNAme=1, Company=2, etc.) that ListViewItem's sub items would be "1", "2", "3", "4", etc. Is this what you need?
-
As far as I know you can not set the scroll amounts for the scroll bars on a scrollable control. The scrollbars in VBA had a LargeChange and SmallChange property, but you don't have direct access to the scrollbars with a scrollable control. If I am right, then I would suppose that the easiest way to get the level of control you want would be to implement your own scrolling.
-
Need help implementing GDI drawing in .net
snarfblam replied to qmp's topic in Graphics and Multimedia
What hasn't been your experience? The performance difference? Just set up a quick benchmark app. I made an application that drew level screens out of 16x16 tiles in a 16x11 grid. As you navigated the map in VB6 with GDI, the screens seemed to appear instantly. When I ported to VB.Net and GDI+, you could see the level screens being drawn. It was not as smooth and professional. It was clicky and laggy, and my computer is reasonably fast, 1.5 ghz. I would hate to see how it ran on an older machine. Other people have told me that GDI+ is faster, but after doing an actual test, were surprised with the results, and conceded that GDI is certainly faster in the realm of bitblts. This may or may not apply to vector graphics. I don't know, but bitblts are appearently not as optimized in GDI+. -
.NET Framework v2.0 --> 2002/2003 support?
snarfblam replied to ThePentiumGuy's topic in Water Cooler
Exactly. I don't see it happening. Anyways, many features in the 2002/2003 IDE were designed to suit the .Net Framework 1.0/1.1, and new changes would probably break compatability. -
I figured out what my issue is. I feel pretty stupid for this one. I had set anti-aliasing to always on in my hardware settings. I turned it off and my game looks all spiffy now. Did I mention that I feel pretty stupid? Thanks for everyone's advice, though.
-
Need help implementing GDI drawing in .net
snarfblam replied to qmp's topic in Graphics and Multimedia
I am pretty sure that this is not true. As far as I know, GDI+ is a whole new library. It many includes new features such as alpha blending, antialiasing, and image resizing/interpolation. From my experience this isn't true. I have not tested vector graphics and text rendering, but with image blitting, GDI+ is actually notably slower.