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
  • Adding object to class - which option makes more sense ?

    c++ question discussion
    5
    0 Votes
    5 Posts
    89 Views
    K
    Googling for something like "C++ derived class tutorial" should give you some useful hits. "A little song, a little dance, a little seltzer down your pants" Chuckles the clown
  • System.* not defined or imported

    help
    4
    0 Votes
    4 Posts
    56 Views
    P
    Apologies - this is a c# question ... :)
  • 0 Votes
    3 Posts
    32 Views
    D
    Don't use the word "register". It doesn't apply in this case. Search for "BIOS and DOS interrupts" and you'll find what you're looking for. Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak
  • Inheritance and STL containers

    question c++ graphics docker oop
    4
    0 Votes
    4 Posts
    47 Views
    Mircea NeacsuM
    Let me expand a bit on my previous answer[^]. As I said, you can convert a pointer (or reference) to pointer (or reference) to the base class. This called "upcasting" because you are moving "up" in the inheritance tree. The conversion is "non-destructive", in other words you can later on "downcast" (move from base to derived) as long as you know what type of object was in the first place. An example: struct Unit { Unit (int tag) : dog_tag(tag){}; virtual std::string kind () = 0; int dog_tag; }; struct Soldier : public Unit { Soldier (int tag) : Unit(tag) {}; virtual std::string kind() {return "soldier";}; float running_speed; } struct Sailor : public Unit { Sailor (int tag) : Unit(tag) {}; virtual std::string kind() {return "sailor";} int life_jackets; }; std::vector actors {new Soldier(555), new Sailor(666);}; int main () { Unit* u0 = actors[0]; std::cout << "Actor 0 is a " << u0.kind() " with tag " << u0.dog_tag << std::endl; If you would look with a debugger at u0 you would see a memory layout something like this: u0 0x1234 -------> pointer to vtable of Soldier dog_tag ----------------------------- running_speed ------------------------------ You can see now why the code works: no matter what kind of object you deal with, the first part of the memory layout is the same. Compiler simply ignores whatever is after the dog_tag field. A few more lines of code (please ignore that I didn't initialize other fields): Soldier *s = (Soldier *)u0; std::cout << "Running speed " << s->running_speed << std::endl; s has exactly the same value as u0 but compiler considers it a pointer to a Soldier object so it uses the value from the running_speed field. I could have written: Sailor *ss = (Sailor*)u0; std::cout << "Sailor has " << ss->life_jackets << " life jackets"; And compiler wouldn't have cared at all. It would have accessed the memory at lif
  • 0 Votes
    4 Posts
    46 Views
    L
    Please stop deleting your questions, as it makes the replies impossible to understand. You have been here long enough, in all your different names, to know how this site works.
  • 0 Votes
    2 Posts
    26 Views
    D
    Your code snippet is very difficult to read with all of the comments and lack of indentation. "One man's wage rise is another man's price increase." - Harold Wilson "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
  • Inheritance and arrays

    c++ docker data-structures oop help
    8
    0 Votes
    8 Posts
    59 Views
    L
    Thank you for your comment.
  • 0 Votes
    8 Posts
    65 Views
    M
    IPM_GETADDRESS message (Commctrl.h) - Win32 apps | Microsoft Learn[^] "Return value Returns the number of nonblank fields."
  • Notes in MFC/Win32 App

    c++ tutorial
    3
    0 Votes
    3 Posts
    51 Views
    M
    Anywhere means nothing. What do you want to do, exactly ? What is or what kind of data in your window ? How is it represented ? What kind of notes you want to add ? What relation has the note and the data ? Do you have an example of something similar you want to do ? Without more details... I'd handle a click or double click event, open a modal popup window with a text box, and on the OK button, save the note whereever you want to save the note. CI/CD = Continuous Impediment/Continuous Despair
  • Enumerations

    help question
    3
    0 Votes
    3 Posts
    39 Views
    C
    Thank you Victor. I will change the object name to lower caps and see if the error goes away
  • Voluntarily DELETED - wrong forum

    help
    6
    0 Votes
    6 Posts
    25 Views
    L
    Yup; he never learns.
  • dialog update

    c++ com graphics help question
    2
    0 Votes
    2 Posts
    21 Views
    OriginalGriffO
    2 Things: 1) Please don't repost if your question does not appear immediately: all of these went to moderation and required a human being to review them for publication. In order to prevent you being kicked off as a spammer, both had to be accepted, and then I have to clean up the spares. Have a little patience, please! I've deleted the 3 identical spares ... 2) Don't post this under Quick Answers - if you got the code from an article, then there is a "Add a Comment or Question" button at the bottom of that article, which causes an email to be sent to the author. They are then alerted that you wish to speak to them. Posting this here relies on them "dropping by" and realising it is for them. However, given that the article is 22 years old it's unlikely that anyone is going to know or remember details of how it works! "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
  • dialog color

    c++ com graphics help
    1
    0 Votes
    1 Posts
    14 Views
    No one has replied
  • dialog color

    c++ com graphics help
    1
    0 Votes
    1 Posts
    7 Views
    No one has replied
  • dialog color

    c++ com graphics help
    1
    0 Votes
    1 Posts
    13 Views
    No one has replied
  • 0 Votes
    5 Posts
    43 Views
    D
    Dave Kreskowiak wrote: ...so reposting this was redundant. And completely unnecessary. "One man's wage rise is another man's price increase." - Harold Wilson "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
  • Can not find where to define an identifier..

    c++ help debugging tools learning
    15
    0 Votes
    15 Posts
    100 Views
    L
    Carbonkevlar13 wrote: I still do not understand why it did not work with my screen. So look carefully at all the other code and compare it line by line with the code that you made.
  • 0 Votes
    6 Posts
    44 Views
    L
    Yes, parallel processing the two of us. :-D
  • glReadPixels unmatched values

    3
    0 Votes
    3 Posts
    30 Views
    E
    16 bit pixel value bytes read from glReadPixels(0,0,,,) are like X1 X1 X2 X2 ... etc. They do not match the raw image pixels. The image is brighter liked a image that has a filter applied to it. I am not sure if I am reading from framebuffer. I sed GL_LUMINANCE with GL_UNSIGNED_SHORT. It is a grayscale image.
  • C program(homework)

    data-structures regex
    12
    0 Votes
    12 Posts
    99 Views
    R
    First run: ~~~~~~~~~~~~~~~~ Original strings: ∩╝æ∩╝ÿµ¡│πü¿∩╝ÿ∩╝浡│πü«ΘüòπüäπÇé∩╝æ∩╝ÿµ¡│πü»µüïπü½µ║║πéîπéïΣ║║πüºπÇü∩╝ÿ∩╝浡│πü»πüèΘó¿σæéπü½µ║║πéîπéïΣ║║πÇé∩╝æ∩╝ÿµ¡│πü»ΘüôπéÆΦ╡░πéèπÇüΘÇåπééπü╛πüƒτä╢πéèπÇé∩╝ÿ∩╝浡│πü«Σ║║πüîΦ╡░πüúπüªπüäπéïπÇé∩╝æ∩╝ÿµ¡│πü»σ┐âπüîπééπéìπüÅπÇü∩╝ÿ∩╝浡│πü»Θ¬¿πüîπééπéìπüäπÇéτºüπü»∩╝æ∩╝ÿµ¡│πüºσ┐âΦçôπüóπü╛πéëπü¬πüäπÇé ∩╝ÿ∩╝浡│πü«σ╜╝πü»Θú¢Φíîµ⌐ƒπ鯵¡óπéüπéëπéîπü¬πüäπÇé∩╝æ∩╝ÿµ¡│πü»µüïπü½τ¬Æµü»πüÖπéïπüôπü¿πüîπüºπüìπÇü∩╝ÿ∩╝浡│πü»Θñàπü½τ¬Æµü»πüÖπéïπüôπü¿πüîπüºπüìπéïπÇéσüÅσ╖«σÇñπüîµ░ùπü½πü¬πéïπÇéτºüπü»∩╝æ∩╝ÿµ¡│πüºπÇü∩╝ÿ∩╝浡│πüºΦíÇσ£ºπü¿ΦíÇτ│ûσÇñπ鯵░ùπü½πüùπüªπüäπéïπÇéπü╛πüáΣ╜òπééτƒÑπéëπü¬πüä∩╝æ∩╝ÿµ¡│πÇüπééπüåΣ╜òπééΦªÜπüêπüªπüäπü¬πüä∩╝ÿ∩╝浡│πÇé Φç¬σêåπ鯵Äóπüùπüªπüäπéï∩╝æ∩╝ÿµ¡│πü¿πÇüπü┐πéôπü¬π鯵Äóπüùπüªπüäπéï∩╝ÿ∩╝浡│πÇé Enter search string (up to 10 characters): 2 Enter replacement string (up to 10 characters): # Nothing is changed. Second run: ~~~~~~~~~~~ Original strings: ∩╝æ∩╝ÿµ¡│πü¿∩╝ÿ∩╝浡│πü«ΘüòπüäπÇé∩╝æ∩╝ÿµ¡│πü»µüïπü½µ║║πéîπéïΣ║║πüºπÇü∩╝ÿ∩╝浡│πü»πüèΘó¿σæéπü½µ║║πéîπéïΣ║║πÇé∩╝æ∩╝ÿµ¡│πü»ΘüôπéÆΦ╡░πéèπÇüΘÇåπééπü╛πüƒτä╢πéèπÇé∩╝ÿ∩╝浡│πü«Σ║║πüîΦ╡░πüúπüªπüäπéïπÇé∩╝æ∩╝ÿµ¡│πü»σ┐âπüîπééπéìπüÅπÇü∩╝ÿ∩╝浡│πü»Θ¬¿πüîπééπéìπüäπÇéτºüπü»∩╝æ∩╝ÿµ¡│πüºσ┐âΦçôπüóπü╛πéëπü¬πüäπÇé ∩╝ÿ∩╝浡│πü«σ╜╝πü»Θú¢Φíîµ⌐ƒπ鯵¡óπéüπéëπéîπü¬πüäπÇé∩╝æ∩╝ÿµ¡│πü»µüïπü½τ¬Æµü»πüÖπéïπüôπü¿πüîπüºπüìπÇü∩╝ÿ∩╝浡│πü»Θñàπü½τ¬Æµü»πüÖπéïπüôπü¿πüîπüºπüìπéïπÇéσüÅσ╖«σÇñπüîµ░ùπü½πü¬πéïπÇéτºüπü»∩╝æ∩╝ÿµ¡│πüºπÇü∩╝ÿ∩╝浡│πüºΦíÇσ£ºπü¿ΦíÇτ│ûσÇñπ鯵░ùπü½πüùπüªπüäπéïπÇéπü╛πüáΣ╜òπééτƒÑπéëπü¬πüä∩╝æ∩╝ÿµ¡│πÇüπééπüåΣ╜òπééΦªÜπüêπüªπüäπü¬πüä∩╝ÿ∩╝浡│πÇé Φç¬σêåπ鯵Äóπüùπüªπüäπéï∩╝æ∩╝ÿµ¡│πü¿πÇüπü┐πéôπü¬π鯵Äóπüùπüªπüäπéï∩╝ÿ∩╝浡│πÇé Enter search string (up to 10 characters): πéèπ Enter replacement string (up to 10 characters): ---- ∩╝æ∩╝ÿµ¡│πü¿∩╝ÿ∩╝浡│πü«ΘüòπüäπÇé∩╝æ∩╝ÿµ¡│πü»µüïπü½µ║║πéîπéïΣ║║πüºπÇü∩╝ÿ∩╝浡│πü»πüèΘó¿σæéπü½µ║║πéîπéïΣ║║πÇé∩╝æ∩╝ÿµ¡│πü»ΘüôπéÆΦ╡░πéèπÇüΘÇåπééπü╛πüƒτä╢πéèπÇé∩╝ÿ∩╝浡│πü«Σ║║πüîΦ╡░πüúπüªπüäπéïπÇé∩╝æ∩╝ÿµ¡│πü»σ┐âπüîπééπéìπüÅπÇü∩╝ÿ∩╝浡│πü»Θ¬¿πüîπééπéìπüäπÇéτºüπü»∩╝æ∩╝ÿµ¡│πüºσ┐âΦçôπüóπü╛πéëπü¬πüäπÇé ∩╝æ∩╝ÿµ¡│πü¿∩╝ÿ∩╝浡│πü«ΘüòπüäπÇé∩╝æ∩╝ÿµ¡│πü»µüïπü½µ║║πéîπéïΣ║║πüºπÇü∩╝ÿ∩╝浡│πü»πüèΘó¿σæéπü½µ║║πéîπéïΣ║║πÇé∩╝æ∩╝ÿµ¡│πü»ΘüôπéÆΦ╡░----ÇüΘÇåπééπü╛πüƒτä╢----Çé∩╝ÿ∩╝浡│πü«Σ║║πüîΦ╡░πüúπüªπüäπéïπÇé∩╝æ∩╝ÿµ¡│πü»σ┐âπüîπééπéìπüÅπÇü∩╝ÿ∩╝浡│πü»Θ¬¿πüîπééπéìπüäπÇéτºüπü»∩╝æ∩╝ÿµ¡│πüºσ┐âΦçôπüóπü╛πéëπü¬πüäπÇé Seems to be running as expected here.