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
  • 0 Votes
    1 Posts
    1 Views
    No one has replied
  • What is the accepted naming convention of the controls?

    c++ question tutorial
    5
    0 Votes
    5 Posts
    1 Views
    L
    The importance of a naming convention is directly proportionate to two things: A) the amount of code you write and need to maintain/understand at a later date. B) the number of people involved in A. I program by myself for my own company, I can easily write a thousand lines of code in a day if I'm really humming. It's absolutely critical to me that I use a naming convention. On the other hand if I'm writing a little one shot utility that has maybe 10 variables in it I might just call them all x or y or something because I just don't care. It's hard to misplace a couple of variables in a one function dialog box. On the other hand for any of my commercial work there is a distinct possibility that down the road if I am successful I just might be hiring someone else to work on that same code. If it's difficult for them to understand I'm going to end up paying them a lot more so it makes sense if your cheap as well. :) Personally I do it like this: m_ prefixes any variable thats a member of a class and visible anywhere in that class (declared in the header not within a function itself). m_p denotes a member variable that is a pointer. ed in front of edit box names btn in front of button names ck in front of checkboxe names dt in front of date/timepicker control names lbl in front of static label names cb in front of combo box names rs for recordset names b for a bool n for an int f for a float str for a CString etc So for example I might have: m_btnExit, m_edSalary, m_dtStartDate, m_bIsEditing, m_pstrPassedString etc. I know at a glance what they are, what they are for and where they are declared (their scope). And most importantly of all use the EXACT same name everywhere on a large project or you will find yourself squinting at code and zoning out late at night. It's amazing how much time careful naming will save when you have a big job to do and your tired. I have wasted lots of time when I have done somthing silly like called a dialog resource edit box "IDC_DATE" and then called the variable "m_edStart" or something equally unrelated. For example I have a hypothetical edit box that is used to enter a first name, I would name it along these lines IDC_FIRSTNAME for the resource, m_edFirstName for the CEdit control variable. I don't recommend calling everything a window because thats kind of obvious and doesn't help much when you have a lot to do. It doesn't really matter how you do it, but whatever you choose to do stick with it. If your going to app
  • Bitmap drawing

    c++ graphics question learning
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • How can I give a 30 day working version of a program?

    question announcement
    4
    0 Votes
    4 Posts
    1 Views
    A
    As you say, "there's nothing stopping someone really determined...." I experimented with a similar method a while ago. I generated a GUID and stored the install date in a binary form under the GUID in HKEY_CLASSES_ROOT (where I thought it would be inconspicuous). It all worked well until I ran a registry cleaning program which spotted the entry as "orphaned" and offered to remove it. The moral being of course, try to crack it when you've written it, and if your succeed, try something else. Even better, try a combination of approaches - writing an encrypted file to Windows\System32 may be a good idea as well.
  • Saving and restoring rebar control

    help tutorial question
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Sql statement and dates.

    help c++ database
    2
    0 Votes
    2 Posts
    0 Views
    C
    Enclose your date literals with "#"'s. eg: WHERE date_open < #22/04/00#
  • 0 Votes
    2 Posts
    0 Views
    C
    Just look in the Toolbar and Docking Windows section. Kirk Stowell has an article "Using Hot Toolbar Buttons " at http://www.codeproject.com/docking/toolbar_hotbuttons.asp
  • Device context

    question
    7
    0 Votes
    7 Posts
    1 Views
    C
    You have to create a bitmap and select it in the memory DC first. Once you selected your bitmap, all drawing changes it directly. See also the GDI section for examples of usage.
  • MFC Console Apps

    question c++
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • How to add bitmap to one of the PropertyPaeg title?

    graphics tutorial question
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Modem - bytes sent/received

    tutorial question
    2
    0 Votes
    2 Posts
    0 Views
    B
    I'm working on the same thing You could get a handle to the DUN window etc Or its possible to use the performance statistics, If you care to know more e-mail me. Regardz Colin Davies taxpaid@bigfoot.com
  • View doesn't get updated -Gray outs

    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • CListCtrl - realtime scrolling

    database question
    2
    0 Votes
    2 Posts
    0 Views
    M
    Do you really have to redraw every item? If not, call Invalidate() on the list control to have it repaint the visible portions.
  • Basic OOP question...

    question
    8
    0 Votes
    8 Posts
    4 Views
    U
    This is a basic C++ question, not OOP. When ever you create a class the compiler automatically creates a default constructor and a copy constructor. The default constructor is required if you want to create objects like this:CFoo foo; As soon as you create ANY constructor, the compiler requires you to write ALL constructors. In other words, it no longer creates the default constructor for you. That means if you write:struct Point { int x; int y; }; Point origin; // legal - using compiler-supplied default constructor ...but if you write this...struct Point { int x; int y; Point(int x, int y): x(x), y(y) {} }; ...the compiler no longer generates the default constructor...Point origin; // illegal! no default constructor Point origin (12,45); // legal - using Point(int,int) Note that a default constructor does not have to take 0 arguments, you simply must be able to call it with 0 arguments. Like this...struct Point { int x; int y; Point(int x=0, int y=0): x(x), y(y) {} // default parameters }; Now everything's happy again...Point origin; // legal - using Point(int,int) Point origin (12,45); // legal - using Point(int,int) Hope this clarifies more than it confuses! Cheers, Eric
  • Binary file: Platform-Independent

    tutorial question
    3
    0 Votes
    3 Posts
    0 Views
    U
    Goto http://chesworth.com/pv/downloads/libs.htm and download bllib11.zip This will give you a start.
  • Best method Exceptions without MFC

    question c++
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • VC++ Intelligent Editor

    c++ help debugging question workspace
    4
    0 Votes
    4 Posts
    0 Views
    W
    Is your friend also including the .clw (class wizard ) file?
  • Device context

    question
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • Toolbar button

    tutorial
    2
    0 Votes
    2 Posts
    0 Views
    M
    Give the button the TBSTYLE_CHECK style. (Note - that constant was renamed to BTNS_CHECK in SDKs that shipped after VC 6.)
  • ImageList_Duplicate Bug!!

    help beta-testing
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied