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
A

Andy411

@Andy411
About
Posts
36
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • VS2008 weird behavior regarding greyed out code in preprocessor directives
    A Andy411

    Anyway thanks a lot for your time and support. Regards, Andy

    Visual Studio c++ database help tutorial question

  • VS2008 weird behavior regarding greyed out code in preprocessor directives
    A Andy411

    Thx for the hint. Unfortunately it does not help. I also tried to delete the ncb file of the solution. It has no effect, either. At the moment I have two assumptions: 1) It has to do something with the size of the source files. There are several files with more (!) than 10k lines (no joke! As I told in my first post: Lot's of legacy stuff from more then 15 years) 2) Maybe something goes wrong with the bsc files (browse source) Regards, Andy PS: At the moment I'm at the beginning of a huge refactoring process. It can only be done step by step. Otherwise it (and I) will loose the acceptance of the colleages. They are usesd to work with these huge files...

    Visual Studio c++ database help tutorial question

  • VS2008 weird behavior regarding greyed out code in preprocessor directives
    A Andy411

    I have a VS2008 solution with different C++ projects. It is a legacy solution which is still in production and has to be maintained and enhanced in the next years. Some of the classes are usesd in different projects of the solution. Each solution has a compiler switch that tells the compiler which project is currently compiled. In code you will often find something (ugly) like: Declaration:

    class FooClass
    {
    public:
    void FncA();
    #ifdef APP_1_EXE
    void FncB();
    #endif

    #ifdef APP_2_EXE
    void FncC();
    #endif
    };

    Implementation:

    void FooClass::FncA()
    {
    // do something
    #ifdef APP_1_EXE
    // do special stuff for APP 1
    #endif
    }

    #ifdef APP_1_EXE
    void FooClass::FncB()
    {
    }

    #endif

    #ifdef APP_2_EXE
    void FooClass::FncC()
    {
    }
    #endif

    Now I have the behavior that APP_1 is active, but in the header file the code is greyed out and in the cpp module code is not greyed out. Even if I right click on the declarations in the header file, I cannot select "goto references" or "goto declaration" in the conext menue. In the class explorer the methods are inaccessible even if the compiler switch is set. For me it looks like VS2008 does not recognize the current active project. Any ideas or hints how to solve the problem? Maybe a good google query? After two days I'm out of ideas :-( Thx Andy PS: The problematic behaviour resides already for a while but it became massiv after I started to refactor and splitted the main header file which contained almost all class declarations into seperate header files. Now each class has it's own header file and it's own implementation file (liek FooClass.h and FooClass.cpp) I also know that it would be better to have a base class an use project specific derived classes instead of preprocessor switches but as I explained at the top: It's legacy code and I'm just at the beginning of the refactoring process.

    Visual Studio c++ database help tutorial question

  • Change application language at Runtime
    A Andy411

    Well, even if you posted the almost same questions many times, I try to give you a hint. Take a look at http://wpflocalizeextension.codeplex.com/[^] It might be usefull.

    WPF wpf help csharp architecture tutorial

  • Pass values between windows
    A Andy411

    Try it with DataBinding. Just bind the Controls in Window1 and Window2 on the properties of the same object.

    class Data : INotifyPropertyChanged
    {
    private int myVar;

        public int MyProperty
        {
            get { return myVar; }
            set 
            { myVar = value;
            this.OnPropertyChanged("MyProperty");
            }
        }
    
    
    
    
        #region PropertyChangedEvent
        public event PropertyChangedEventHandler PropertyChanged;
    
        protected virtual void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    
        #endregion        
    

    }

    And e.g.

    Data d = new Data();
    Window1.DataContext = d;
    Window2.DataContext = d;

    In Windows2.xaml

    e.g. In Windows1.xaml

    <pre lang="HTML">
    <Label Content={Binding MyProperty} />
    </pre>

    WPF csharp wpf question

  • Binding DataGrid
    A Andy411

    What is the exact problem? After a quick view, I see two things: 1) After calling the ctor of ViewModel, there will be Ivan, Stefan, Maria and Michael in the Persons collection. After calling ViewModel.Add() there will be only Maria and Michael, because you create a new collection. 2) class Person needs to implement INotifyPropertyChanged and after changing a property it has to call the PropertyChangedEvent. Hope it helps Andy

    WPF wpf csharp wcf linq

  • Catching unhandled ThreadAbortException from Main?
    A Andy411

    Well, I allways have a try/catch in my threads. Usualy I catch TreadAbortException and other "most excpected" exceptions and at the end I allways catch general exceptions and log them. In debug mode I tend to insert a Debug.Assert(false) in the general exception handler, to see if I forgot an "expected" exception. In the release they are only logged. Some people say, that you shold not catch general exceptions, but the software I'm used to work on has to run 24/7 and most of the time without a user in front of it. So it has te recover itself after the occurence of any kind of error. I don't know how others manage it, but I don't like software which crashes totally, only showing a messagebox with an error and then say good-bye without any chance of saving data or anything else. Andy

    C# wpf csharp design tutorial question

  • connect to usb modem
    A Andy411

    I don't have that modem, but my questions could propably help you to find out more: Is the driver installed correctly? Is there a virtual COM-Port for the modem? How does the example code connect to the modem? Mabe you can post some snippets.

    C# csharp help question

  • Continuous listening of COM port for detecting MODEM??
    A Andy411

    I'm not sure if I understand you: You want to iterate through all COM-Ports to detect, if a modem is connected? You can open each COM-Port, send the command "AT" and wait if you get an "OK" as answer. Then you know, that there is a modem.

    C# com help question

  • Merging Arrays
    A Andy411

    OK, I had to delete my first answer, because it was a C# solution. Sorry. Now my brain is switsched in C-mode :) You can use memcpy. But allways be aware of the size of the target array! It has to be large enough to take all of the elements.

    int a[] = { 2, 4, 6};
    int b[] = { 3, 5, 7};

    int c[6];

    memcpy(c, a, sizeof(a));
    memcpy(c + 3, b, sizeof(b)); // + 3 because the first 3 elements are
    // allready in use

    Hope it helps.

    C / C++ / MFC data-structures tutorial question

  • Merging Arrays
    A Andy411

    I know two solutions:

    // Use Array.CopyTo
    int[] a = { 2, 4, 6 };
    int[] b = { 3, 5, 7 };

    int[] x = new int[a.Length + b.Length];
    a.CopyTo(x, 0);
    b.CopyTo(x, b.Length);

    // Use a List
    List c = new List();
    c.AddRange(a);
    c.AddRange(b);

    int[] d = c.ToArray();

    I would prefer using List<> because it is more powerfull, you can easily search, sort etc.

    C / C++ / MFC data-structures tutorial question

  • do-while did not work
    A Andy411

    How do you learn C? Don't you have a book or a tutoroial with an index? :confused: That's what google answered me: http://www.cplusplus.com/reference/cstdio/getchar/[^] PS: Sorry if my answer sounds a bit rude, but I am realy confused about the question what getchar does. If I were you, my first step would be asking google, bing are whatever searchmachine you want. Or taking a look inside a book. If I don't understand the description/answer there, I would ask in a forum again.

    C / C++ / MFC career

  • do-while did not work
    A Andy411

    As mentioned in the QA section: Please don't cross post. I decided to answer you here. Did you take a look at "again" in the debugger? You will recognize that in the second round thru the loop it will have the value 0x0a == \r it's the carriage return from your input. You can try something like this to catch the CR:

    char cr;
    char again;
    do
    {
    printf("insert y or Y to repeat");
    fflush(stdout);

    again = getchar();
    cr = getchar();
    

    }while(again=='y'||again=='Y');

    C / C++ / MFC career

  • Do you think I can put 30 year old lego in the dishwasher?
    A Andy411

    if you buy it new, they say that you can wash it at 30°C in your washing machine. I would not tumble or centrifuge it. Put some lego as a test in an old pilow cover. That should work. I would not put it into the dishwasher. The dishwasher cleaner is very "strong" and aggressive.

    The Lounge question

  • Return to Q&A makes me wonder why I came back
    A Andy411

    I gave you my 5, too. I also experienced the same thing, fast 1 star only vote, in the last weeks. If there were an explaining comment, why the answer is downvoted, someone could better understand.

    Site Bugs / Suggestions visual-studio help csharp com beta-testing

  • Replicate a class from an assempli and add a new constructor
    A Andy411

    You cannot do it later in a method, but if you know the parameters, you can do it like this:

    class BaseClass
    {
    public BaseClass(int theParam)
    {
    }
    }

    class DerivedClass : BaseClass
    {
    public DerivedClass() : base(4711)
    {
    }
    }

    C# question

  • WCF
    A Andy411

    Menu File->New->Project, Select and Expand Visual C#, Select WCF... What kind of WCF-project you want depends on your needs. Ask MSDN or Google for details and comparison.

    WCF and WF csharp visual-studio wcf question

  • Can an Attribute class find out, to which class it is actually attached?
    A Andy411

    Thx for your answer. Well, I have to accept my destiny ;-) and I'll choose the typeof operator in the constructor. As I mentioned before, I was just interested if it could be possible

    C# css tutorial question

  • Can an Attribute class find out, to which class it is actually attached?
    A Andy411

    Hi Dave, thanks for your answer. Well, I did not want to change the behaviour of the attribute. It still should show the DisplayName, Description, Category etc. I only wanted to make it a bit more "smart" regarding localization. I was just curious, if it is possibly for an attribute to figure out to which class it is attached. It's ok for me, since I have a solution, inspired by different approaches which can be found here at CP and out in the web.

    C# css tutorial question

  • Can an Attribute class find out, to which class it is actually attached?
    A Andy411

    Background: To implement localization I have derived from DisplayNameAttribute: LocalDisplayNameAttribute. When using this attribute, I only want to declare the ResourceString an a default string. The class LocalDisplayNameAttribute should find out on it's own, which class and which assembly is using it. My idea is, to find the strings in related resources by reflection. The strings should allways be in AssemblyName.Properties.Resources. Is it possible for a attribute class, to find out, who it is used by? Example: Assembly LocalizationTools.dll

    namespace LocalizationTools
    {
    public class LocalDisplayNameAttribute : DisplayNameAttribute
    {
    public LocalDisplayNameAttribute(string resourceName, string defaultText)
    : base(defaultText)
    {
    m_resourceName = resourceName;
    }

        public override string DisplayName
        {
            get
            {
                string name = string.Empty;
                try
                {
                    name = SomeVodoo(base.DisplayNameValue);
                }
                catch (Exception)
                {
                    name = base.DisplayNameValue;
                }
                return name;
            }
        }
        
        private string SomeVodoo(string defaultText)
        {
            // Find out to which class an assembly we belong. Then Find the Properties.Resources of the assembly
            // and find the m\_resourceName
        }    
    }
    

    }

    Assembly SomeClasses.dll

    public class Foo
    {
    [LocalizationTools.LocalDisplayName("DisplayName_ImportantProperty", "Important property XYZ")]
    public int ImportantProperty { get; set; }
    }

    And in SomeClasses.Properties.Resources you can find DisplayName_ImportantProperty PS: I have a IMO less elegant solution by declaring the type.

    [LocalizationTools.LocalDisplayName(typeof(SomeClasses.Properties.Resources), "DisplayName_ImportantProperty", "Important property XYZ")]
    public int ImportantProperty { get; set; }
    }

    Thanks in advance Andy

    C# css tutorial 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