Search Results

Search found 8 results on 1 pages for 'rekreativc'.

Page 1/1 | 1 

  • How to prevent MDI main form closing from MDI Child.

    - by Rekreativc
    Hello! I have a MDI main form. On it I host a form, and I want it to show a message box before it closes (asking the user whether to save changes). So far so good, however I have discovered that closing the MDI main form does not raise a MDI child FormClosing event. I figured I will just call MdiChild.Close() in the MDI main's FormClosing event (which does get raised). This seams to work, however it does causes a problem... In the messagebox that I show, I offer the user to save changes, not to save changes and cancel closing. Normally this works fine, however I can't seem to find a way to cancel MDI main's FormClosing event. Is there a elegant way of doing this? EDIT: I solved this by throwing an exception (when user decides to cancel the closing procedure) which is caught in MDI main's FormClosing event. In this way I know when I have to cancel the MDI main's FormClosing event and this seams to work fine ... However I just can't believe that this "hax" is the only way of doing this. Surely there is a better way?

    Read the article

  • MessageBox doesn't show on mdi form after a long calculation

    - by Rekreativc
    Hello This is a very similar problem to This one, sadly that one was never answered either. I have a MDI Main forum that hosts several children forms. One of them does a long calculation and throws an exception if an error occurs (all work is done on the same thread). I then try to inform the user of an error with an messagebox, however it doesn't appear (but steals focus from the MDI Main, so the application is completely unresponsive). The beheviour changes slightly if I call Application.DoEvents() (evil I know, but this is a last resort thing). Then the forms remain completely active and the messagebox only appears after I change active application (Alt+Tab) to something else and then back again. What can I do to make sure the messagebox will be visible? I have already tried passing both, active child and MDI Main as parameter to the MessageBox.Show method. It doesn't change the behaviour.

    Read the article

  • Accessing a file on a network drive

    - by Rekreativc
    Hello. Background: I have an application that has to read from files on a network drive (Z:) This works great in my office domain, however it does not work on site (in a different domain). As far as I can tell the domain users and network drives are set in the same way, however I do not have access to users etc in the customers domain. When I couldn't access the network drive I figured I needed a token for a user. This is how I impersionate the user: [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)] public static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken); ... const string userName = "Razvoj02"; const string pass = "Programer02"; const string domainName = null; const int LOGON32_PROVIDER_DEFAULT = 0; const int LOGON32_LOGON_INTERACTIVE = 2; IntPtr tokenHandle = new IntPtr(0); bool returnValue = LogonUser(userName, domainName, pass, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, ref tokenHandle); if (!returnValue) throw new Exception("Logon failed."); WindowsImpersonationContext impersonatedUser = null; try { WindowsIdentity wid = new WindowsIdentity(tokenHandle); impersonatedUser = wid.Impersonate(); } finally { if (impersonatedUser != null) impersonatedUser.Undo(); } Now here is the interesting/weird part. In my network the application can already access the network drive, and if I try to impersonate the active user (exactly the same user, including the same domain) it will not be able to access the network drive. This leaves me helpless since now I have no idea what works and what doesn't, and more to the point, will it work on site? What am I missing?

    Read the article

  • Is calling Process.Refresh() required for Process.HasFinished

    - by Rekreativc
    Hello I am interested if calling Process.Refresh() is mandatory when waiting for the process to terminate by checking Process.HasFinished property? I have a piece of code that works fine without the Process.Refresh() call, however I am curious weather this is a coincidence? I can see that a msdn example has the Process.Refresh() call... If its not necessary, and Process.HasExited is the only property I need, are there any advantages to making the call to Process.Refresh() ? If not, is there a reason it is in the msdn example? Thank you for your answers.

    Read the article

  • Return an empty IEnumerator

    - by Rekreativc
    Hello! I have an interface that, among other things, implements a "public IEnumerator GetEnumerator()" method, so I can use the interface in a foreach statement. I implement this interface in several classes and in one of them, I want to return an empty IEnumerator. Right now I do this the following way: public IEnumerator GetEnumerator() { ArrayList arr = new ArrayList(); return arr.GetEnumerator(); } However I consider this an ugly hack, and I can't help but think that there is a better way of returning an empty IEnumerator. Is there?

    Read the article

  • Storing images in a Microsoft SQL Server 2005 database

    - by Rekreativc
    Hello! I have a question about storing an image in a database. I know this topic has been discussed before, however I feel that in my case this is actually a good idea - the images will be small (none should be as large as 1MB) and there shouldn't be too many. I like the idea of not worrying about IO permissions etc. Anyway I have a problem when storing the image (byte[]) to the database type image. Here is my code: OleDbCommand comm = new OleDbCommand(strSql, Program.GetConnection()); comm.Parameters.Add("?", SqlDbType.Image).Value = bytearr; comm.ExecuteNonQuery(); Everything compiles fine, however when I run it, the code only saves the value 63 (0x3F) into the field - no matter which image I am trying to save. What could be the problem? Thank you for your help.

    Read the article

  • Visual studio deployment project error when writing to registry

    - by Rekreativc
    Hello I have a setup for an application that was recently converted to be a framework 4.0 project (don't know if it's relevant). The setup has to write to registry (Local Machine) and until now this has always worked perfectly, however now it fails to write to registry on a clean machine (running Windows 7, 64 bit). The setup does not fail, does not show a warning of any kind, however it does not write to the registry (I even set AlwaysCreate property to true on every key, just in case) which of course causes the application to terminate on startup. What could be the cause of this? I have never encountered such an error before. Edit: I have tried running the installer as administrator, didn't change anything.

    Read the article

  • C# Get video file duration from metadata

    - by Rekreativc
    I am trying to read metadata from a file. I only need the Video - Length property, however I am unable to find a simple way of reading this information. I figured this would be fairly easy since it is visible by default in Explorer, however this looks to be way more complicated than I anticipated. The closest I came was using: Microsoft.DirectX.AudioVideoPlayback.Video video = new Microsoft.DirectX.AudioVideoPlayback.Video(str); double duration = video.Duration; However this throws a LoaderLock exception, and I don't know how to deal with it. Any ideas?

    Read the article

1