Windows API Tutorials
Здесь есть возможность читать онлайн «Windows API Tutorials» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Жанр: Программирование, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.
- Название:Windows API Tutorials
- Автор:
- Жанр:
- Год:неизвестен
- ISBN:нет данных
- Рейтинг книги:3 / 5. Голосов: 1
-
Избранное:Добавить в избранное
- Отзывы:
-
Ваша оценка:
- 60
- 1
- 2
- 3
- 4
- 5
Windows API Tutorials: краткое содержание, описание и аннотация
Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Windows API Tutorials»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.
Windows API Tutorials — читать онлайн бесплатно полную книгу (весь текст) целиком
Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Windows API Tutorials», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.
Интервал:
Закладка:
Windows API Tutorials
The tutorials start with the most basic Windows program, the windows equivalent of "hello world!", Winnie. Then we move on to a more Genericprogram, which serves as a skeleton for a simple Windows application. Then we discuss various Controls. Using these controls one can build a complete dialog-basedapplication, whose main window is a dialog. We are then ready to discuss a Generic Dialog, a framework with which one can quickly build specific dialogs.
To do some simple graphicsone needs a Canvasobject. You use Pens and Brushesto paint on the canvas.
More advancedtopics include programming with Threadswith a practical example of a Folder Watcher— a program that watches directories for changes.
Modernwindows programming requires some knowledge of the Shell API, which leads us to the discussion of OLE and COM. We show how one can encapsulate OLE in C++ to create Smart OLE. OLE is also used in Automation, which lets your application talk to other applications.
Controls are nothing but specialized windows. You can easily create your own controls, as evidenced by the Splitter Bartutorial.
For graphicsprogrammer, we give a short introduction on using Bitmapsfor animation and a more advanced tutorial on using Direct Draw.
You can subscribeto our tutorials directly, or you can view our tutorials off-line by using the subscription option in your browser. Both Microsoft Internet Explorer 4.0 and Netscape Navigator 4.0 or later have this option.
Some of you asked why we don't provide a zipped version of the tutorials. Unfortunately we don't have the resources to keep both versions in synch. Sorry!
Here is how you subscribe to tutorials in IE 4.0:
• Add current pageto your Favoritesand
• Choose the option to subscribe by clicking on " Yes, notify me of updates and download the page for offline viewing."
• Click on " Customize,"
• Choose " Download this page and pages linked to it."
• Choose link depth 1to get all the windows tutorials (or 2, if you want the source code for the examples).
The tutorial is less than 0.5 MB and the book is about a megabyte, and you can do the downloading during off-peak hours. To update the pages on your computer,
• Select Manage Subscriptionsfrom the Favoritesmenu.
• Select the subscription(s) you want to refresh and
• Click on the Updatebutton.
When you are ready to browse, Select Work Off-linefrom your browser's Filemenu and go to your Favoritesmenu.
Follow instructions above to subscribe to each chapter separately using depth 3. Subscribing to the top page will result in following the links to Amazon, Barnes & Noble, and Microsoft.
The Simplest Windows Program
Before you can even begin thinking about programming in windows, you have to be able to understand how this simple program works. Remember to compile this and other windows programs with the STRICTcompilation flag defined!
Note: This is a Win32 program — it will run under Windows 95 and Windows NT (if they want you to program for the 16-bit platform, they should pay you twice as much!). Windows API calls are highlighted in blueand windows specific data types are shown in green. I will also usually put a double colon in front of API calls. In C++, that simply means that i'm calling a global function, in case there is some ambiguity.
Remember to compile sources as a Windows application. For instance, in Visual C++ select File.New.Projects.Win32 Application. Otherwise you'll get the error: unresolved external _main . (I provided a project file for those of you who use MS VC++ 6.0)
First, you have to define a class of windows that will be displayed by your application. In our case we will display only one window, but still, we need to give Windows some minimal information about its class. The most important part of the WinClassis the address of the callback procedure, or the window procedure. Windows is supposed to call us —it sends messages to our program by calling this procedure.
Notice the declaration of WindowProcedure. windows will call us with a handle to the window in question, the message, and two data items associated with the message, the paramters, wparam and lparam.
In WinClass we also have to specify things like the program instance handle HINSTANCE, the mouse cursor (we just load the standard arrow cursor), the brush to paint the window's background (we chose the default window color brush), and the name of our class.
Once all the fields of WNDCLASS are filled, we register the class with the Windows system.
#include
LRESULT CALLBACK WindowProcedure(HWND hwnd, unsigned int message, WPARAM wParam, LPARAM lParam);
class WinClass{
public:
WinClass (WNDPROC winProc, char const * className, HINSTANCE hInst);
void Register () {
::RegisterClass(&_class);
}
private:
WNDCLASS _class;
};
WinClass::WinClass(WNDPROC winProc, char const * className, HINSTANCE hInst) {
_class.style = 0;
_class.lpfnWndProc = winProc;// window procedure: mandatory
_class.cbClsExtra = 0;
_class.cbWndExtra = 0;
_class.hInstance = hInst; // owner of the class: mandatory
_class.hIcon = 0;
_class.hCursor = :: LoadCursor(0, idc_arrow); // optional
_class.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1); // optional
_class.lpszMenuName = 0;
_class.lpszClassName = className;
// mandatory
}
Once the Window Class is registered, we can proceed with the creation of a window. This is done by calling the CreateWindowAPI. It takes a lot of arguments, the name of the window class that we have just registered, the caption that will appear in the title bar, style, position and size, and the application instance. the rest of the arguments, for the time being, will be left equal to zero.
The window will not appear on the screen until you tell Windows to show it.
class WinMaker{
public:
WinMaker (): _hwnd (0) {}
WinMaker (char const * caption, char const * className, HINSTANCE hInstance);
void Show (int cmdShow) {
::ShowWindow(_hwnd, cmdshow);
::UpdateWindow(_hwnd);
}
protected:
HWND _hwnd;
};
WinMaker::WinMaker(char const * caption, char const * className, HINSTANCE hInstance) {
_hwnd = :: CreateWindow(
className, // name of a registered window class
caption, // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // x position
Интервал:
Закладка:
Похожие книги на «Windows API Tutorials»
Представляем Вашему вниманию похожие книги на «Windows API Tutorials» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.
Обсуждение, отзывы о книге «Windows API Tutorials» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.