Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

MilesAhead

@MilesAhead
About
Posts
17
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • AddContextMenuItem multiple files
    M MilesAhead

    There are two approaches that come to mind. First is write a dynamic shell context menu handler that stores all the files selected in the IShellExtInit::Initialize method. This is pretty easy in C++ using one of the wizards you can find here on the Code Project. In C# it's a bit more hairy though. The easier approach in C# would be to modify your app so that it only runs a single instance and any additional instances just pass the command line to the first instance. I'm pretty sure there are examples here of C# single instance apps. Then it's just a matter of passing the command line info. Search on single instance apps in C# here and you should get some working code so you can see various methods to pass info from one instance to another.

    C# com tools

  • C# and DLL's
    M MilesAhead

    Did you try searching knowlegebase for a bug report? You can't be the only one seeing DLL load lag if that's what's happening.

    C# csharp c++ help question

  • C# and DLL's
    M MilesAhead

    Hmm, seems to me I've heard MFC doesn't play nice with other frameworks. And .NET is a framework. I've run into some strangeness with MFC. I remember I was experimenting with forms in DLLs and had one done in Delphi that I launched from a VC++ 6.0 MFC app using a worker thread. No matter what I did when I closed the DLL form, I got an exception. However if I displayed a messagebox in the VC++ app after closing the form, I never got an error. I chalked it up to Delphi having a VCL and MFC not being at the root of all the GUI stuff, but who knows? Of course the Delphi DLL form worked fine with every other app I used to launch it, such as Delphi and VB 6.0. Go figure. :)

    C# csharp c++ help question

  • disable all keys including Ctrl+alt+Del
    M MilesAhead

    Apparently if you replace one of the system DLLs on NT based system you can bypass control-alt-del but I forget the name of the DLL in question. If you google for NT Admin Tips you might find it and where to get the replacement DLL. I'd advise against this modification without client permission though. :)

    C# question

  • Remove Confirm Dialog After Confirm?
    M MilesAhead

    The simplest method would be to break the MessageBox.Show call out of the if block. DialogResult dr; dr = MessageBox.Show(yadda, yadda) if(dr == whatever) { .. do tons of whatever stuff }

    C# question csharp xml

  • COM Object
    M MilesAhead

    I don't think I've run across anything like that. Do you know if the ActiveX was implemented in VB by any chance? I ask because I've seen some references to VB ActiveX or COM objects not being marked with the "creatable" attribute on some of the Delphi ngs. Other than that I'm afraid I don't have any idea. Perhaps google on the GUID or CLSID and see if this control shows up in bug reports is all I can suggest. Sorry I couldn't be more help.

    C# com asp-net question

  • how difficult does getting an instance by handle have to be?
    M MilesAhead

    Okay, I think a more straight-forward solution to what you want to do, provided both applications are on the same machine, is to use shared memory via Memory Mapped Files. C# is a bit of a pain in that it only gives the PInvoke mechanism for doing Win32 stuff, but using a page of swap file in a memory mapped file for shared memory isn't that difficult. There are a couple articles showing how to get at memory mapped files from C# on Code Project. Also you can use the tool at http://pinvoke.net to pull the prototypes adjusted for C# right into the editor for you. The main advantage of using a named memory mapped file with app instances is that you don't need to worry about handles. Using a GUID string in the memory mapped filename makes sure it's unique. So in your application you try to create the Memory Mapped File with CreateFileMapping(). If you get a handle but Marshal.GetLastWin32Error() returns ERROR_ALREADY_EXISTS then you're in the secondary instance. Otherwise if the creation succeeded you're in the primary. The secondary instance copies info it wants to send to the primary in the shared memory. The primary instance reads it out. To avoid mangling the data you can use a mutex to control access. Before it quits, the secondary instance gets the mutex, copies the info to the shared memory, releases the mutex, then exits(if that's what you want it to do.) The primary gets the mutex, checks for new data in the shared memory, if it finds it then it copies the data out, then releases the mutex. It sounds a bit more complicated than it is. I would look for examples of Memory Mapped Files. Using one page of system swap file is the simplest case with fewest system quirks to worry about. As I suggested, the TellTail component on www.torry.net does what you're trying to do. Delphi is pretty Enlish-like so even if you don't program in it often you can read the source and get the gist. Besides, Win32 calls are going to be pretty much the same no matter what language you call them with.

    C# tutorial regex question

  • how difficult does getting an instance by handle have to be?
    M MilesAhead

    What's the desired interraction between the app instances? One instance "getting" another isn't very specific. Give a bit more detail and maybe someone can get you started.

    C# tutorial regex question

  • COM Object
    M MilesAhead

    Have you tried importing it into the Toolbox and dropping it on the main form of a test application? Perhaps if that works you can look at the Form Designer generated code for clues.

    C# com asp-net question

  • How do I do double-click file opening with my C# app?
    M MilesAhead

    There are several approaches you can take to transmit the command line info(such as the filename) from the secondary instance of your app to the primary. You can use sockets, windows messaging, shared memory etc.. I did an ActiveX Control that uses a page of the system swap file with a memory mapped file to do it. It works with just about everything I've tried that can understand ActiveX. If you can read Delphi, the source to the component that the ActiveX Control is derived from is online. http://www.torry.net Search on "TellTail" to download the Delphi source. Basically it uses a named mutex to determine if you're in the primary or secondary instance of the app. If in the secondary, it copies command line info to the shared memory page. The primary instance has to periodically check if any info has been put in shared memory then call a method to copy it out. I'm reworking it now to use the 'Global\' namespace if in XP for the named kernel objects but I may also change it to use a system event to eliminate the polling in the primary app. When the next revision comes out I'll have to decide how I'm going to distribute it. But for now the Delphi source might give you some ideas how to do it in C#. Good luck.

    C# tutorial question csharp data-structures

  • Reading a txt file to set properties ?
    M MilesAhead

    Sounds like what I use .ini files for. I think there's a C# article on Code Project that encapsulates WritePrivateProfileString and ReadPrivateProfileString. Or you could DLLImport them and roll your own. Delphi has a pretty nice TIniFile class so what I did was write a dual-interface COM wrapper for it so I could use it with anything that can use COM. I haven't tried it with C# yet though. It worked fine with VB 6 and VC++ 6.

    C# tutorial question

  • MessageBox
    M MilesAhead

    You might look around and see if anyone has done a C# SplashScreen Control. I'm new to C# but in Delphi the usual scheme for a roll-your-own splash screen is just to dynamically create a Panel with a bunch of labels to display your text. Then use a timer to destroy it after so many seconds.

    C#

  • Returning multiple values from methods
    M MilesAhead

    Python allows similar multiple function returns and assignments. As the Python developers will tell you, they are mearly implemented as "syntactic sugar." There's no need for such to bleed down to the lower implementation level in this case either. I've only been messing with C# for a short time but since I tend to use a lot of Win32 API calls more than multiple assignment I'd find useful a tool where I could put the cursor on one of those all caps DEFINES and have it paste in a const with the correct value from one of the Windows.h includes. Hunting that stuff down and typing in const declarations is the pits! :) What a waste of time!

    C# csharp design collaboration help

  • Component Exception vs Error Event??
    M MilesAhead

    I wrote a C# component for application instance control that I'm enhancing and I wanted to get some programmer opinions. The component is designed to be dropped on the main form of the application. As a programmer using the component would you think it more convenient to have an error event or to throw an exception? Coming from Delphi I think it's convenient to create the error handler using the component property page in the IDE but I'm not sure if that's considered bad form (no pun intended) in C#? The other approach I could take would be to check if the error event is assigned and throw an exception as alternative. Any thoughts? TIA

    C# visual-studio discussion csharp delphi help

  • Initialize control dropped on form?
    M MilesAhead

    Just FYI after playing around for about 6 hours I hacked my way into a component that will initialize the way I want when dropped on a form. Maybe I'll work up a short article showing how 'cause it's definitely a feature that's very convenient. When my C# programming book arrives in the mail I'll consult that first of course. :)

    C# csharp delphi design question

  • Initialize control dropped on form?
    M MilesAhead

    Wow! That's like, way too much work. All I'm trying to do is create a convenience where a component is dropped on a form and a unique string is generated to ID the app as a property of the component. I'm coding a simple instance component where the programmer can set the number of concurrent instances allowed to run on the same machine. In the Delphi version (s)he just has to drop it on the form and call one method on app startup. Looks like in C# I'll have to settle for a string property with a suggestive name( "GuidString" ) to hint that the programmer should use a Guid Generator utility to paste a unique string in this property. It works just as well but it's just cooler if it would fill in without the programmer's intervention. Unfortunately with C# if you use any contructor you get a different Guid every time the form is created, which is no good for my purpose. Oh well.. can't have everything I guess! :) Thanks for the info. I would have looked around for days only to find there ain't no easy way to do it! :)

    C# csharp delphi design question

  • Initialize control dropped on form?
    M MilesAhead

    Hi. I'm new to C# and I'm trying to create C# implementations of Controls I did in Delphi in the past. In Delphi there is a flag 'csDesigning' that will be set in 'ComponentState' if you're in design mode. Using that I can do stuff like create a Guid String to get a unique program ID and the control can do stuff like File Mapping or whatever to share data between instances of the same app etc.. In C# I see something called 'DesignMode' but it seems like it's always false! Is there an easy way to set properties when a UserControl is dropped on a form that will be the same for all instances of the application? IOW, if I create a Guid String just using a constructor I'll get a different string for each app instance when I want the property values to be the same for all app instances, but be unique in each app where the control is used. This one has me baffled! TIA

    C# csharp delphi design question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups