background preloader

MFC

Facebook Twitter

Microsoft Visual C++/MFC Tutorial - FunctionX - Iceweasel. MFC Windows Coding Guidelines - CodeProject - Iceweasel. Contents Prerequisites By function I mean: global function static/instance method Carefully read the documentation/Press F1 (Ctrl-F1) if you are not sure about something Switch these options on in your Visual Studio project options C++ - General Warning level - Level 4 (All builds) Make sure your code compiles without any single warning.

MFC Windows Coding Guidelines - CodeProject - Iceweasel

After switching to warning level 4 (or, what is worse even before) you may encounter many warnings. Rewriting some code (recommended) Using casting – but be very, I repeat very careful with it. Use ASSERT macro as often as possible _ASSERTE, ASSERT (MFC/ATL), assert (standard C++) These macros are removed during preprocessing in release builds along with expressions passed to them so they don’t hurt performance in final build at all.

They take boolean expression as parameters or any expression than can be implicitly converted to boolean. Always check for correctness of parameters passed to the function (especially pointers). Use exact type Avoid casting Do this:: Data Conversions - CodeProject - Iceweasel. Introduction Here are a few data conversions with small examples :- Decimal Conversions Decimal To Hex char hexstring[10]; int number = 30; itoa( number, hexstring, 16); Hex To Decimal char * hexstring= "ABCDEF"; char * p; int number = strtol(hexstring, &p,16); bool HexToDecimal (char* HexNumber, int& Number) { char* pStopString; Number = strtol (HexNumber, &pStopString, 16); return (bool)(Number !

Data Conversions - CodeProject - Iceweasel

Decimal to time char *DecToTime(float fTime, char *szTime) { int nHrs, nMin, nSec; fTime *= 3600; nHrs = (int)fTime / 3600; nMin = (int)(fTime - nHrs * 3600) / 60; nSec = (int)(fTime - nHrs * 3600 - nMin * 60); wsprintf(szTime, "%02d.%02d.%02d Hrs.Min.Sec String Conversions String to Hex sscanf(string, %04X, &your_word16); Hex to CString CString Str; unsigned char Write_Buff[1]; Write_Buff[0] = 0x01; Str.Format("0x0%x",Write_Buff[0]);

Customization Tips for the MFC Extensions - Iceweasel. Dynamic Link Libraries With Microsoft Foundation, Just the Facts. - CodeGuru - Iceweasel. The main purpose of this document is to provide a concise and simple explanation of how to build Dynamic Link Libraries (DLL) that contain dialog resources and use Microsoft Foundation Libraries (MFC).

Dynamic Link Libraries With Microsoft Foundation, Just the Facts. - CodeGuru - Iceweasel

A simple example is used to illustrate some common pitfalls encountered in DLL development and some of the basic interaction between application and DLL. This article assumes some basic usage and understanding of building MFC applications using the Microsoft Developer Studio and Visual C++ 6.0. The problems all began when I received the Developers Studio 6.0 and revisited a program that originated it's 32-bit days with Visual C++ 4.0.

Compiling this old project and it's dependent DLLs no longer worked correctly. The culprit; the implementation of the DLLs. The simplest method to explain this complication is to use an example project, which can be found in the zip file "MFCdll_demo.zip. " Figure 1. Now here is where a lot of confusion may occur. No problem so far. Tips for using Dynamic Link Libraries (DLLs) with MFC - CodeGuru - Iceweasel. This documents intends to give a beginner some knowledge that can be helpfull when designing a project to the Windows plataform.

Tips for using Dynamic Link Libraries (DLLs) with MFC - CodeGuru - Iceweasel

When I start a new project I try to let all the code that seams to be the most changeable in a DLL. This give me the power to change the project having to compile and distribute the minimum piece of code. But to do this work properly there are some tips that must be followed. Many of you might be asking asking Why not simply use COM ? The answer is that, of course, COM is a great choice in certain situations. A big problem of DLLs (specially those that use MFC) are the debug and release version. Copy the AAA.def to AAAD.def and change all the AAA to AAAD; In the Project/Settings, select Win32 Debug Under the tab Link change the Output file name to AAAD.DLL; Below in this property page you can see something like: /def:". Now the the debug version will create AAAD.lib and AAAD.DLL files. Programming for Changes class AFX_EXT_CLASS CFoo{}