|
Michael Dunn wrote:
You absolutely must* be proficient in programming at the API level before starting with MFC.
Bollocks. I think for a beginner it's better to learn programming with MFC, and THEN go back and learn what the API is doing for you behind the scenes. In the same way that most C++ books get it wrong by teaching how to manipulate a char* before they show you std::string, if they ever do.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
Well I think what you mean is much more, you *need to be proficient in C++ programming*. I've used most of the MFC classes but I am still learning everyday new API (for examples: wave devices, compression, windows hook, and so on...). I think a good C++ programmer can quickly learn MFC between 4-6 months before he goes after the API.
VOTD: 16 "All Scripture is God-breathed and is useful for teaching, rebuking, correcting and training in righteousness,
17 so that the man of God may be thoroughly equipped for every good work" - 2 Tim 3:16-17 (NIV)
|
|
|
|
|
Hi.
Okay, here is my MFC adventure.
I started out learning C++. C++ remains the only programming language I have learned and use. My goal has always been to develope programs for Windows. I knew at one point I will have to begin learning either MFC, Borland, Qt, or Win32 API. I remember posting messages asking members about MFC and Win32 API and trying to decide what I should start with. I decided on MFC because Win32 API was too difficult at the time.
My first venture with MFC began with Programming Windows with MFC Second Edition by Jeff Prosise. At first glance after I received that reference from Amazon was that MFC was way too complicated. Heck, there was too many code I had no idea about, which I later learned was AppWizard and ClassWizard generated code. Anyways, I began reading Prosise's book hoping to program Windows quickly. I was wrong. I was not able to learn, understand, and put to use the key concepts Prosise presents in the book. Approximately a month later I reached chapter 9, which is where Prosise introduces Doc/View architecture. I was excited because I knew that was going to be the breakthrough point where I will learn the tool to program Windows easily.
Doc/View was easy because AppWizard generates a skeletal program that you can compile and run immediately. However as I soon found out, I still have to program all aspects of the program from text, menu, toolbar, buttons, windows, views, etc. The bottomline was that I was not ready to develope a Windows program. In fact, I was nowhere near that level of experience or even understanding of MFC to develope my first project.
At that point I lost confidence. I thought MFC was too difficult. I posted a message on boards asking members concepts about Doc/View that all MFC programmers must know. I thought of quiting. Then decided to give MFC one more attempt because I saw that *MFC code was easy C++, it is the MFC generated code that really confused me*. I put Programming Windows with MFC Second Edition aside and bought *Introduction to Programmng MFC with Visual C++ by Richard Jones*. *It was the wises decision and became an important reason I made a breakthrough with MFC*.
Here is my advice:
- Start learning MFC via *Introduction to Programmng MFC with Visual C++ by Richard Jones* first
Richard Jones wrote an incredible introduction to MFC. He explains everything in a very concise, simple, and easy way to understand. His teaching technique is more effective to programmers of all levels because he explains and shows the transition from core C++ to MFC. You will see a gradual change from core C++ to MFC. That is one *key element to learning MFC and Windows programming*.
- Do all or as many exercises that from Introduction to Programming MFC with Visual C++. Finish all exercises no matter how "stupid" or "tedious" you may think of them. The most important element to learning MFC as well as all real world programming including gaming, Win32 API, Winsock, and COM is *practice*. You have to program!
*Do not start out learning MFC via Programming Windows with MFC Second Edition by Jeff Prosise* Start out with *Introduction to Programmng MFC with Visual C++ by Richard Jones* first.
- Once you are done reading and doing all exercises from Jones' book, start thinking about beginning your own projects. Remember, think big. Try to consider a project that involves many messages so you will gain experience with the way Windows handles messages. I recommend a text editor.
- Now you are ready for Programming Windows with MFC Second Edition by Jeff Prosise. It is an unparalleled MFC *reference*. You will at one point or another need to look up something from Prosise's book. There are no exceptions! Buy it, read it, and keep it as a reference. In fact, I honestly feel that all MFC programmers should have a copy of it. It is to MFC as Programming Windows by Charles Petzold is to Win32 API.
Follow the steps above and with an open mind and desire to become a decent Windows MFC programmers, I believe you will master the fundamentals of MFC without three months or less. Again, you must practice. I highly recommend that you do all exercises from Jones' book. I highly recommend that you start your own projects as soon as possible. One reason is when you start your own project, you will get an understanding of many MFC tools. You will gain experience. If you need help, post on forums. There are many experienced programmers that can and will help you. I recommend the following forums for *programming*:
C Board
CodeGuru
Code Project
GameDev Forums
MSDN Newsgroups
Do not lose hope. Have confidence and practice, practice, and practice!
Kuphryn
|
|
|
|
|
I am not worried about my ablity to learn the matterial, I am mored concerned about wasting my time. I have two 4 year degrees under my belt (Computer Science / Philosophy (helps more than you would thing!)), know a dozen languages and have been writing code since I was in junior high.
One of the most important things I have learned is to always seek advice from experts when learning something new.
For now I will stick with Richard Jones's book and then maybe read the Sams Book later to learn all the shortcuts.
|
|
|
|
|
My experience with MFC and Win32 API is very limited. Heck, my programming experience is limited. I do know and will tell you that practices do wonders.
I believe one could not go wrong learning and practicing MFC and especially Win32 API. There is no such thing as wasting time with Win32 API. Microsoft designed Win32 API to be a foundational tool for Windows OS.
Kuphryn
|
|
|
|
|
hi
i have trying to figure out MFC concepts.SOmehow i haven't yet.i bought already five or six books like Kruglinski , sams 21 days ,beginnig vc++.somehow i am impressed with your advice and jsut ordered this book by Jones.hope i will be in good stead in no time
.thansk
chandra
|
|
|
|
|
Raskolnikov wrote:
Would I be better off reading online documents at MSDN libarary?
From the sounds of things you have enough experience that maybe you should consider reading the MSDN and maybe some of the stuff here on CP. The MSDN doesn't really show you how to program, but if you know that already, it documents MFC just fine.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
An argument to a method said it takes an LPDISPATCH. I didnt find it in the mSDN. Anyways my purpose was to blank out a picture box (third party) and when I put FALSE in the function, it gave me the desired result. So what exactly is an LDISPATCH. How is it that FALSE is an LDISPATCH?
|
|
|
|
|
typedef IDispatch *LPDISPATCH;
Look for documentation on IDispatch
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
I have had the same question some time ago, so my investigations might help you to.
IDispatch in COM is like history in life, it is the mother of everything.On the other hand they are like women, they dont have any useful feature but you still cannot exist without them.
If you have this poiter you can gain access to any other related pointer by calling QI (QueryInterface) on it.
Thus the pointer itself is of no ethical value.
Hope this helps.
|
|
|
|
|
I have a program in which most of my users wish to be able to press Enter to go from field to field instead of Tab.. I have been putting this off for quite a while because I have been assuming that I would have to override the CEdit class and all other resource classes that I use..
what ive noticed is that nowhere else in the software do you need to hit enter.. so I'm wondering if there is a way to always reinterpret an Enter key press as a Tab key.. Or even a whole dialog at a time?
any suggestions?
-dz
|
|
|
|
|
|
You could write an event handler for the WM_KEYDOWN event, and if the key pressed was event then call the default event handler after changing the key pressed to Tab.
Does that make sense?
Pete
|
|
|
|
|
Hi all
I have C++ application that I want people to demo via a webpage.
Is it posible to Write a Java Applet to interface my application?
I would of course have to serve the application off of my web server.
Is this possible??
any help appreciated.
IGeorgeI
George W
Software Developer
www.zsystems.ca
|
|
|
|
|
|
if u mean a java runs ur c++ exe, it is very easy, use java code:
Runtime.exec
that is all.
includeh10
|
|
|
|
|
Hi all,
I need to set quota limit for users on a shared folder on a file server.
How to implemented it in VC++? Is there a API function?
Thanks
|
|
|
|
|
Check these COM interfaces:
IDiskQuotaControl
IDiskQuotaEvents
IDiskQuotaUser
IDiskQuotaUserBatch
IEnumDiskQuotaUsers
AFAIK, there's no non-COM API with HQUOTAs and such.
Tomasz Sowinski -- http://www.shooltz.com
Never argue with an idiot, he'll bring you to his level and beat you with experience.
|
|
|
|
|
Dear all,
This problem of mine has been bugging me crazy.
I have to load a 24bit .bmp file and convert it to a 32 bit bmp file.
I've manage to load the bitmap file, display it on the screen and even made the code to make it a 32bit bitmap.
The problem is to attach the modified bits to the m_bmpBitmap CBitmap object. Then I get the info of the m_bmpBitmap with the BITMAP structure.
BITMAP bm;
m_bmpBitmap.GetBitmap(&bm);
The bm.bmBits is 0x0 which it shouldn't be.
All the CreateBitmap() and GetBitmap() funtions return successful but I can't even display the image to screen and I feel it is due to bm.bmBits = 0x0.
I've even tried to create a 24 bit bitmap with the same method below and it didn't work too.
I would like to be able to view the image that I created and as well as to be able to save it. I welcome any new ideas on how to approach this matter.
Many many thanks.
Chun Te, Ewe
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
CBitmap m_bmpBitmapOri;
CBitmap m_bmpBitmap;
BYTE *m_pOriSrc, *m_pSrc;
HBITMAP hBitmap = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(), "h:\\logo.bmp"
,IMAGE_BITMAP, 0, 0, R_LOADFROMFILE | LR_CREATEDIBSECTION);
m_bmpBitmapOri.Attach(hBitmap);
BITMAP bmOri;
m_bmpBitmapOri.GetBitmap(&bmOri); // Get the loaded bitmap
m_pOriSrc = (BYTE*)bmOri.bmBits; // Pointer to the original bitmap bits
// Prepare a new location
if(m_pSrc!=NULL) delete [] m_pSrc;
m_pSrc = new BYTE[(bmOri.bmHeight+1)*bmOri.bmWidth*4];
...
some code to change from 24bpps to 32 bpps (if needed I can provide)
...
if (m_bImageValid) m_bmpBitmap.DeleteObject();
// Creating the image
m_bmpBitmap.CreateBitmap( bmOri.bmWidth, bmOri.bmHeight, 1, 32, m_pSrc );
BITMAP bm; // Obtain info regarding bitmap
m_bmpBitmap.GetBitmap(&bm); //
// Create a device contect to load the bitmap into
CDC dcMem;
CClientDC pDC(this);
dcMem.CreateCompatibleDC(&pDC);
dcMem.SelectObject(m_bmpBitmap);
pDC.BitBlt(250, 7, bm.bmWidth, bm.bmHeight, &dcMem, 0, 0, SRCCOPY);
// Won't display image
|
|
|
|
|
I want to scroll to the last line of my edit box. Is there a simple way to do this? Thanks
-Ken Mazaika
|
|
|
|
|
I tried this...is there a reason it didn't work?
class CMsgBox : public CEdit<br />
{<br />
protected:<br />
LESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);<br />
};<br />
<br />
<br />
and in the module:
#include "headerFile.h"<br />
<br />
LRESULT CMsgBox::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)<br />
{<br />
LRESULT result = CEdit::DefWindowProc(message, wParam, lParam);<br />
if (message == WM_SETTEXT)<br />
SendMessage(EM_SCROLL, SB_BOTTOM, 0);<br />
return result;<br />
}<br />
Is there something I'm going wrong? Thanks.
-Ken Mazaika
|
|
|
|
|
My release build works but the debug build crashes at at the delete. It says its a memory check error. The release version sails on through. Actually the debug version will keep going after the crash(retry) then crash again, and retry restores it. So the logic is working but I'm doing something really wrong.
memory check error at 0x002F59AA = 0x00, should be 0xFD.
Any ideas?
Thanks,
ns
char* photo1;
photo1 = new char [strlen(pDoc->m_db.m_photoInfo)];
strcpy(photo1,pDoc->m_db.m_photoInfo);
char* pDelimiter = strstr (photo1, ",");
ASSERT (pDelimiter != NULL);
*pDelimiter = '\0';
char* dbname = photo1;
m_PhotoDBName = dbname;
pDelimiter++;
CString mineName = pDelimiter;
<code> delete[] photo1</code>;
When I hit debug, it gave the error (user breakpoint called from code at (some address).
It went into dbgheap.c. Does this help in diagnosing the problem?
|
|
|
|
|
You need to allocate room for the terminating NULL
photo1 = new char [strlen(pDoc->m_db.m_photoInfo) + 1];
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
Well, that took care of one of them! The next crash is again at a delete[] (I just started using delete!) It turns out to be a variable I dont need, but still want to know whats wrong:
m_pCommandPhoto->ActiveConnection = m_pConn1;
CString partQuery = "'"+MineName+"'";
char* partQuery0 = new char(partQuery.GetLength()+1);
strcpy(partQuery0,partQuery);
CString SQLQ = "SELECT * FROM tblMine WHERE (DefID = "+partQuery+")";
char* SQLQuery = new char [SQLQ.GetLength()+1];
strcpy(SQLQuery, SQLQ);
AfxMessageBox(SQLQuery);
<code>delete[] partQuery0;</</code>pre>
Thanks,
ns
|
|
|
|
|
You've used () in the new statement, which makes the length a parameter that is passed to the char constructor. This means that your newing with the non-[] form so delete [] fails
change it to
char* partQuery0 = new char[partQuery.GetLength()+1];
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|