|
Alan Balkany wrote: With MFC, problems that should take minutes to solve sometimes take days.
How so? I always found it very simple, and if you want part of th win32 api that isnt wrapped by MFC you just call it directly. You can edit the message map simply to add WM_XXXXX commands that arent handled by the class wizzard, and can simply modify the comnstructors to pass all kinds of data round.
The only complexity would be implementing something complex, like windows hooks or some such, but that would be the same with MFR of raw win32 API.
But I agree, learn .Net and C#, it has WAY more commercial demand. (By the way, I didnt know you can use C++ with ,Net. I am a kernel guy and dont venture into user mode that much these days.)
==============================
Nothing to say.
|
|
|
|
|
The consistently incomplete documentation for MFC makes it difficult to use.
Of course an MFC expert can easily use it to solve problems. But it's not user friendly to someone who's not an expert. With .NET and intellisense, you can use .NET effectively even if you don't know it very well.
A couple examples of MFC landmines that eat up the hours and days of your development time:
1. You have a CBitmap and you want to load a .bmp file from disk. How do you do it?
(HINT: CBitmap::LoadBitmap () doesn't work. How retarded is that?)
2. You see that OnDraw () is used to update windows. Fair enough. But you try to use it on a CDialog and it doesn't f***ing work!. Part B: You try to use it on a CFrameWnd and it doesn't f***ing work, but for a DIFFERENT reason!
MFC is full of garbage like this! (And I used it back in 1997 when you couldn't just go to the Internet for a quick answer.) MFC is one of the reasons I hate Microsoft!
modified 4-Mar-13 11:20am.
|
|
|
|
|
Alan Balkany wrote: CBitmap::LoadBitmap () doesn't work. How retarded is that?
Why Windows didn't add simple .bmp, .jpg and .zip file reader/writer APIs way back with Windows 95 has always been a mystery to me.
|
|
|
|
|
I suspect it's because Microsoft sees ALL other developers as potential competition to THEIR products, so they insert conceptual roadblocks and missing or undocumented functionality to slow them down.
|
|
|
|
|
I think it was a combination of incompetence, lack of vision, arrogance and a fear of lawsuits (for the JPG and zip stuff.)
Alan Balkany wrote: undocumented functionality to slow them down.
Contrary to popular belief, that is very rare. Almost all undocumented functionality that is useful is actually provided through other means. Frankly, the biggest problems with Windows is the COM kick they got on in the 90s and that Microsoft engineers tend to over-engineer everything favoring complexity over simplicity (an all too common problem with all engineers.)
|
|
|
|
|
There is a value in MFC even this days. A lots of applications are written with MFC, and some of them(which are usually time critical or compute intence) are still will be written in MFC.
If you interested in learning MFC, the good start is Ivor Horton's "Visual C++ 2010".
|
|
|
|
|
|
Ideally, for learning C++, you do not need a GUI.
You can simply the console message using cout.
If you still need a GUI, MFC is the best bet for native C++.
ATL also has window classes and there is an unsupported windowing framework called WTL that builds on top of this.
In the .Net world there is a C++ extension called C++/CLI that has a GUI.
But this is not strictly C++ because new syntax has been introduced.
Metro apps or Windows Store apps use XAML for its GUI.
But this is also not native C++.
It is another extension called C++/CX that is very similar to C++/CLI in syntax.
So if you really want to learn C++, simply use cout to output messages because it will work not matter what OS you're running it on.
|
|
|
|
|
I need to develop commercial level application
|
|
|
|
|
That depends on what you mean by "value". If you're just thinking about its usefulness on your résumé there are probably better choices.
To the .net is better camp all I've got to say is, personally I'm glad I went from lower level programming environments and worked my way up. I think that actually knowing what's going on makes you a better programmer.
Steve
|
|
|
|
|
If your application is Windows specific and needs any sort of performance advantage, MFC is fantastic. Personally, I like the enhancements to it offered by CodeJock, but to each his own. People like to gripe about MFC because it doesn't have C++ purity, but who cares; it's fast and, with a few exceptions, stays out of my way (in what matters to me.)
On the other hand, for database front ends, ASP and UI applications where you are willing to give up some fine grained control, a little performance AND you are still Windows specific, .NET is the way to go. Some people here have advocated going the Silverlight route. I'm not a fan, but my work doesn't fall into the niche where Silverlight makes sense.
For cross platform, despite some its ugliness, including it's massive size and very annoying pre-compiler, Qt is probably the best bet. (WxWidgets is also worth looking into, but I'm more familiar with Qt and personally find it better going forward, though I could change my mind tomorrow.)
I do agree with a comment above; if you are just learning C++, don't bother with a GUI. Same with C#. Just use the console and try to keep the code as procedural as possible and build from there once you get the basic concepts down. To be honest, I prefer people start with C, but that may not be realistic today.
|
|
|
|
|
Joe Woodbury wrote: I prefer people start with C, but that may not be realistic today.
I learnt C++ first and C to me was just C++ but with a list of exclusions. Worked well.
Steve
|
|
|
|
|
Hi,
I have a picture control on a dilaog box which is contained in a property sheet. Now whenever I increase the resolution of the PC, size of the controls on my application will be same, and it will show some space to the right of the application controls when it is displayed. I can change the position of the controls but how to increase the width & height of a bitmap in mfc.
Controls size will remain same irrespective of the resolution of the monitor, rather it will show an empty space at the bottom & right of the controls ( in case ur monitor size is large and you increase the resolution).
Any help will be appreciated.
Regards,
Mbatra
|
|
|
|
|
How you draw the bitmap into picture control ?
|
|
|
|
|
Hi,
The 'Type' property of Picture Control has been set as Frame.
The Bitmap position is just fixed on the window.
Regards,
Mbatra
|
|
|
|
|
You can use the CopyImage() function to scale a bitmap. With a CStatic picture control it can be used this way:
void CMyStatic::ScaleImage(const CSize& sz)
{
HBITMAP hBitmap = GetBitmap();
if (hBitmap)
{
HBITMAP hCopy = (HBITMAP)CopyImage(hBitmap, IMAGE_BITMAP, sz.cx, sz.cy, 0);
if (hCopy)
{
SetBitmap(hCopy);
::DeleteObject(hBitmap);
}
}
}
Another option is to use owner drawing calling StretchDIBits() to scale the image.
But resizing a bitmap may result in bad looking images.
|
|
|
|
|
I've dug up SteveKing's old article SpellEdit:
SpellEdit[^]
Originally it was made for Visual Studio 7.1 (2003) but I managed to fiddle with it to get it compiling/working under Visual Studio 6.0 (because that's what I have).
Everything is working however the project is non-UNICODE. So I converted the project into UNICODE and now I get lots of build errors, such as:
error C2664: 'spell' : cannot convert parameter 1 from 'class CString' to 'const char *'
The whole MySpell library/code uses char * everywhere... and even HunSpell uses char * everywhere too. So how come previously (in non-UNICODE) there was an implicit conversion between CString & const char *, but after changing project to UNICODE I get this error.
PS: This is not problem about converting CString to char * - even though I've tried this, it just doesn't work.
|
|
|
|
|
A quote from the MySpell link of the SpellEdit article:
Quote: MySpell has been replaced with hunspell starting with OpenOffice.org 2.0.2. Hunspell builds on MySpell but supports Unicode and adds several other useful features. So you can't use MySpell with Unicode builds because it supports only ANSI character sets.
Hunspell has Unicode support but uses UTF-8 strings while Windows uses UTF-16. So Windows strings must be converted to UTF-8 before passing them to the spell checker.
With UTF-8, strings are still passed as char* because a single character is encoded as sequences of bytes with variable length while UTF-16 charcters are represented by two bytes (wchar_t ). When using CString objects, they will be CStringA or CStringW according to the Unicode setting of your project. You may use CString s to convert between ANSI and Unicode:
LPCSTR lpszAnsi = "ANSI text";
LPWCSTR lpszWide = L"Unicode text";
CStringA strA = lpszWide; CStringW strW = lpszAnsi;
But for UTF-8 conversions, you must use WideCharToMultiByte() and MultiByteToWideChar() .
You may have a look at http://sourceforge.net/projects/hunspell/files/Misc/RichEdit/[^] which implements spell checking for a RichEdit control using Hunspell.
|
|
|
|
|
Hello Friends
I am creating a MfC Dialog based application using vs2010 in XP. I am adding some controls to dialog by using Template. Now,When I am opening that application in Win7, the default XP style with additional control is coming fine but it replacing Win7 Dialog standard controls like Search feature.
And If i Pass the last parameter to CFiledialog [bVistaStyle] to TRUE then only Win7 style dialog is appearing but not additional controls tht i added using template.
I want dialog should appear like Xp style with template and and with win7 standard controls too.
Any Ideas ?
Regards
Y
|
|
|
|
|
yogeshs wrote: Any Ideas ? Yes, but unlessyou show us the code that is not working it is unlikely that we can guess what is going wrong.
Use the best guess
|
|
|
|
|
 Here is the Class that i Sublasses from CFileDialog with setting last parameter in CFileDialog bVistaStyle to FALSE.
FileDialogTemplate::FileDialogTemplate(const LPCSTR caption, BOOL bOpenFile,
LPCSTR lpszDefExt, LPCSTR lpszFileName, DWORD dwFlags, LPCSTR lpszFilter,
CWnd* pParentWnd, int idx, BOOL pain, BOOL sav7, char* DefDir, int typ,
BOOL ivrit, int ver, int nVersion, BOOL multy, LPFNDLL_SWITCHREAD pSwitchRead)
: CFileDialog(bOpenFile, bOpenFile ? lpszDefExt : NULL,
alignFileName(lpszFileName),
(typ == sf_spec) ?
((dwFlags != 0) ? dwFlags : OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT) :
(typ == sf_bmp || typ == sf_fpf) ?
(OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT |
OFN_NOCHANGEDIR | OFN_ENABLETEMPLATE | OFN_EXPLORER) :
(typ == sf_dsn_dir) ?
(OFN_HIDEREADONLY | OFN_NOVALIDATE | OFN_ENABLETEMPLATE | OFN_EXPLORER) :
(typ == sf_dsn || typ == sf_dsp || typ == sf_rul) ?
(OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT |
OFN_ENABLETEMPLATE | OFN_EXPLORER) :
(typ == sf_log) ?
(OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_EXPLORER) :
(OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER),
lpszFilter, pParentWnd,0UL,FALSE)
{
m_pSwitchRead = pSwitchRead;
m_DefExt = (bOpenFile || lpszDefExt == NULL) ? "" : lpszDefExt;
m_Multy = multy && bOpenFile;
HMODULE hResourceOld = ::AfxGetResourceHandle();
::AfxSetResourceHandle(SHARED_RES_MODULE);
ivrit_eng = ivrit;
m_ver = (typ == sf_dsn_dir ||
typ == sf_dsn || typ == sf_dsp || typ == sf_rul) ? ver : 0;
rul_num = rul_size_num = 0;
bOpenFileDialog = bOpenFile;
sv7 = FALSE;
paint = (pain &&
(typ == sf_dsn_dir || typ == sf_dsn || typ == sf_dsp || typ == sf_bmp ||
typ == sf_rul || typ == sf_fpf || typ == sf_spec));
type = typ;
save7 = 0;
m_pImage = NULL;
m_Bitmap = NULL;
m_IsModulateFile = FALSE;
m_SizeSel = 0;
m_ofn.hInstance = SHARED_RES_MODULE;
title = new char[_MAX_PATH];
title[0] = '\0';
m_ofn.lpstrFileTitle = title;
m_ofn.nMaxFileTitle = _MAX_PATH;
int buf_size = 65536;
file_buf = new char[buf_size];
file_buf[0] = '\0';
file_buf[buf_size-1] = '\0';
if ( lpszFileName != NULL )
lstrcpyn(file_buf, lpszFileName, buf_size-1);
m_ofn.lpstrFile = file_buf;
m_ofn.nMaxFile = buf_size - 1;
if ( caption != NULL ) {
m_ofn.lpstrTitle = caption;
} else
m_ofn.lpstrTitle = title;
LPCSTR DefExt = lpszDefExt;
char un[8];
if ( idx != 0 && lpszFilter != NULL ) {
m_ofn.nFilterIndex = (DWORD)idx;
int ii = idx + idx - 1, in = 0;
const char* p = lpszFilter;
while ( ii > 0 ) {
if ( *p == '|' )
ii--;
p++;
}
p += 2;
while ( *p != '|' && in < 4 )
un[in++] = *p++;
un[in] = (char)0;
DefExt = un;
}
lstrcpyn(str, ::TGetIniString("ExtPath", DefExt), _MAX_PATH);
m_ofn.lpstrInitialDir = (DefDir == NULL) ? str : DefDir;
m_ofn.lpTemplateName = MAKEINTRESOURCE(
(ver == 0) ? IDD_OPENSAVE_TEMPLATE : IDD_OPENSAVE_TEMPLATE_NEW);
if ( !bOpenFile && typ != sf_dsn_dir )
m_ofn.Flags |= OFN_FILEMUSTEXIST;
NOVALIDATE_flag = ((m_ofn.Flags & OFN_NOVALIDATE) != 0);
if ( !NOVALIDATE_flag && typ != sf_dsn_dir )
m_ofn.Flags |= OFN_NOVALIDATE;
if ( m_Multy )
m_ofn.Flags |= OFN_ALLOWMULTISELECT;
m_view_mode = -1;
::AfxSetResourceHandle(hResourceOld);
}
Regards
Y
|
|
|
|
|
Sorry, but I cannot make head or tail of the above code. I would suggest you do some testing with basic CFileDialog templates to try and see what differences are happening.
Use the best guess
|
|
|
|
|
ok, I will try that way.
Thanks.
Regards
Y
|
|
|
|
|
I want to change my system IP, subnet mask, host name etc. using win32 VC++.
I've tried AddIPAddress function but that's not persistent.
I want to change it that it should be change without rebooting system and should be there after restarting the system.
Thanks!
|
|
|
|
|
|