Anyway thanks a lot for your time and support. Regards, Andy
Andy411
Posts
-
VS2008 weird behavior regarding greyed out code in preprocessor directives -
VS2008 weird behavior regarding greyed out code in preprocessor directivesThx 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...
-
VS2008 weird behavior regarding greyed out code in preprocessor directivesI 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()
{
}
#endifNow 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.
-
Change application language at RuntimeWell, 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.
-
Pass values between windowsTry 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> -
Binding DataGridWhat 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
-
Catching unhandled ThreadAbortException from Main?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
-
connect to usb modemI 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.
-
Continuous listening of COM port for detecting MODEM??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.
-
Merging ArraysOK, 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 useHope it helps.
-
Merging ArraysI 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.
-
do-while did not workHow 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.
-
do-while did not workAs 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');
-
Do you think I can put 30 year old lego in the dishwasher?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.
-
Return to Q&A makes me wonder why I came backI 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.
-
Replicate a class from an assempli and add a new constructorYou 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)
{
}
} -
WCFMenu 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.
-
Can an Attribute class find out, to which class it is actually attached?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
-
Can an Attribute class find out, to which class it is actually attached?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.
-
Can an Attribute class find out, to which class it is actually attached?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