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
P

Patric_J

@Patric_J
About
Posts
25
Topics
10
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • StatusStrip don't process mouse clicks if parent window is inactive.
    P Patric_J

    StatusStrip don't process mouse clicks if parent window is inactive. I have an application with two winforms, one which has a StatusStrip object. The StatusStrip object has a couple of buttons with mouse click handlers hooked up. If the window with the status strip is the active window, the mouse click handler get called when user clicks on a button on the status strip. If the window with the status strip is not the active window, it takes two click on a status bar button to get the mouse click handler called. The first click only activates the window and do not result in a call to the click event handler. Anyone knows how to fix this? How to get a status strip to fire events even if it is in a nonactive window so user don't have to click twice?

    /Patric My C# blog: C# Coach

    C# csharp winforms com help tutorial

  • Advanced merge of xml documents
    P Patric_J

    Hi I need to merge several versions of xml documents which contain different data. I can't just append one document to another, instead it need to substitute elements which are the same (meaning having same tag in a hierarchy). One file will have higher precedence than the other and would substitute the data of the other one if same tag. I think an example would explain better than words. David Ellis 2006 M R 2005 Neil Marshall David R. Ellis USA R G 2003 Andrew Stanton David R. Ellis 2006 R USA R 2005 Neil Marshall G 2003 Andrew Stanton Notice in the merged version that for example director for Snakes on a Plane been updated and country added to same movie. Is there any way to do this using standard tools, like C#/.NET or SQLServer 2005 or some other library/product? Or do I need to implement this myself? Thanks for any pointers, Patric /Patric My C# blog: C# Coach

    XML / XSL csharp tools xml tutorial question

  • C++ Jobs in Finance/Hedge Funds etc
    P Patric_J

    Most likely they want you to be really good at object oriented programming and multithreaded programming. If you are applying for a server position you should also know socket programming. Managed C++ is not used here on Wall Street unless to build a wrapper around some legacy C++ code so it can be called from C# code. C# is becoming more common, specially for frontend applications.

    /Patric My C# blog: C# Coach

    Work Issues c++ question csharp design oop

  • Q about job: I have chances or not?
    P Patric_J

    At my company (financial software shop in NYC) most developers are non-american. It's hard nowadays to get working visas, they run out early so it will take a year or so from that you have a job offer to when you can start working. You usually have to come to US to look for jobs and do interviews, you can't do that from abroad. Your English must be much better than it is now. Also, you say you have many years of programming experience, but companies normally only count the time you worked as programmer after university and then you only have one year of programming experience, which is little short to be able to land a visa. I had 5 years of professional programming experience and it was still tough to get a job here. However, the jobmarket in NYC is great for C++ programmers, specially if you have some financial background also. Good luck /Patric My C# blog: C# Coach

    Work Issues c++ com game-dev php html

  • Keyboard Events
    P Patric_J

    Hi, I'm curious, why would a form need to catch keyboard events? What are you using it for? I can't think of any scenario where this can be used. /Patric My C# blog: C# Coach

    C#

  • Creating conditional windows application
    P Patric_J

    Check Paul DiLascia MSDN Magazine column where he discusses this, unfortunately for you its C++ but still its a good article about the problem: Color Support, Console Apps, and Saving User Settings -- MSDN Magazine, February 2004 /Patric My C# blog: C# Coach

    C# question help

  • Opening system menu with code don’t work
    P Patric_J

    Thanks, it works. /Patric My C# blog: C# Coach

    C / C++ / MFC question csharp com

  • Opening system menu with code don’t work
    P Patric_J

    Hi, I want to open the system menu of a window from code instead of as usual letting the user do it by right mouse-clicking on the top left icon. I use GetSystemMenu() to get the system menu and TrackPopupMenu() to display it. The system menu shows up but when I click on any menu item, nothing is routed back to the window. OnSysCommand() which normally receives system menu clicks is not called. However if the system menu is opened by the user as usual, everything works fine. What do I do wrong? How do I trap the menu item clicks? Here’s the code from my test project, a standard dialog based application, TestDlg inherits from CDialog so this pointer is the dialog itself with the OnSysCommand() method. void TestDlg::OnButton() { CMenu* pSysMenu = GetSystemMenu(FALSE); pSysMenu->TrackPopupMenu(0, 100, 100, this); } /Thanks, Patric /Patric My C# blog: C# Coach

    C / C++ / MFC question csharp com

  • Match percentage between two string
    P Patric_J

    Use Levenshtein distance alghoritm, see below link for some C# code: Text search part II /Patric My C# blog: C# Coach

    C# csharp regex tutorial

  • View update pattern
    P Patric_J

    Implement events on the business objects (Model) which your forms (View) should subscribe to. Whenever a business object is changed it should fire an event and whatever forms are interested in the change will be notified and can update itself. /Patric My C# blog: C# Coach

    C# question asp-net regex architecture announcement

  • Inheritance instances
    P Patric_J

    Your question is not very clear but if I understand it you have to two classes Class1 and Class2 both inheriting from Base. Then you create two objects, c1 from Class1 and c2 from Class2. Both objects will have its own copy of the iNo, inhereted from Base. They are not the same iNo int variable just because they are defined in the same class, instead they refer to seperate variables in memory. You don't want to use inheritance in this case, you want to use aggregation

    class Base
    {
    public int iNo;
    }

    class Class1
    {
    public Base myBase;
    }

    class Class2
    {
    public Base myBase;
    }

    class Test
    {
    [STAThread]
    static void Main()
    {
    Base b = new Base();
    b.iNo = 10;

        Class1 c1 = new Class1();
        c1.myBase = b;
    
        Class2 c2 = new Class2();
        c2.myBase = b;
    
        Console.WriteLine("c1.myBase.iNo = " + c1.myBase.iNo);
        Console.WriteLine("c2.myBase.iNo = " + c2.myBase.iNo);
        
        c2.myBase.iNo = 5;
    
        Console.WriteLine("c1.myBase.iNo = " + c1.myBase.iNo);
        Console.WriteLine("c2.myBase.iNo = " + c2.myBase.iNo);
    }
    

    }

    This will result in the following outpu c1.myBase.iNo = 10 c2.myBase.iNo = 10 c1.myBase.iNo = 5 c2.myBase.iNo = 5 /Patric My C# blog: C# Coach

    C# question oop

  • The current index in the foreach
    P Patric_J

    cazzz wrote: Is there any reason to use a foreach instead off a for loop? Using foreach will automatically cast an item in the collection to right type. Example:

    for (int i = 0; i < 8; ++i)
    {
    // You need to cast.
    Customer cust = (Customer)customers[i];
    }

    instead

    foreach (Customer cust in customers)
    {
    // cust is now of correct type Customer.
    }

    Use foreach when you just want to iterate over all items and don't care about order or which item is the current item. Handle special behaviour inside a class and not in the calling code according to classic OO principles. Example:

    // Calling code somehow knows that customers[4] needs some special handling.
    for (int i = 0; i < 8; ++i)
    {
    if (i == 4)
    {
    Customer cust = (Customer)customers[i];
    DoSumthingWithCustomer(cust);
    }
    }

    instead

    // Calling code only knows it needs to call a method for each customer object.
    foreach (Customer cust in customers)
    {
    // cust is now of correct type Customer.
    cust.DoSumthing();
    }

    You should implement the class Customer so when calling method DoSumthing() on its objects it will only do something for the object which have index 4 in the for loop. Ugly indexing is normally not needed in my experience. /Patric My C# blog: C# Coach

    C# csharp database question

  • Bitarray
    P Patric_J

    Just use the CopyTo method of the BitArray class. If bitArray is your BitArray object then the following will work:

    byte[] bytesArray = new byte[64];
    bitArray.CopyTo(bytesArray, 0);

    /Patric My C# blog: C# Coach

    C# question csharp algorithms security help

  • Code changes when switching from design to code view
    P Patric_J

    When you use Visual Studio it adds the following little comment to your code right above the InitializeComponent() method #region Component Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() Put you changes in the OnLoad eventhandler or the contructor instead. /Patric My C# blog: C# Coach

    C# csharp com design help question

  • dialog access problem
    P Patric_J

    Interesting problem, how do you unlock a modeless dialog locked by a modal dialog? Sorry to say, I have no good answer and looking at the lack of responses to your question the community seams to have problems with it also. Can't you make the help dialog as a standalone application which you kill when the parent dialog is shutdown? Only problem I see with this solution is if you need to communicate with the help application, which is more difficult than communication within an application, so then it might not be worth it. Here's a link how to make a single instance application: www.codeproject.com/csharp/singleinstance.asp /Patric My C# blog: C# Coach

    C# help question

  • Why can't the as operator perform user-defined conversions?
    P Patric_J

    Why can't the as operator perform user-defined conversions? Is it a C# problem or with MSIL? I can't see any reasons why the compiler should'nt be able to use a user-defined conversion operator. Anyone knows the answer? MSDN my c# blog: C# Coach

    C# csharp html com help question

  • MCSD not important when Microsoft hiring
    P Patric_J

    I participated in today's chat held by Microsoft Tech Recruiting. Some of the more interesting Q&A i put on my blog: spaces.msn.com/members/pjsson/ According to MS so do they not consider a MCSD being anything of value when they are hiring. What's the purpose of getting one then if not even Microsoft care? zoeg (Expert): Q: Does a .Net MCSD get a preference during the resume filtering? A: It depends on the group really. For the positions that I have recruiter for in the past this hasn't been a requirement and doesn't necessarily make a candidate more attractive per se. /Patric

    Work Issues csharp com question lounge career

  • List View items - exporting and importing data
    P Patric_J

    Hi, what you want to do is called serialization. Serialization is saving an object's state to a stream so its state can be transported or saved and later restored. You suggested a tab separated text file, which is nice since the file is easily read and understood by other applications, however binary files are faster. If format don't mattter to you, I would suggest binary format. BinaryFormatter.Serialize Method is the method you use for binary serialization. The problem will be for you that a listview control or ListViewItemCollection object do not support serialization. To be able to serialize an object, the object's class needs to be either marked with the Serializable attribute or implement the ISerializable interface. The class ArrayList however is marked Serializable attribute and it's pretty easy to construct an arraylist from a listview control. Good luck and feel free to check my C# blog, Patric

    C# help tutorial

  • Visual C++ and Borland C++ Builder :: Breakdown
    P Patric_J

    Also Visual C++ will be used when you don't want to allow users to do reverse engineering on your code to see how it works. Companies will write their sensitive modules in standard (Visual) C++ that implements various business secrets. Then they will use managed C++ to write an interface that can easily be accessed from .NET code. This however means that you need to learn to code managed C++, but only so much to write these (relatively simple) kind of interfaces. For many companies, using Dotfuscator will not be enough. /Patric

    IT & Infrastructure c++ question delphi visual-studio tools

  • chart needed for .NET framework
    P Patric_J

    Hi, anyone know where I can find a graphical chart over the classes and namespaces of the .NET framework? Something similar to what exists for MFC library, see link below. Thanks, Patric Hierarchy Chart

    .NET (Core and Framework) csharp c++ html dotnet com
  • Login

  • Don't have an account? Register

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