- •Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
- •If(!RegisterClass(&w)) return false;
- •If (!hWnd) return false;
- •InvalidateRect(hWnd,&rt,true);
- •InvalidateRect(hWnd,&rt,true);
- •InvalidateRect(hWnd,&rt,true);
- •InvalidateRect(hWnd,&rt,true);
- •Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
- •If(!RegisterClass(&w)) return false;
- •If (!hWnd) return false;
- •If (!hWnd) return false;
- •If(!RegisterClass(&w)) return false;
- •If(!RegisterClass(&w)) return false;
- •If(!RegisterClass(&w)) return false;
- •InvalidateRect(hWnd,&rt,true);
- •If(!RegisterClass(&w)) return false;
- •Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
- •If(!RegisterClass(&w)) return false;
- •If (!hWnd) return false;
- •InvalidateRect(hWnd,&rt,true);
- •InvalidateRect(hWnd,&rt,true);
- •InvalidateRect(hWnd,&rt,true);
- •InvalidateRect(hWnd,&rt,true);
- •Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
- •If(!RegisterClass(&w)) return false;
- •If (!hWnd) return false;
- •InvalidateRect(hWnd,&rt,true);
- •Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
- •If(!RegisterClass(&w)) return false;
- •If (!hWnd) return false;
- •Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
- •If(!RegisterClass(&w)) return false;
- •If (!hWnd) return false;
- •Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
- •If(!RegisterClass(&w)) return false;
- •If (!hWnd) return false;
- •Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
- •If(!RegisterClass(&w)) return false;
- •If (!hWnd) return false;
- •Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
- •If(!RegisterClass(&w)) return false;
- •If (!hWnd) return false;
- •Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
- •If(!RegisterClass(&w)) return false;
- •If (!hWnd) return false;
- •Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
- •If(!RegisterClass(&w)) return false;
- •If (!hWnd) return false;
- •If(!RegisterClass(&w)) return false;
If (!hWnd) return false;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return int(msg.wParam);
}
BOOL MyRegisterClass…
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
wchar_t szHello[MAX_LOADSTRING];
switch (message)
{
case WM_NCCREATE:
{
dllInstance = ::LoadLibrary ( L"dll.dll" );
if ( dllInstance == NULL )
{
::MessageBox ( 0, L"В процессе загрузки динамической библиотеки произошла ошибка.", L"Ошибка", MB_OK );
return 0;
}
DrawFunc = ( _DrawFunc ) ::GetProcAddress ( dllInstance, "Draw" );
if ( DrawFunc == NULL )
{
::MessageBox ( 0, L"В процессе загрузки динамической библиотеки произошла ошибка.", L"Ошибка", MB_OK );
return 0;
}
return 1;
}
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
DrawFunc ( hWnd, hdc, 0.1, 10 );
::EndPaint ( hWnd, &ps );
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
***** void Draw ( HWND hWnd, HDC hdc, double xMin, double xMax )
{
Xmin = xMin;
Xmax = xMax;
FillArray();
#include <windows.h>
#include <stdio.h>
#define ID_EDIT 1001
#define ID_BUTTON 1002
LONG WinProc(HWND, UINT, WPARAM, LPARAM);
HINSTANCE hInstance;
char szTitle[]="Однострочный редактор";
int zna=1;
// WINMAIN
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR pCmdLine,
int nCmdShow){
char ProgName[]="Labrab";
HWND hWnd;
MSG msg;
//РЕГИСТРАЦИЯ ОКОННОГО КЛАССА
WNDCLASS w;
w.lpszClassName=ProgName;
w.hInstance=hInstance;
w.lpfnWndProc=(WNDPROC)WinProc;
w.hCursor=LoadCursor(NULL, IDC_ARROW);
w.hIcon=LoadIcon(NULL, IDI_APPLICATION);
w.lpszMenuName=NULL;
w.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);
w.style=CS_HREDRAW | CS_VREDRAW;
w.cbClsExtra=0;
w.cbWndExtra=0;
If(!RegisterClass(&w)) return false;
//
hWnd=CreateWindow(
ProgName, //имя класса
szTitle, //имя окна (заголовок)
WS_OVERLAPPEDWINDOW, //стиль окна
100, //x-координата окна
100, //y-координата окна
GetSystemMetrics(SM_CXSCREEN)/2, //ширина окна
GetSystemMetrics(SM_CYSCREEN)/2, //высота окна
NULL, // дескриптор родительского или окна владельца
NULL, // дескриптор меню или идентификатор дочернего окна
hInstance, // дескриптор экземпляра приложения
NULL // указатель на данные создания окна
);
//CreateWindow("STATIC","Подготовка ко второму модулю",WS_CHILD|WS_VISIBLE|SS_LEFT,10,1,220,20,hWnd,NULL,hInstance,NULL);
ShowWindow(hWnd, nCmdShow);
while(GetMessage(&msg, NULL, 0, 0)) //цикл обработки сообщений
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
//
//ОКОННАЯ ПРОЦЕДУРА
LONG WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){
//POINT LeftCorner;
RECT rect;
//int x,y,x1,y1;
//POINT pt;
//чтобы преобразовать чар в бу НАДО СПРИНТФ
static HWND hEdit, hButton, hStatic;
char chBuff[80]=" ";
switch(msg){
case WM_CREATE:
{
hStatic=CreateWindow("static","Введите строку и нажмите кнопку ОК",WS_CHILD|WS_VISIBLE|SS_CENTER,30,10,300,20,hWnd,(HMENU)0,hInstance,NULL);
hEdit=CreateWindow("edit",NULL,WS_CHILD|WS_VISIBLE|WS_BORDER|ES_LEFT,30,40,300,30,hWnd,(HMENU)ID_EDIT,hInstance,NULL);
hButton=CreateWindow("button","OK",WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,130,85,100,30,hWnd,(HMENU)ID_BUTTON,hInstance,NULL);
SetFocus(hEdit);
return 0;
}
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case ID_EDIT:
{
if((HIWORD(wParam))==EN_ERRSPACE)
{
MessageBox(hWnd,"Мало памяти",szTitle,MB_OK);
}
return 0;
}
case ID_BUTTON:
{
SendMessage(hEdit,EM_GETLINE,0,(LPARAM)chBuff);
//MessageBox(hWnd,chBuff,"Нежданчик",MB_OK);
SetWindowText(hEdit,"\0");
SetFocus(hEdit);
sscanf(chBuff,"%d", &zna);
//GetClientRect(hWnd, &rect);
InvalidateRect(hWnd,NULL,TRUE);
//sprintf(chBuff,"%d", &zna);
//MessageBox(hWnd,chBuff,"Нежданчик",MB_OK);
return 0;
}
}
return 0;
}
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd,&ps);
MoveToEx(hdc,30,150,NULL),
LineTo(hdc,2*zna+130,150);
//sprintf(chBuff,"%d", zna);
//MessageBox(hWnd,chBuff,"Нежданчик",MB_OK);
UpdateWindow(hWnd);
//ValidateRect(hWnd,NULL);
EndPaint(hWnd,&ps);
return 0;
}
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_LBUTTONDOWN:
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
break;
}
return 0;
}
ЧЕК БАТТОН В СТАТУС БАР =)
#include <windows.h>
#include <stdio.h>
#include <commctrl.h>
#pragma comment(lib,"comctl32.lib")
#define ID_BUTTON1 1001
#define ID_CHECK1 1001
#define ID_CHECK2 1002
#define ID_CHECK3 1003
#define ID_CHECK4 1004
#define ID_CHECK5 1005
#define ID_STATBAR 2001
HINSTANCE hInst;
LONG WinProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd)
{char ProgName[]="My Window";
char Title[]="Window";
HWND hWnd;
MSG msg;
WNDCLASS w;
w.lpszClassName=ProgName;
w.hInstance=hInstance;
w.lpfnWndProc=(WNDPROC)WinProc;
w.hCursor=LoadCursor(NULL,IDC_ARROW);
w.hIcon=LoadIcon(NULL,IDI_APPLICATION);
w.lpszMenuName=NULL;
w.hbrBackground=(HBRUSH)(COLOR_WINDOW+7);
w.style=CS_HREDRAW|CS_VREDRAW;
w.cbClsExtra=0;
w.cbWndExtra=0;
hInst=hInstance;