📄 wpw_wapi_start_95.html
字号:
<HTML>
<HR><A NAME=WINAPI_GETTING_START>
Return to <a href="wpw_wapi_index.html#TOC">Table of Contents for this chapter</a><br>
<H4>Subject: Getting Start with Windows Programming</H4><PRE>
In article <DABnov.Bpr@news.wizvax.net> olias@wizvax.net (Robert R. Cook) writes:
>Can someone suggest a starting point for learning how to program in
>Windows? What is this I hear about the API? I am familiar with DOS
>programming under several languages (BASIC, PASCAL, FORTRAN, C, C++,
>80x86 Assembler, and some others).. but whenever I try to do something
>in Windows I get stuck. Even Visual Basic seems like it should be
>easier. I've also tried Borland's C++ and PASCAL for Windows with
>similar results. I hear that it is supposed to be so easy to program
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>in Windows. I hear that so often that I feel that I must be missing
^^^^^^^^^^^^^^^
Wow, where did you hear that? I sure don't think it is.
>something or taking the wrong approach. I am no computer slouch and I
>consider myself to be an at least semi-intelligent person.
>I am just looking to get started. Just to do the very basic operations
>necessary to write a program.
>If anyone has a good starting point I would really appreciate it.
>Maybe someone can tell me how they got started and give me a line on
>their success story.
> Any replies would be greatly appreciated.
>Thank you for your time.
The single best book for learning Windows programming is "Programming
Windows 3.1" by Charles Petzold (Microsoft Press). Most people
recommend this book - it's a classic. It doesn't waste 1000 pages
re-iterating all of the reference info that you already have in
your compiler reference manuals and/or on-line help. It's 100%
'how' & 'why' of Windows programming. It comes with a diskette
containing all of the source & .EXE for all of the samples in the
book, many of which I keep around as useful little applets for
exploring Windows. He doesn't use C++ (just plain C) so it's
not a good book for learning OWL/MFC, but it is still a good book
for learning what's going on inside.
The single greatest obstacle you will have, if you haven't run into
it before, is the idea of an event-driven message system. You
don't write code that runs in a sequence of your own design. You
write the code and just let it sit there until it is activated
by messages from the system. For example, you don't draw anything
on the screen when you want to, you *wait* until Windows tells you
it is time to [re-]draw your picture. You must be prepared to
re-paint your picture at any time. Fundamental to your understanding
of how it all works is a complete understanding of how the
GetMessage() loop works (in WinMain).
The API (Application Programming Interface) is the set of hundreds
of functions that you use to communicate with Windows. These
functions are used to create windows and do graphics. It is the
'system' and a graphics library all rolled into one. You can write
Windows programs using this raw API or you can use one of the layers
which sit on top of the API (i.e. Borland's OWL or Microsoft's MFC).
Many will disagree with me, but I recommend writing a couple of
simple applications using the raw API first. You can work with
Petzold's example for this. When you fully understand how the
messaging works, WndProc callbacks, GetMessage() loop and WM_PAINT
painting and you can put up a dialog box and display/edit/retrieve
the values, and do a couple of menu items, then perhaps you might
like to look at OWL or MFC to help you eliminate some of the drudgery.
Remember, they are just layers - underneath it all is just raw API
code like you see in Petzold's book.
Your use of OWL/MFC may also depend on your knowledge of C++.
When I started in '92, I was a C expert, but had no ++. I was
overwhelmed by it all: C++, OWL, Windows API, event-driven programming
etc. It was too much. I made the (wise) decision to start with
plain C and the raw API and Petzold's book. Far too many people
start with MFC/OWL today and many of them haven't got a clue what
the code generated by the Wizards/Experts actually does. Many
don't have any idea of what 'pumping messages' means and they
don't recognize that everything in Windows is a 'window', so
things like EnableWindow() are used for everything including controls.
Those are just a few examples. On the upside is that fact that
you can punch a couple of buttons and have the Wizard/Expert dump
out a bunch of source code that can be compiled and run immediately.
You then add in your code to this shell. Personally, I hate the
filenames, syntax and coding styles and conventions of these
Wizards/Experts and have absolutely no use for them at all.
I'm a bit biased, because I still use the raw API and you will
no doubt get a few suggestions to start with MFC/OWL. Do whatever
you feel comfortable with, but in either case, you should have
a copy of Petzold's book on your shelf to explain it all.
Good luck. We expect to see you here answering questions in six
months... :) :)
--
John A. Grant jagrant@emr1.emr.ca
Airborne Geophysics
Geological Survey of Canada, Ottawa
</PRE>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -