Cags
Avatar/Signature-
Posts
699 -
Joined
-
Last visited
Cags's Achievements
Newbie (1/14)
0
Reputation
-
Foreward I recently ran into a very annoying problem whilst developing for the Pocket PC. How to create an application that was full screen? The simple answer to this is you create a Form with it's WindowState property set to Maximised and set the Menu property to null. I wasn't happy with this however as although I didn't want the TaskBar and the SIP Icon, I still wanted to allow a menu. Solution 1 Many places I looked suggested that the way to get around this was to use the SHFullScreen API. The way this works is by moving the items passed into dwState below the object with the windows handle passed into hwndRequester. I'm not going to go into too much detail, but sufficed to say I could not get this method to work to a satisfactory standard. The problem is that many things can cause the Z Order to be changed back to it's initial state which causes the SIP Icon to suddenly re-appear. One annoying thing that used to trigger this was selecting a top level MenuItem, then not selecting a child MenuItem, but instead clicking back on the form. NB. SHFullScreen is generally in aygshell.dll however it's in coredll.dll on the Pocket PC Declare Function SHFullScreen Lib "aygshell" (ByVal hwndRequester As Long, ByVal dwState As Long) As Boolean [DllImport("aygshell.dll")] private extern static bool SHFullScreen(IntPtr hWnd, long dwState); Solution 2 Still determined to come up with the effect I wanted I continued on experimenting/researching. Eventually I came across some articles which used a differen't method. Namely moving the items off screen so that the form can be resize in thier place. The solution I came up with uses the following three API Calls... [DllImport("coredll.dll")] public static extern int FindWindow(string LPClassName, string LPWindowName); [DllImport("coredll.dll")] public static extern int GetWindowRect(int hwnd, ref RECT rc); [DllImport("coredll.dll")] public static extern int MoveWindow(int hWnd, int X, int Y, int cx, int cy); The basic theory is as follows. The constructor of the class gathers the required info for each item. This information is the Handle and its Location. This information is then stored for later use. A reference to the form is stored as it's possible its handle will change. public ScreenHelper(System.Windows.Forms.Form mainForm) { _parent = mainForm; hiddenItems = new ScreenItem(); GetWindowRect(FindWindow(null, _parent.Text), ref rtFormDefault); hWndSipButton = FindWindow("MS_SIPBUTTON", null); GetWindowRect(hWndSipButton, ref rtSipButton); hWndTaskBar = FindWindow("HHTaskBar", null); GetWindowRect(hWndTaskBar, ref rtTaskBar); hWndSip = FindWindow("SipWndClass", null); GetWindowRect(hWndSip, ref rtSip); } There are two other public methods, they are ChangeItemVisibility and ResetScreen. I won't cover the code too much here as its in the file, but essentially ChangeItemVisibility accepts a flagged enum, which allows you to alter whether an item is displayed on screen or not. The ResetScreen method is very important as it replaces all the items in their correct positions. It is very important that this message is called before the application is closed otherwise the user may have to reset their device in order to get the items back. To use the class successfully in an application you will need to call ChangeItemVisibilty each time the application gets control and call ResetScreen when your application looses control. To-do this I override the OnActivated and OnDeactivated events. It's also worth noting that OnDeactivated is not called when you call Application.Exit(), so be sure to add an extra call to ResetScreen() before calling it. Afterword Well I'm no Guru, but I thought that since this problem caused me a lot of headaches, I'd share the solution I came up with. Attached is a sample project which contains my ScreenHelper class. Feel free to use it or any parts at your descretion, no guarantee implied etc, etc. Comments, suggestions, bug reports all welcome. References The following is a list of the main articles that helped me create my ScreenHelper class. pocketpcdn.com http://support.microsoft.com/kb/q266244/ http://www.codeproject.com/netcf/netfullscreen.asp
-
I doubt it's impossible. But it would probably require low level hooks, something which can be frowned upon talking about in open forums because of the possibility of missuse.
-
The way I understand it is that your old CD player isn't doing anything special, it doesn't need to extract anything because the files are on the disc just like they are on any other disc. The trick is your computer is lying to you about whats on the disc based on a piece of malware (rootkit) thats installed when you insert the cd. The files are there you just can't see them, the .exe either simply knows the files true location so can play them back, or alternatively authenticates with the malware to allow access to the files. As far as I can tell from the article provided by PlausiblyDamp, the EULA doesn't state the software will be installed on your computer, and there is no option to remove it, whats more it sloppily attempts to disguise itself as something it's not (a plug and play driver), this in my opinion should be illegal (if it actually isn't). Sony should be as accountable for this type of behavior.
-
Fair point, the re-writting would somewhat throw an anchor in the works. I was trying to come up with a linked list solution, but I guess that would work similar to your suggestion of blanking out the source array in as much as you'd have to count through the items. As the only coding I've done in the last year is some PHP though, I'm glad I came up with a solution at all :)
-
Can you not simply run the replace code only when you output the data from the database? So it will be stored in your db as \r\n or whatever, but before you output the data you replace that value in the string you fetched from the db.
-
Just to put another option into the mix (don't think it was covered, but it's late). Populate an array with the numbers in sequence. Then use Rnd() to choose a random index between 0 and the length of the array -1. Remove the value from the original array and add it to a second array. Rinse, Dry, Repeat until array 1 is empty. Voila a randomly ordered list. Probably not as efficient as some solutions suggested, but just thought I'd throw it out there.
-
If the string will always start exactly like that you can simply crop the file:/// part off the start of the file using something like the SubString method. I believe .Net can function on path names that contain / the same as if it is a \ but if not you can use the strings Replace function to change them all over.
-
Technically I would have thought the best way to create the string would be using the StringBuilder class. If I had to choose one of those methods I'd have personally done it using method #2. The string class is immutable, which makes using += a slow method. I cannot however say for sure this doesn't also make using the & equally as inefficient.
-
You will have to maintain a static list of open forms so that they can be closed from the closing event of the current form. Application.Exit() will also do the job, but isn't the best idea because it just 'yanks the sheet from under' your application rather that closing tidily.
-
techmanbds' suggestion would work, but would require coding every single menu item individually at design time, which isn't possible if it's a dynamically created item. A more generic method could be used by attaching an event handler that simply casts the sender object then gets the text. ' your method would look something like this Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim mnuItem As MenuItem = DirectCast(sender, MenuItem) MessageBox.Show(mnuItem.Text) End Sub ' ' and just so you know, it would be attached to the event like so AddHandler MenuItem2.Click, AddressOf MenuItem2_Click
-
You are using two different types of array as the error message points out to you. ' This code creates a 1 dimensional array of 1 dimentional arrays Public MapArray()() As Short ' you would get the first item of this using MapArray(0)(0) ' ' Wheras this code creates a 2 dimensional array Dim MyArray(10, 10) As Short ' you would get the first item of this using MyArray(0, 0) You problem solves itself if you stick to using one style or the other.
-
Unless I'm mistaken, you can't initialise a class library because it isn't an object. The simplest way to initialise objects within a class library is to have a static (shared) method called Initialise, which you would call at some point before you would require the objects, in your forms contructor for example.
-
Triggered ListBox event when items are added [C#/CS 2005]
Cags replied to Shaitan00's topic in Windows Forms
If you wanted to find the text in the lstBox you would simply use the last index. You don't really need an event as you can just call the method to send the text directly after calling lbChatBox.Items.Add(stext), that way you can send stext and don't have to worry about retrieving the text from the lstbox. -
TryCast is certainly the better solution I couldn't remember the keyword as I didn't have VS handy, plus I use VS 2003. The code provided by PlausiblyDamp would work perfectly fine so to say it's nothing todo with DirectCast is merely a matter of opinion. Your VS 2003 code does pretty much the exact same thing except it uses CType. To the best of my knowledge CType does the same job as DirectCast except it won't error if the object passed in is not of the right type. Since the code checks the type anyway this is somewhat irrelevant.
-
The GetItemAt method assumably returns an object (or type Object), the as keyword is used to cast the object to the left of it to the type listed on the right. // cast the returned object to type EXListViewItem this.GetItemAt(e.X, e.Y) as EXListViewItem // different way of writing the same thing (EXListViewItem)this.GetItemAt(e.X, e.Y) In VB I believe you would use DirectCast. The code would look something like the code below, forgive me if thats not entirely right haven't got Visual Studio handy and casting isn't somthing I've handled much in VB. Dim lstvItem As EXListViewItem = DirectCast(this.GetItemAt(e.X, e.Y), EXListViewItem)