#define UNICODE
#include <windows.h> // includes basic windows functionality
#include <windowsx.h>
#include <tchar.h>
void DrawRectangles(HDC);
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
switch (wmId)
{
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
WNDCLASS wc;
MSG Messages;
wc.style = 0;
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); //не может быть NULL
wc.lpszMenuName = L"LISTMENU";
wc.lpszClassName = L"MonClass";
RegisterClass( &wc );
HWND hWndMain;
hWndMain = CreateWindow( L"MonClass",
L"Title",
WS_OVERLAPPEDWINDOW,
10, 10,
20, 20,
NULL, NULL, hInstance, NULL );// An unhandled win32 exception occured in PROG.EXE
// if window could not be created, return "failure"
if ( ! hWndMain ) {
return NULL;
}
MessageBox(NULL, L"MESSAGEBOX",L"IS WORKS",MB_OK);
ShowWindow( hWndMain, nCmdShow );
UpdateWindow( hWndMain );
/*!!!цикл обработки сообщений!!!*/
while (GetMessage (&Messages, NULL, 0, 0))
{
TranslateMessage(&Messages);
DispatchMessage(&Messages);
}
HBRUSH hbrush, hbrushOldBrush;
int nOldPolyFillMode;
// Координаты вершин первого многоугольника
POINT ptPoints1[] =
{
{10, 10}, {100, 310}, {40, 300},
{300, 15}, {135, 340}, {113, 125},
{250, 137}, {300, 300}
};
// Координаты вершин второго многоугольника
POINT ptPoints2[] =
{
{310, 10}, {400, 310}, {340, 300},
{600, 15}, {435, 340}, {413, 125},
{550, 137}, {600, 300}
};
// Выбираем встроенную серую кисть
hbrush = GetStockBrush(GRAY_BRUSH);
hbrushOldBrush = SelectBrush(hdc, hbrush);
// Рисуем первый многоугольник в режиме
// заполнения ALTERNATE, установленном
// по умолчанию
Polygon(hdc, ptPoints1,
sizeof ptPoints1 / sizeof ptPoints1[0]);
return Messages.wParam;
}
Графика в WinApi?
Я в winApi не разбираюсь дайте исходник попонятней я переделаю под себя!
Я так пытался но не выходит.
Код:
ну, в общем пример ты нарыл правильный. только всё своё рисование перенеси между строчками BeginPaint и EndPaint и будет тебе счастье :)
Код:
#define UNICODE
#include <windows.h> // includes basic windows functionality
#include <windowsx.h>
#include <tchar.h>
void DrawRectangles(HDC);
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
switch (wmId)
{
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
WNDCLASS wc;
MSG Messages;
wc.style = 0;
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); //не может быть NULL
wc.lpszMenuName = L"LISTMENU";
wc.lpszClassName = L"MonClass";
RegisterClass( &wc );
HWND hWndMain;
hWndMain = CreateWindow( L"MonClass",
L"Title",
WS_OVERLAPPEDWINDOW,
10, 10,
20, 20,
NULL, NULL, hInstance, NULL );// An unhandled win32 exception occured in PROG.EXE
// if window could not be created, return "failure"
if ( ! hWndMain ) {
return NULL;
}
MessageBox(NULL, L"MESSAGEBOX",L"IS WORKS",MB_OK);
ShowWindow( hWndMain, nCmdShow );
UpdateWindow( hWndMain );
/*!!!цикл обработки сообщений!!!*/
while (GetMessage (&Messages, NULL, 0, 0))
{
TranslateMessage(&Messages);
DispatchMessage(&Messages);
}
BeginPaint();
HBRUSH hbrush, hbrushOldBrush;
int nOldPolyFillMode;
// Координаты вершин первого многоугольника
POINT ptPoints1[] =
{
{10, 10}, {100, 310}, {40, 300},
{300, 15}, {135, 340}, {113, 125},
{250, 137}, {300, 300}
};
// Координаты вершин второго многоугольника
POINT ptPoints2[] =
{
{310, 10}, {400, 310}, {340, 300},
{600, 15}, {435, 340}, {413, 125},
{550, 137}, {600, 300}
};
// Выбираем встроенную серую кисть
hbrush = GetStockBrush(GRAY_BRUSH);
hbrushOldBrush = SelectBrush(HDC, hbrush);
// Рисуем первый многоугольник в режиме
// заполнения ALTERNATE, установленном
// по умолчанию
Polygon(HDC, ptPoints1,
sizeof ptPoints1 / sizeof ptPoints1[0]);
EndPaint ();
return Messages.wParam;
}
#include <windows.h> // includes basic windows functionality
#include <windowsx.h>
#include <tchar.h>
void DrawRectangles(HDC);
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
switch (wmId)
{
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
WNDCLASS wc;
MSG Messages;
wc.style = 0;
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); //не может быть NULL
wc.lpszMenuName = L"LISTMENU";
wc.lpszClassName = L"MonClass";
RegisterClass( &wc );
HWND hWndMain;
hWndMain = CreateWindow( L"MonClass",
L"Title",
WS_OVERLAPPEDWINDOW,
10, 10,
20, 20,
NULL, NULL, hInstance, NULL );// An unhandled win32 exception occured in PROG.EXE
// if window could not be created, return "failure"
if ( ! hWndMain ) {
return NULL;
}
MessageBox(NULL, L"MESSAGEBOX",L"IS WORKS",MB_OK);
ShowWindow( hWndMain, nCmdShow );
UpdateWindow( hWndMain );
/*!!!цикл обработки сообщений!!!*/
while (GetMessage (&Messages, NULL, 0, 0))
{
TranslateMessage(&Messages);
DispatchMessage(&Messages);
}
BeginPaint();
HBRUSH hbrush, hbrushOldBrush;
int nOldPolyFillMode;
// Координаты вершин первого многоугольника
POINT ptPoints1[] =
{
{10, 10}, {100, 310}, {40, 300},
{300, 15}, {135, 340}, {113, 125},
{250, 137}, {300, 300}
};
// Координаты вершин второго многоугольника
POINT ptPoints2[] =
{
{310, 10}, {400, 310}, {340, 300},
{600, 15}, {435, 340}, {413, 125},
{550, 137}, {600, 300}
};
// Выбираем встроенную серую кисть
hbrush = GetStockBrush(GRAY_BRUSH);
hbrushOldBrush = SelectBrush(HDC, hbrush);
// Рисуем первый многоугольник в режиме
// заполнения ALTERNATE, установленном
// по умолчанию
Polygon(HDC, ptPoints1,
sizeof ptPoints1 / sizeof ptPoints1[0]);
EndPaint ();
return Messages.wParam;
}
Код:
1>------ Rebuild All started: Project: winapi, Configuration: Debug Win32 ------
1>Deleting intermediate and output files for project 'winapi', configuration 'Debug|Win32'
1>Compiling...
1>1.cpp
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(1) : warning C4005: 'UNICODE' : macro redefinition
1> command-line arguments : see previous definition of 'UNICODE'
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(21) : warning C4065: switch statement contains 'default' but no 'case' labels
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(77) : error C2660: 'BeginPaint' : function does not take 0 arguments
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(99) : error C2059: syntax error : ','
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(104) : error C2275: 'HDC' : illegal use of this type as an expression
1> c:\program files\microsoft sdks\windows\v6.0a\include\windef.h(267) : see declaration of 'HDC'
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(106) : error C2660: 'EndPaint' : function does not take 0 arguments
1>Build log was saved at "file://c:\Documents and Settings\Стас\Мои документы\Visual Studio 2008\Projects\winapi\winapi\Debug\BuildLog.htm"
1>winapi - 4 error(s), 2 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
1>Deleting intermediate and output files for project 'winapi', configuration 'Debug|Win32'
1>Compiling...
1>1.cpp
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(1) : warning C4005: 'UNICODE' : macro redefinition
1> command-line arguments : see previous definition of 'UNICODE'
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(21) : warning C4065: switch statement contains 'default' but no 'case' labels
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(77) : error C2660: 'BeginPaint' : function does not take 0 arguments
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(99) : error C2059: syntax error : ','
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(104) : error C2275: 'HDC' : illegal use of this type as an expression
1> c:\program files\microsoft sdks\windows\v6.0a\include\windef.h(267) : see declaration of 'HDC'
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(106) : error C2660: 'EndPaint' : function does not take 0 arguments
1>Build log was saved at "file://c:\Documents and Settings\Стас\Мои документы\Visual Studio 2008\Projects\winapi\winapi\Debug\BuildLog.htm"
1>winapi - 4 error(s), 2 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
BeginPaint\EndPaint у тебя изначально правильно располагались в WndProc возле WM_PAINT вот туда и перенеси код рисования
Цитата: rezer
Добавил я эти функции но что-то не компилится.
Прежде чем использовать эти функции, почитайте их описание.
Код:
#include "stdafx.h"
#include "Laba4b.h"
#include <WinGdi.h>
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
// Forward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
void Paint(HDC *hDC);
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_LABA4B, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_LABA4B));
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage are only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_LABA4B));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_LABA4B);
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
return RegisterClassEx(&wcex);
}
//
// FUNCTION: InitInstance(HINSTANCE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
//
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_about :
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT: {
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
Paint(&hdc);
EndPaint(hWnd, &ps);
break;}
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
// Message handler for about box.
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_INITDIALOG:
return (INT_PTR)TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
break;
}
return (INT_PTR)FALSE;
}
void Paint(HDC *hDC){ // Собственно функция вывода квадрата
RECT MyRect;
HBRUSH MyBrush = CreateSolidBrush(RGB(23,444,34));
MyRect.left = MyRect.top = 10;
MyRect.right = MyRect.bottom = 100;
FillRect(*hDC,&MyRect,MyBrush);
DeleteObject(MyBrush);
};
#include "Laba4b.h"
#include <WinGdi.h>
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
// Forward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
void Paint(HDC *hDC);
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_LABA4B, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_LABA4B));
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return (int) msg.wParam;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage are only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_LABA4B));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_LABA4B);
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
return RegisterClassEx(&wcex);
}
//
// FUNCTION: InitInstance(HINSTANCE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
//
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_about :
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT: {
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
Paint(&hdc);
EndPaint(hWnd, &ps);
break;}
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
// Message handler for about box.
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_INITDIALOG:
return (INT_PTR)TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
break;
}
return (INT_PTR)FALSE;
}
void Paint(HDC *hDC){ // Собственно функция вывода квадрата
RECT MyRect;
HBRUSH MyBrush = CreateSolidBrush(RGB(23,444,34));
MyRect.left = MyRect.top = 10;
MyRect.right = MyRect.bottom = 100;
FillRect(*hDC,&MyRect,MyBrush);
DeleteObject(MyBrush);
};
Спасибо за помощь , а что за Laba4b.h ты используешь???
Цитата: rezer
Спасибо за помощь , а что за Laba4b.h ты используешь???
Когда а MS Visual Studio создаешь проект то она автоматически создает header с названием проекта. В этом header'е подключается headerы с ресурсами. В принципе вместо него можно написать
Код:
#include "resource.h"
// ну или любой другой header с используемыми ресурсами.
// ну или любой другой header с используемыми ресурсами.
А то я подрубил "resource.h" появилась куча ошибок!
Кстати какую книгу посоветуете для изучения WinApi ,начинал читать румянцева , но что-то не вдохновила книга!
Код:
1>------ Rebuild All started: Project: winapi, Configuration: Debug Win32 ------
1>Deleting intermediate and output files for project 'winapi', configuration 'Debug|Win32'
1>Compiling...
1>1.cpp
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(30) : error C2065: 'IDS_APP_TITLE' : undeclared identifier
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(31) : error C2065: 'IDC_LABA4B' : undeclared identifier
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(40) : error C2065: 'IDC_LABA4B' : undeclared identifier
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(67) : error C2065: 'IDI_LABA4B' : undeclared identifier
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(70) : error C2065: 'IDC_LABA4B' : undeclared identifier
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(72) : error C2065: 'IDI_SMALL' : undeclared identifier
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(111) : error C2065: 'IDM_about' : undeclared identifier
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(111) : error C2051: case expression not constant
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(112) : error C2065: 'IDD_ABOUTBOX' : undeclared identifier
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(114) : error C2065: 'IDM_EXIT' : undeclared identifier
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(114) : error C2051: case expression not constant
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(119) : warning C4065: switch statement contains 'default' but no 'case' labels
1>Build log was saved at "file://c:\Documents and Settings\Стас\Мои документы\Visual Studio 2008\Projects\winapi\winapi\Debug\BuildLog.htm"
1>winapi - 11 error(s), 1 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
1>Deleting intermediate and output files for project 'winapi', configuration 'Debug|Win32'
1>Compiling...
1>1.cpp
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(30) : error C2065: 'IDS_APP_TITLE' : undeclared identifier
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(31) : error C2065: 'IDC_LABA4B' : undeclared identifier
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(40) : error C2065: 'IDC_LABA4B' : undeclared identifier
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(67) : error C2065: 'IDI_LABA4B' : undeclared identifier
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(70) : error C2065: 'IDC_LABA4B' : undeclared identifier
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(72) : error C2065: 'IDI_SMALL' : undeclared identifier
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(111) : error C2065: 'IDM_about' : undeclared identifier
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(111) : error C2051: case expression not constant
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(112) : error C2065: 'IDD_ABOUTBOX' : undeclared identifier
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(114) : error C2065: 'IDM_EXIT' : undeclared identifier
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(114) : error C2051: case expression not constant
1>c:\documents and settings\стас\мои документы\visual studio 2008\projects\winapi\winapi\1.cpp(119) : warning C4065: switch statement contains 'default' but no 'case' labels
1>Build log was saved at "file://c:\Documents and Settings\Стас\Мои документы\Visual Studio 2008\Projects\winapi\winapi\Debug\BuildLog.htm"
1>winapi - 11 error(s), 1 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Цитата: rezer
Кстати какую книгу посоветуете для изучения WinApi ,начинал читать румянцева , но что-то не вдохновила книга!
Есть "Проектирование интерфейса пользователя средствами WIN32 API" Ганеев Р М
Есть толстенный справочник "Microsoft Windows API" Саймона, по сути это выжимка из msdn, но на русском и ессно читать гораздо удобнее.