Jump to content
Xtreme .Net Talk

snarfblam

Leaders
  • Posts

    2156
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by snarfblam

  1. What happens when the app fails? Are you given an exception? Does it have a DirectX error code?
  2. Keep in mind, reordering the forms every time they become out of order is going to produce flickering, and the active form will always try to force itself on top.
  3. First things first: is this a photograph of a house? Will you be compositing pre-existing images or generating new ones? Complex image manipulation would not be a good starting place for your first app.
  4. I haven't tested this but its the jist of what you need to do: load the file, find what you need to change, change it, and save the file. Dim lines As String() = System.IO.File.ReadAllLines(filename) ' Loop through lines For I As Integer = 0 To Lines.Length - 1 Dim line As String = lines(i) 'Sparate command and value Dim parts As String() = line.Trim().Split(new Char() {" "c}, StringSplitOptions.RemoveEmptyEntries) 'Somewhat validate data If parts.Length = 2 Then 'Check if its what were looking for If parts(0) = nameImLookingfor Then 'Update value lines(i) = nameImLookingFor & " " & newValue.ToString() Return ' Stop looking End If End If Next I 'When done, use File.WriteAllLines to update file.
  5. There you go. But what happens if someone is a really fast clicker and presses the button down and releases it, both between two timer ticks.
  6. Re: Pick two and swap! Another method that guaruntees a random order would be to fill an array by picking random insertion points. Using the 52 example, start by initializing an array with 52 dummy values that indicate that that spot is empty (-1 would be typical, in this case 0 will also work). You start with value 1, and pick a random number from 0 to 51 for the insertion, and place the 1 at that index. Next time, pick a random number from 0 to 50, and count through that many empty spaces (i.e. count through empty spaces, skipping used spots), then put the 2 at the nth empty spot. Then pick a random number from 0 to 49 in put the 3 in that empty spot. Using random numbers with a range equal to the number of empty spots remaining gives all empty spots an equal chance of being used each iteration. Of course, if you are making a card game, you may want to use a more "legitimate" shuffling algorithm to make the game more "authentic".
  7. There is an absolute path to any user's root registry key (they are all located in HKEY_USERS), but you would need to figure out which one belongs to the current user and have admin access to use the keys this way.
  8. What is the problem that you are having?
  9. This is probably what your declarations should look like: Private Declare Function GetCursorInfo Lib "user32.dll" ([color="Red"]ByRef [/color]pc As CURSORINFO) As [color="Red"]Integer[/color] Structure CURSORINFO Dim cbsize As [color="Red"]Integer[/color] Dim flags As [color="Red"]Integer[/color] Dim hCUrsor As [color="Red"]Integer[/color] Dim p As [color="Red"]PointAPI[/color] End Structure Structure PointAPI Dim X As [color="Red"]Integer[/color] Dim Y As [color="Red"]Integer[/color] End Structure It seems like on the webs, most Windows API function declarations for VB are for VB6. A VB6 Long is the same thing as a DotNet Integer: 32-bits. A DotNet Long is 64-bits. Also, the GetCursor function wants a pointer to the CURSORINFO (that is what the "p" in "pc" stands for). When you pass it ByRef, VB passes a pointer (i.e. "reference") to the object. If you pass it ByVal, it would be read-only and the function would be unable to return any data to you.
  10. [PLAIN]Re: Why my operator<< overload doesn't work and prints out a memory location? [C++][/PLAIN] I'm a little fuzzy on my C++ but I think this is your issue. Your overload defines an operator << for ostream and &A (reference to A), but in usage, you have an ostream and list<A*>::const_iterator. The two are not the same, and your operator won't be used. [edit]Or not.[/edit] I guess the Begin method returns a sort pointer? If this is the case, and you have a list of pointers, then you are still passing an A* instead of an A&, though how you get from A* to A&, I'm not sure. Maybe one of these: &**itrA **itrA (compiler will convert to a reference?)
  11. Sorry. My remark about spambots was nonsense, in response to a bunch of spam on this forum (that, for all I know, you never even saw). In all seriousness, what you need to ask yourself is would anyone ever want to inject malicious code into your app, why, and what could they do? The solution depends on the answers, and could be anywhere from restricting security of the code to scrubbing all the input. I'm no security expert, so I recommend reading up on some good security practices.
  12. Just because you are using VS 2008 deosn't mean that the app is DotNet. If you are writing a "C++/CLI" app, then it will be DotNet. If you aren't sure, a simple way to check is see if you can access anything in the System namespace. I don't have much experience with C++/CLI, but from what I gather, libraries are included via a using statement, rather than an include. #include <iostream> #using <mscorlib.dll> #using <System.Text.dll> // ... System::Text::RegularExpressions::Regex ^x = gcnew System::Text::RegularExpressions::Regex("pattern"): The above should compile only if your app is managed (I haven't tested it either way).
  13. As far as I know, this would only be the case if your app is managed (DotNet).
  14. Yes. Spambots.
  15. In this sort of case I tend to scan the string char by char seeking for delimiters, extracting substrings. In the event of anything unexpected (extra delimiters, invalid number format, early string termination), I would consider the input invalid. Regular expressions might also be an option.
  16. Just a note, appropriate security considerations should be made. (Do you trust the source of the messages? Could malicious HTML be inserted into the messages? etc..) The idea in your code is certainly right. There is no limit on the size of the tag; it is just an object reference. The only limit is that of the string class: roughly 2 gigs.
  17. You can set the WebBrowser.DocumentText property. For example, using C# Express, I created a WinForms app, added a Web Browser control, and used the following code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); webBrowser1.DocumentText = "<HTML><HEAD></HEAD><BODY><OL><LI>1</LI><LI>2</LI></OL></BODY></HTML>"; } } } The output was as you would expect...
  18. I don't quite understand. Are you looking to do something like this? [sTAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Form1 mainForm = new Form1(); [color="DarkGreen"] // Custom initialization[/color] Application.Run(mainForm); } Or something else? Also, I would recommend using Application.Run over ShowDialog. It really probably doesn't matter, but Application.Run is the accepted standard, and it might be doing some initialization (Application class) or cleanup (after the main form closes) that ShowDialog doesn't (it's hard to find clear documentation on the subject).
  19. Looking at just your console app, I changed the definition of Program to class Program { Button button1; ListView listView1; [color="Red"]public Thread MainThread;[/color] static void Main(string[] args) { Program pgm = new Program(); [color="Red"]pgm.MainThread = Thread.CurrentThread;[/color] pgm.Go(); Console.ReadLine(); } /* . . . */ void Thread_Report(int step) { [color="Red"]Console.WriteLine((Thread.CurrentThread == MainThread).ToString());[/color] } // ... The output was false. It looks as if you expect the Delegate.Invoke method to behave as the Control.Invoke method does. Delegate.Invoke will run the target method on the thread from which it is called. For a quick solution, you could change the Thread_Report method as follows: void Thread_Report(int step, object data) { [color="Red"] if (InvokeRequired) { Invoke(new AppropriateDelegateType(Thread_Report), new object[] { step, data }); return; }[/color] if ((data != null) && (data is DataTable)) { DataTable table = (DataTable)data; // ... You would have to do this for each cross-thread invocation however. The background-worker uses a more elaborate technique for the thread-safe calls, based on a SynchronizationContext object.
  20. Bing isn't supposed to or expected to overtake Google. It's really just meant to increase Microsoft's market-share. Likewise, Google couldn't expect to take over the desktop OS market, especially considering the number of great Linux distributions out there and the fact that they hardly make a dent in Microsoft's market-share.
  21. Why not display the file's name via the description property of the FolderBrowserDialog? I.e. folderBrowserDialog1.Description = "Select a folder to save A.zip"; Either that, or ignore the filename specified by the user.
  22. Why not use the array creation syntax rather than memory allocation functions? I'm far from a C++ expert, but it seems more natural to me to write integer = new int[size]; than integer = (int*) calloc (size, sizeof(int)); As far as realloc() goes, does it deallocate the memory the poiner points to then reallocate new memory? Does it preserve data?
  23. Have you tried reading a string from the stream? This should read an entire line. Then you could process the string char by char, or validate it as a whole.
  24. Here. It's not very usable in its current form, and I didn't correct all the P/Invoke signatures, just those that threw exceptions. Also, there is some extraneous stuff in there from my tinkering around; the important stuff is what I highlighted above.TransparentFormThing.zip
×
×
  • Create New...