На главную

On-line справка по Win32 API

Написать письмо
БЕСПЛАТНАЯ ежедневная online лотерея! Выигрывай каждый день БЕСПЛАТНО!
Список всех статей A-B-C-D-E-F-G-H-I-J-K-L-M-N-O-P-Q-R-S-T-U-V-W-X-Y-Z | Скачать Вниз

Obtaining a Private Display Device Context



An application performing numerous drawing operations in the client area of its window must use a private display device context. To create this type of device context, the application must specify the CS_OWNDC constant for the style member of the WNDCLASS structure when registering the window class. After registering the window class, the application obtains a handle identifying a private display device context by calling the GetDC function.

The following example shows how to create a private display device context.

#include /* required for all Windows apps */
#include
#include /* strtok */
#include "dc.h" /* specific to this program */

/* Function prototypes */

BOOL InitApplication(HINSTANCE);
long FAR PASCAL MainWndProc(HWND, UINT, UINT, LONG);

/* Global variables */

HINSTANCE hinst; /* handle of current instance */
HDC hdc; /* display device context handle */

.
.
.

BOOL InitApplication(HINSTANCE hinstance)
{
WNDCLASS wc;

/*
* Fill in the window class structure with parameters
* describing the main window.
*/

wc.style = CS_OWNDC; /* Private-DC constant */
wc.lpfnWndProc = (WNDPROC) MainWndProc;

wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hinstance;

wc.hIcon = LoadIcon((HINSTANCE) NULL,
MAKEINTRESOURCE(IDI_APPLICATION));


wc.hCursor = LoadCursor((HINSTANCE) NULL,
MAKEINTRESOURCE(IDC_ARROW));

wc.hbrBackground = GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = "GenericMenu";
wc.lpszClassName = "GenericWClass";

/* Register the window class and return the
* resultant code.
*/

return RegisterClass(&wc);
}

LRESULT APIENTRY MainWndProc(
HWND hwnd, /* window handle */
UINT message, /* type of message */

WPARAM wParam, /* additional information */
LPARAM lParam) /* additional information */
{

PAINTSTRUCT ps; /* paint structure */

/* Retrieve a handle identifying the private DC. */

hdc = GetDC(hwnd);

switch (message) {

case WM_PAINT:
BeginPaint(hwnd, &ps);

.
. /* Draw and paint using private DC. */
.



Пригласи друзей и счет твоего мобильника всегда будет положительным!
Предыдущая статья
 
Сайт Народ.Ру Интернет
Следующая статья
Пригласи друзей и счет твоего мобильника всегда будет положительным!

Получающий Частный Дисплейный Контекст Устройства



Приложение, выполняющее многочисленные действия чертежа в области клиента своего окна должно использовать частный дисплейный контекст устройства. Чтобы создавать этот тип контекста устройства, приложение должно определить константу CS_OWNDC для члена стиля структуры WNDCLASS при регистре класса окна. После того, как зарегистрировать класс окна, приложение получает ручку, опознающую частный дисплейный контекст устройства вызывая функцию GetDC.

Следующий пример показывает как, чтобы создавать частный дисплейный контекст устройства.

#include /* необходимый для всего Окна кв. */ #include
#include /* strtok */ #include "dc.h" /* специфический в эту программу */

/* Функциональные прототипы */

BOOL InitApplication(HINSTANCE);
долго (длиной) ЗНАЧИТЕЛЬНО PASCAL MainWndProc(HWND, UINT, UINT, ДОЛГО (ДЛИНОЙ));

/* Глобальные переменные */

HINSTANCE hinst; /* ручка текущего примера */ hdc HDC; /* контекстная ручка дисплейного устройства */

.
.
.

BOOL InitApplication(hinstance HINSTANCE)
{
wc WNDCLASS;

/*
* Заполните структуру класса окна параметрами
* описывая основное окно.
*/

wc.style = CS_OWNDC; /* КОНСТАНТА Private-DC */ wc.lpfnWndProc = (WNDPROC) MainWndProc;

wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hinstance;

wc.hIcon = LoadIcon((HINSTANCE) НЕДЕЙСТВИТЕЛЬНЫЙ, MAKEINTRESOURCE(IDI_APPLICATION));


wc.hCursor = LoadCursor((HINSTANCE) НЕДЕЙСТВИТЕЛЬНЫЙ, MAKEINTRESOURCE(IDC_ARROW));

wc.hbrBackground = GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = "GenericMenu";
wc.lpszClassName = "GenericWClass";

/* Зарегистрируйте класс окна и возвращайте the
* равнодействующий код.
*/

возвращайте RegisterClass(&wc);
}

LRESULT APIENTRY MainWndProc( HWND hwnd, /* РУЧКА окна */ сообщение UINT, /* тип сообщения */

WPARAM wParam, /* ДОПОЛНИТЕЛЬНАЯ информация */ LPARAM lParam) /* дополнительная информация */
{

ps PAINTSTRUCT; /* структура краски */

/* Извлеките ручку, опознающую частный DC. */

hdc = GetDC(hwnd);

ключ (сообщение) {

случай WM_PAINT: BeginPaint(hwnd, &ps);

.
. /* Сделайте и закрашивайте использование частный DC. */
.



Вверх Version 1.3, Oct 26 2010 © 2007, 2010, mrhx Вверх
 mrhx software  Русский перевод OpenGL  Русский перевод Win32 API
 
Используются технологии uCoz