Skip to content

C / C++ / MFC

C, Visual C++ and MFC discussions

This category can be followed from the open social web via the handle c-c-mfc@forum.codeproject.com

111.5k Topics 465.7k Posts
  • RPN notation in C

    data-structures help learning
    7
    0 Votes
    7 Posts
    0 Views
    L
    Member 12529159 wrote: There are, I think, some big mistakes Yes, this will not compile, and even if it did, none of this code is going to work. You are reading a string into the array seq and then using Push to copy characters back into the same array. You are also storing everything as characters but when you use Pop, you think you are rectrieving an integer. And you assume that each string will be two digits followed by a mathematical symbol.
  • How 2 watch watch "Angry Birds" (2016) full Movie Online Free ?

    html com question
    1
    0 Votes
    1 Posts
    2 Views
    No one has replied
  • Pass by pointer not working

    help question
    6
    0 Votes
    6 Posts
    2 Views
    CPalliniC
    I gave you a flawed code sample, sorry. :-O Thank you for pointing it out so nicely.
  • C execl is this a bug ?

    help question
    4
    0 Votes
    4 Posts
    0 Views
    L
    If your on Eclipse it is a known bug (id=173732) The fflush(stdout); fix is the only way around it as horrible as it is. In vino veritas
  • Windows 7 UAC prevents my app to write log data

    question
    5
    0 Votes
    5 Posts
    0 Views
    S
    Thank you for your help :-) Best Regards, sdancer75
  • is there any good book about c++ class?

    c++ question learning
    3
    0 Votes
    3 Posts
    0 Views
    CPalliniC
    An introductory book could be "Stroustrup: Programming -- Principles and Practice Using C++ (Second Edition)"[^]. More advanced books comes from the same author. Another precious book, written by Josuttis covers the C++ standard library: Nicolai M. Josuttis: The C++ Standard Library, 2nd edition[^]. Freely available, though bit dated, there are the Eckel's ones: Bruce Eckel's MindView, Inc: Thinking in C++ 2nd Edition by Bruce Eckel[^].
  • 0 Votes
    7 Posts
    0 Views
    L
    99% of the time if you get a difference between release and debug mode you forgot to zero a variable and assume it is. Turn the warning levels up to full and you should get a warning saying "use of uninitialized variable". Usually it is something like this int Bad (int someval){ int i; if (someval > 0){ i = 1; } if (i == 0) return (1); return (0); } In debug mode all local variables are zeroed automatically. That simply doesn't happen in release mode the variables will start at whatever rubbish was in the stack at the position it was allocated. In the above code the behaviour of "bad" is totally predictable in debug mode as "i" will always start at 0. In release mode you have no idea what is going to happen as "i" could start at any value and the return is purely chance based. Look carefully at the code, now try compiling it and tell me if you get a warning :-) In vino veritas
  • 0 Votes
    2 Posts
    0 Views
    L
    Please use the forum at the end of the article, so the writer of the article (and code) can help.
  • Stuck in 2 loops

    help question
    14
    0 Votes
    14 Posts
    0 Views
    L
    Reading the messages first helps to decide whether there is any point in posting a response. Something that I generally do, especially when it is obvious that the thread has a conversation going between OP and another CP member.
  • Phone Dialer

    c++ css database question
    11
    0 Votes
    11 Posts
    1 Views
    B
    Thanks David, It is a Good Start! (Mental Block I had, not looking for 'Modems' in the first place!), as you know, that's how it goes. However, it covers, apart from a sprinkling of C or CPP, a Lot of CE, C#, etc, which have their own libraries, etc, and hence are instructive, but not very useful. For Instance, "Phone.Lib" is not a component of MFC42. All I need to do is the Dialling, and the Channelling of the connection to the Sound System, and hanging up, after ending the call. I'm going to try for now something called "RasDial.exe" and see how I get on with it. Hopefully I can fool it in not looking for a Phonebook Entry, or stopping it from trying to make an Internet Connection. I have also bought a £6.00 USB Dialup Modem which comes with a CD. Hopefully the CD contains something useful. I live in hope. Even if it fails, the cost is less than a packet of cigs, and, I still have the Modem. Hope if all else fails to be able to hang a Head Set and Mike to the 'Phone' Output, and, hope the Modem can do the Dialling via the Line Socket. May need to set to Pulse, and a switch to isolate the head set, (I know how POTS works) but, for now hope we can make it work without having to resort to this. Worth Six Pound to try it, though, even if it does not work! Thanks, and, I'll keep you Posted, but, remember, I'm on my own, and have to resolve many issues, all by myself. If I get an Intractable Problem in One Place, I put it aside, for dealing with, and whilst waiting, tackle something else. That keeps the entire front moving. Kind Regards,and thanks again :) Bram van Kampen
  • 0 Votes
    2 Posts
    0 Views
    L
    You could just intercept the DrawItem call and for any empty string simply clear the lpDrawItemStruct->rcRect manually and then pass all the calls thru to the normal drawitem. lpDrawItemStruct has everything you need to know what to draw lpDrawItemStruct->itemID it the string number lpDrawItemStruct->itemState & ODS_SELECTED will tell give you if it is selected or not. lpDrawItemStruct->rcRect is the area to draw in In vino veritas
  • FIFO en languge C

    question
    4
    0 Votes
    4 Posts
    0 Views
    CPalliniC
    That's nothing more amusing than code them yourself. Before codeing, Wikipedia could be a good starting point for understanding the concepts, e.g.: FIFO (computing and electronics) - Wikipedia, the free encyclopedia[^] Stack (abstract data type) - Wikipedia, the free encyclopedia[^] ...
  • Creation of class members of class created on the heap

    2
    0 Votes
    2 Posts
    0 Views
    L
    Yes, storage for class members will be allocated when the object is created. In the case of class objects (such as your CFont object) their constructor will be called to create them. You can see this happen by stepping through the code in the debugger.
  • 0 Votes
    6 Posts
    1 Views
    L
    Can I point out that if you really want portability with C++11, we do this and there is nothing your code can do with this as it uses the standard vector library #include using namespace std; #define YMAX 6 #define XMAX 4 // single line to define a 2D array of floats vector> matrix1(YMAX, vector(XMAX)); // Now you can just set values matrix1[0][0] = 3.6f; matrix1[1][2] = 4.0f; matrix1[5][3] = 8.0f; // Or read them back float f = matrix1[1][2]; The really cute part is it can be used on any standard type // single line to define a 2D array of STRINGS vector> stringmatrix(YMAX, vector(XMAX)); // writing strings in the array stringmatrix[0][0] = "hello at 0,0"; stringmatrix[1][2] = "this one"; stringmatrix[5][3] = "hello at 5,3"; // Getting string value from the array string whatdidwesay = stringmatrix[1][2]; In vino veritas
  • How to implement Ctrl + tab to navigate between tabs in a CTabCtrl

    tutorial
    3
    0 Votes
    3 Posts
    1 Views
    A
    Thanks David :)
  • 0 Votes
    5 Posts
    11 Views
    B
    Hi, Well, there are a few considerations here. 'C', 'CPP' are examples of languages which produce code running close to the OS, and the Hardware. One works there on the coal face, dealing directly with actual memory locations, and de Operating System. the vagarities of the hardware components, etc. This can lead on occasion to hard to detect bugs, and crashes. A Strash is a famous example. Another consideration is that the Supplier of the OS can literally pull the carpet from underneath your feet, by deprecating your favourite OS. Another disadvantage is that you must maintain different versions of Source Code if you want toi write for more than One Platform. On the other hand, just because you deal directly with the OS and Hardware, you can do all sorts of tricks that cannot be done in'Synthetic' languages, such as say C# or Java. These languages run on a 'Virtual Machine' in a 'Virtual Environment' When you find yourself in such an environment, you may forget about playing even the most innocent trick. That virtual machine knows nothing about memory, but talks in variables. The advantage here is, that this a far more friendly environment to write in, it tries not to allow you to write wrong code. Also, your code will probably run from now till kingdom come on every computer and OS. Now, it should also be remembered, that as a society, we cannot ever dispense with languages such as C and CPP. Languages such as C# Java, and many others are actually written using 'C' and 'CPP' I personally think that you could do worse than learning 'C' and 'CPP', in particular if in the latter you incorporate 'MFC' Note: C# Java, vs 'C' and 'CPP' are very similar in syntax. The devil is in the syntactical detail!!! Regards, :) Bram van Kampen
  • Does DestroyWindow Parent CDialog destroy all ChildControls

    7
    0 Votes
    7 Posts
    0 Views
    L
    Okay the rules with memory or object allocation and deleting are very simple. Situation 1: If the memory/object is used by multiple children windows and/or the parent then you create it in OnCreate (WM_CREATE) on the parent and destroy it on OnDestroy (WM_DESTROY) of the parent. The reason is because multiple children and/or parent are using it and you need it created before any children and disposed of after the children are deleted. Situation 2: If the memory/Object is used by ONLY the SINGLE child window EXCLUSIVELY (that is the data belongs really to the child) then you create it on OnCreate (WM_CREATE) of the child and you delete it with the OnDestroy (WM_DESTROY) of the child. Sometimes people get lazy and just use situation 1 to cover situation 2 but there are traps in that. It is very easy to forget you need something done before the child is created which is in an unrelated block of code in the parent window create function. So generally I would advise against being lazy and using situation 1 to try and cover all situations. Using Situation 2 when it is valid to do so makes your code self contained portable without thinking about it. Situation 2 is that most often not understood by people. I will give you a simple example I might use on your edit entry, and this is a subclass of the edit I use a lot in programs. OnCreate (WM_CREATE) of the edit box I create a string object. Whenever the user hits enter, I validate the entry via a message call and if its valid put the current value into the string object and then update the edit window to the new value. Why do this ... well because in the edit box handler hitting the "esc" key goes and gets the value from the string object and puts it back it the edit box. It is a return to last valid value function or a simple single step back. If you think about it you could extend the concept to a list and be able to scroll back thru the list of entered values something you might recognize for the entry address input of your web browser. Now the point here is the string object is the edit boxes responsibility to delete so it will do that on it's OnDestroy (WM_DESTROY). Now everything is self contained I can create as many of these edit boxes as I want into a parent and they all look after there own object string. So basically you need to work out what data is being used where and in this regard it is very similar to thread or task code. In vino veritas
  • Adding UI to an existing console project using windows form

    design
    5
    0 Votes
    5 Posts
    0 Views
    M
    Thank you so much for the information
  • How To Look At GCC C Sources

    collaboration question c++ com
    6
    0 Votes
    6 Posts
    0 Views
    F
    Thanks very much Richard and Jochen. It dawned on me yesterday afternoon while taking a walk (which is how I solve most of my programming problems) that I needed libc - not GNU GCC sources. Just now before checking in here I managed to download libc in tarball format. Now I need to see if I have an app to extract tarballs. I much appreciate your help! Thanks very much!
  • Exchanging data using CSocket

    c++ sysadmin data-structures json help
    4
    0 Votes
    4 Posts
    0 Views
    J
    It can be still done with my solution. Just send a message after each data update indicating whch data has been changed. If you need to track the changings, you may add another structure containing flags for the elements. However, in this case the flags must be cleared when the clients has processed the update (sending some kind of acknowledgement in the other direction).