收录查询

CP网站的C++/MFC FAQ

The Code Project Visual C++ Forum FAQ
By Michael Dunn.

About This FAQ

Latest additions and updates.

Welcome to the FAQ for the CodeProject Visual C++ forum. This FAQ is a compilation of the most-often asked questions in the forum, and covers several C++ programming subjects. It is not a full-fledged C++ or Windows programming FAQ (there are plenty of those already), but rather it's meant to cover the topics that CodeProject readers ask about the most.

If you think of any questions that you feel should be covered in this FAQ, email me with the question and the answer.

NOTE: Please do not email me directly to ask individual questions. I can't be everyone's personal consultant. Also, don't post programming questions in the message area of this article. Use the CodeProject forums to ask your questions; that's what they're there for!

Thanks to Tim Deveaux, Anders Molin, and Christian Graus for their contributions to this FAQ, along with all the folks who have posted suggestions in the comments area and via email!

Contents

CodeProject forum questions

1.1

What's the best way to ask a question about code, so that I get a good answer?

1.2

Why don't my #include lines or template parameters show up right in the forum?

Compiling and linking questions

2.1

I'm trying to use a standard C++ library class (like cout, cin, or string) but the compiler gives an undeclared identifier error (C2065) on those names. Why?

2.1a

How do I know if my code is using the iostream library or STL?

2.2

I'm trying to call a Windows API, but the compiler gives an undeclared identifier error (C2065). Why?

2.3

I'm trying to call a Windows API, but the linker gives an unresolved external error (LNK2001) on the API name. Why?

2.4

Why do I get an unresolved external error (LNK2001) on main() when I make a release build of my ATL project?

2.5

I added some source files I got from someone else into my project and the compiler gives the error "C1010: unexpected end of file while looking for precompiled header directive." Why?

2.5a

Thanks. Now, what's a precompiled header?

2.6

Where is the header file atlres.h (or atlapp.h)?
Where can I download WTL?

2.7

Why do I get an unresolved external (LNK2001) error on _beginthreadex and _endthreadex?

2.8

Why do I get an unresolved external on nafxcw.lib or uafxcw.lib?

Debugging questions

3.1

What does a failed debug assert mean?

Windows UI questions

4.1

How can I save and load JPGs, PNGs, or other graphics formats?

4.2

How do I change the background color of a dialog, or draw a picture as the background?

4.3

I have a dialog that does some lengthy processing, and I need to have a Cancel button so the user can abort the processing. How do I get the Cancel button to work?

4.4

How do I change the cursor when it's in my window?

4.5

How do I show or hide a window?

4.6

How do I enable or disable a dialog control (button, edit box, etc.)?

4.7

How do I keep a window on top of all other windows?

4.8

How do I highlight an entire row of a list view control in report mode?

4.9

How do I change the background color of a static control?

4.10

How do I programmatically select an item in a list view control?

4.11

My list or tree control works fine in debug builds, but not in release builds. Why?

4.12

How do I create a newline in a multi-line edit control?

4.13

How do I prompt the user to select a directory?

4.14

How do I retrieve the text that the mouse cursor is pointing at?

4.15

How do I set the text in the caption of a frame window or dialog?

4.16

How do I set the icon that's displayed in the caption of a frame window or dialog?

4.17

How do I read the text in an edit box in another process?

4.18

How do I restrict my window so it can't be resized larger or smaller than a certain size?

Console program questions

5.1

How do I clear the screen in a console program?

5.2

With other compilers, I used to use gotoxy() to position the cursor in a console program. How do I do this in Visual C++?

5.3

How can I output text in different colors in a console application?

5.4

I've allocated a console window in my GUI program, but if the user closes the console, my program closes too. What to do?

5.5

I've allocated a console in my GUI program. When I try to close the console window, it hangs around for a while. Why?

5.6

How can I run my console program without the console window popping up?

General C++ questions

6.1

Why can't I use a member function as a callback?

6.2

How do I share a global variable among my .CPP files?

6.3

How can I change a number into its string representation, or vice versa?

6.4

How do I run another program from my program?

6.5

How do I declare and use a pointer to a class member function?

6.6

Is there a C++ equivalent to the Visual Basic "With" keyword?

MFC questions

7.1

In my MFC program, I'm trying to disable a menu item with EnableMenuItem(), but it doesn't have any effect on the menu. Why?

7.2

I'm trying to change the font of a dialog control, but it's not having any effect. Why?

7.3

How do I convert a CString to a char*?

7.4

How do I prevent a dialog from closing when the user presses Enter or Esc?

7.5

How do I remove "Untitled" from the main frame window caption?

7.6

I have a dialog-based app and want the dialog hidden on startup. How do I do this?

7.7

How can I make my main frame window non-resizable?

Other Windows topics

8.1

I've written a service and it can't access mapped network drives. Why?

8.2

A program I've written doesn't load when it's run on a computer without Visual C++ installed. Why?

8.3

How do I find the full path to my program's EXE file?

8.4

How do I read the summary information from an Office file?

8.5

How do I delete a file that is currently in use?

8.6

How do I send an email using the default mail client?

8.7

How do I tell if the computer is connected to the Internet?

Links to other Resources

=======================================================
45 Day Series: CodeProject VC++ Forum Q&A - I
By ThatsAlok.

 

Introduction

Nothing unusual... this article is a compilation of questions and answers which were asked between 10 December 2004 and 23 Jan 2005 (45 days) on the Code Project Visual C++ forum. Also, this is the first article of the 45 Days series. I hope, I will bring more on this series.

Thanks to people for their contributions on the CodeProject forum to help fellow peers in their need. I have changed some original comments to suit/maintain the look/feel of article (I beg apology for that). If I have missed something, please feel free to mail me or leave a comment at bottom.

Content

[10 Dec to 18 Dec 2004]

[19 Dec to 27 Dec 2004]

[28 Dec 2004 to 5 Jan 2005]

[6 Jan to 14 Jan 2005]

[15 Jan to 23 Jan 2005]


 

posted @ 2006-09-22 12:10  ->  阅读(462)  评论(0)    收藏  举报