|
I have tired to catch WM_QWERYENDSESSION in the PreTranslateMsg but this is not work. I found the right way, afx_msg OnQweryEndSession() ...
Pavel Sokolov,
CEZEO software,
LanTalk Network,
http://www.cezeo.com
http://www.lantalk.net
|
|
|
|
|
Hi,
I have to show a nicely formatted document with some text, lines, tables, possible pics and graphs from ActiveX controls in my app.
Could somebody please give me a pointer? Maybe some libraries?
Thanks
R.
|
|
|
|
|
I am reading "Introduction to MFC Programming with Visual C++" by Richard M. Jones. I am new to MFC and Win 32, and Visual Studio, but am otherwise a proficient and experienced programmer.
I am trying the second example from the book and it is not working as expected. Instead of a string as output all I get is integer (probably the memory address of the CString object).
#include <afx.h><br />
<br />
#include <iostream>
using namespace std;
<br />
int main()<br />
{<br />
CString s;<br />
CString sa("Strings ");<br />
CString sb = CString("are easy ");<br />
CString sc = "in MFC!";<br />
s = sa + sb + sc + '!';<br />
cout << s;<br />
<br />
::Sleep(2000);
return 0;<br />
}
As specified in the book I created a Win 32 Console App then specified "Use MFC in a shared DLL" and then built it in debug mode. I tried this with both 6.0 and .NET. The book is suposed to cover 6.0.
What is going wrong?
PS I changed the code to
cout << s.GetString();
Which works, is the book simply mistaken, out of date (it claims to cover 6.0) or am I configuring the project wrong in some way?
|
|
|
|
|
Maybe cout does not recognize a CString object.
-----
CString szText = "Testing 1 2 3";
cout << static_cast<pctstr>(szText);
-----
Kuphryn
|
|
|
|
|
You've got it in one - you need to cast it to a const char *, or get the underlying char * using a method as you have done. Or you could write an iostream inserter for CString. I have articles on CP to show you how.
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
|
|
|
|
|
Good day all, new day, new help me please
in this function to return the users system directory
CString CSetupApp::GetSystemDir()
{
CString szSystemDir((char)0, MAX_PATH);
::GetSystemDirectory(szSystemDir.GetBuffer(0), MAX_PATH);
szSystemDir.TrimLeft();
szSystemDir.TrimRight();
return szSystemDir;
}
the dir is returned correct, but i can't trim the string to add
an apps filename
eg. CString m_Nfile;
m_Nfile = GetSytemDir();
m_Nfile += "\\app.exe";
AfxMessageBox(m_Nfile);
will return "c:\Winnt\system32" or whatever your flavour
with the .Trim having no effect
if anyone can shed some light, its always appreciated.
shotgun
|
|
|
|
|
You must call ReleaseBuffer() after a GetBuffer(), and before using any other CString methods that modify the string.
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
thanks alot.
shotgun
|
|
|
|
|
Hi,
As a new beginner I would like to know that: Is it possible with Visual C++ MFC 6.0 I can install an Icon (ShortCut) that links to an application (.exe) in Run Time?
Let say I have:
a) c:\Trial_Application\Trial.exe
b) When I run my SetUp program application Visual C++ 6.0 MFC (Run Time), I would like to add at the user DeskTop an Icon ShortCut (might be the same Icon of the Trial.exe) to that Trial.exe
Some one know how to do that? I appreciate any help here!
Thanks
|
|
|
|
|
|
Hi,
I did try to do the codes, but it failed from the start: the if(SUCCEEDED(hres)) is not TRUE! I do not know why?
Even I try to get in (bypassing if) I get errors the next line (psl->SetDescription(description); ) ... I think I did not now how to use this function! Here what I called:
CreateFileShortcut("Hello","c:\\Try_Icon\\Release",
"c:\\Windows\\Desktop","IconInstallDlg.exe","Trial");
Because I have the c:\Try_Icon\Release\IconInstallDlg.exe & I would like to add an Icon on My Window Desktop ... do you my errors by calling like that?
Would you please to point out what were wrong, I am only the new Visual C++ programmer!
Many thanks,
|
|
|
|
|
Hi all,
I have a dialog that pops up every hour or so, and I'd like it to return to the previous active window after the user clicks OK on the dialog.
I've got a HWND member variable that gets the previous active window in PreCreateWindow, and a SetActiveWindow function in the PostNcDestroy of the popup dialog class. I'm not sure about where else to put these functions, --and it does bomb with an error, "...memory could not be read."
Could someone point me in the right direction? Where's the best place to do this?
Thanks in advance.
Matt
|
|
|
|
|
Found that
::SetForegroundWindow(hwnd); seems to work. Just didn't look deep enough.
Sometimes things are staring you right in the face and you don't even realize it.
Matt
|
|
|
|
|
Hi,
As a new beginner I would like to know that: Is it possible with Visual C++ MFC 6.0 I can install an Icon (ShortCut) that links to an application (.exe) in Run Time?
Let say I have:
a) c:\Trial_Application\Trial.exe
b) When I run my SetUp program application Visual C++ 6.0 MFC (at Run Time), I would like to add at the user DeskTop an Icon ShortCut (might be the same Icon of the Trial.exe) to that Trial.exe
Some one know how to do that? I appreciate any help here!
Thanks
|
|
|
|
|
This is how I would attempt to do it:
First open up a simple shortcut in notepad. Figure out the way a shortcut works and learn how to formulate one linking to your program(its fairly easy to understand whats going on)
Now in the setup program write a file to the path C:\Windows\Desktop with the extension *.lnk
That should be it
-Ken Mazaika
|
|
|
|
|
I already read a book on Win32 api programming and now I want to learn MFC.
I started reading "Teach Yourself Visual C++.Net in 21 Days" but it seemed that all I was doing was learning how to modify and the code generated my the App Wizzards.
So now I am reading "Introduction to MFC Programming with Visual C++" which devotes several chapters to covering the inner working of MFC so that when I create my first MFC app I will actually be able to read and understand the code that is gennerated. One I know the basics I will likely switch back to the Teach Yourself book. Unfortunately this book only covers Visual C++ 6.0 and I am using Visual C++ .Net.
My Questions are
1) How different is 6.0 and .NET? I am not overly concerned with changes to Visual Studios User interface. Even thought the direction give instructions for 6.0 I can still figure out how to do it in .NET. Nor am I concerned with changes with the various Wizzards. I am only worried about changes to MFC classes between versions.
2) Do you know of any up to date book that teaches the fundamentals first and the wizzards second?
3) Would I be better off reading online documents at MSDN libarary?
Thanks for your advice - Rask
|
|
|
|
|
You read a book (good start!) but do you understand how to use the APIs? You absolutely must* be proficient in programming at the API level before starting with MFC.
*I know, someone else will come along and say, "No you don't!" but you do.
--Mike--
Just released - RightClick-Encrypt v1.3 - Adds fast & easy file encryption to Explorer
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I understand how to use the APIs. In addition to reading the book and typing in the examples I spent considerable time experimenting with the source code from the book. I also make it a point whenever reading a book to write a simple application every three or four chapters that put into practice what I learned.
I also have a BS in CIS and have been programming in C/C++ for at least six years (mostly comand line stuff though).
|
|
|
|
|
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
|
|
|
|