
- •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;
Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
{
char ProgName[]="My Window";
char Title[]="Заголовок окна";
HWND hWnd; MSG msg;
WNDCLASS w;
w.lpszClassName=ProgName;
w.hInstance=hInstance;
w.lpfnWndProc=(WNDPROC)MyWinP;
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,Title, WS_OVERLAPPEDWINDOW,0,0,
CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
If (!hWnd) return false;
ShowWindow(hWnd, nCmdShow);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LONG MyWinP(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static HWND Scroll1;
static int nPage, nCurPos, nPosMin, nPosMax;
char pos[5];
switch(msg)
{
case WM_CREATE:
Scroll1=CreateWindow("scrollbar",NULL, SBS_HORZ|SBS_BOTTOMALIGN|WS_CHILD|WS_VISIBLE,10,10,160,16,hWnd,(HMENU)0,NULL,NULL);
nPage=10;
nPosMin=1;
nPosMax=150;
nCurPos=30;
SetScrollRange(Scroll1, SB_CTL, nPosMin, nPosMax, TRUE);
SetScrollPos(Scroll1, SB_CTL, nCurPos, TRUE);
sprintf(pos,"%d",nCurPos);
SetWindowText(hWnd, pos);
break;
case WM_HSCROLL:
switch (LOWORD(wParam))
{
case SB_LEFT:
nCurPos=nPosMin;
break;
case SB_LINELEFT:
nCurPos--;
break;
case SB_PAGELEFT:
nCurPos-=nPage;
break;
case SB_RIGHT:
nCurPos=nPosMax;
break;
case SB_LINERIGHT:
nCurPos++;
break;
case SB_PAGERIGHT:
nCurPos+=nPage;
break;
case SB_THUMBPOSITION:
case SB_THUMBTRACK:
nCurPos=HIWORD(wParam);
break;
}
if (nCurPos>=nPosMax)
{
nCurPos=nPosMax;
EnableScrollBar(Scroll1, SB_CTL, ESB_DISABLE_RIGHT);
}
if (nCurPos<=nPosMin)
{
nCurPos=nPosMin;
EnableScrollBar(Scroll1, SB_CTL, ESB_DISABLE_LEFT);
}
SetScrollPos(Scroll1, SB_CTL, nCurPos, TRUE);
sprintf(pos,"%d",nCurPos);
SetWindowText(hWnd, pos);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}
Пример 8
Создание тулбара
#include <windows.h>
#include <commctrl.h>
#define ID_TOOLBAR 100
#define ID_FILEOPEN 40001
#define ID_FILESAVE 40002
#define ID_FILENEW 40003
LONG MyWinP(HWND, UINT,WPARAM,LPARAM);
Int winapi WinMain(hinstance hInstance, hinstance hPrevInstance, lpstr lpCmdLine, int nCmdShow)
{
char ProgName[]="My Window";
char Title[]="Заголовок окна";
HWND hWnd; MSG msg;
WNDCLASS w;
w.lpszClassName=ProgName;
w.hInstance=hInstance;
w.lpfnWndProc=(WNDPROC)MyWinP;
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,Title, WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,0,0,
CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);