- •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(hInstance, LPCTSTR(IDI_ICON2));
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);
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 List1, Button1, Combo1;
static int en;
char item[150];
int nItem;
switch(msg)
{
case WM_COMMAND:
switch (LOWORD(wParam))
{
case ID_LIST:
if (HIWORD(wParam)==LBN_DBLCLK)
{
nItem=SendMessage(List1,LB_GETCURSEL,0,(LPARAM)item);
if (nItem!=LB_ERR)
{
SendMessage(List1,LB_GETTEXT,nItem,(LPARAM)item);
SetWindowText(hWnd,item);
}
}
break;
case ID_BUTTON:
EnableWindow(List1, ++en%2);
sprintf(item,"%d record",en);
if (SendMessage(List1,LB_FINDSTRINGEXACT,0,(LPARAM)item)==LB_ERR)
SendMessage(List1,LB_ADDSTRING,0,(LPARAM)item);
break;
case ID_COMBO:
if (HIWORD(wParam)==CBN_EDITCHANGE)
{
GetWindowText(Combo1,item,sizeof(item));
SetWindowText(hWnd,item);
}
if (HIWORD(wParam)==CBN_KILLFOCUS)
{
GetWindowText(Combo1,item,sizeof(item));
if (SendMessage(Combo1,CB_FINDSTRINGEXACT,0,(LPARAM)item)==CB_ERR)
{
SendMessage(Combo1,CB_ADDSTRING,0,(LPARAM)item);
SetWindowText(Combo1,"");
}
}
break;
}
break;
case WM_CREATE:
Button1=CreateWindow("button","Добавить", WS_CHILD|WS_VISIBLE,10,270,100,30,hWnd,(HMENU)ID_BUTTON,NULL,NULL);
List1=CreateWindow("listbox",NULL,WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_HSCROLL|LBS_STANDARD|LBS_NOINTEGRALHEIGHT, 10,40,100,220,hWnd,(HMENU)ID_LIST,NULL,NULL);
SendMessage(List1,LB_SETHORIZONTALEXTENT,200,0);
SendMessage(List1,LB_ADDSTRING,0,(LPARAM)"1 record");
SendMessage(List1,LB_ADDSTRING,0,(LPARAM)"5 record");
SendMessage(List1,LB_ADDSTRING,0,(LPARAM)"3 record");
SendMessage(List1,LB_SETCURSEL,1,0);
en=1;
Combo1=CreateWindow("combobox",NULL,WS_CHILD|WS_VISIBLE|WS_TABSTOP|CBS_AUTOHSCROLL|CBS_DROPDOWN|CBS_SORT, 10,320,100,200,hWnd,(HMENU)ID_COMBO,NULL,NULL);
SendMessage(Combo1,CB_SETEXTENDEDUI,1,0);
SendMessage(Combo1,CB_ADDSTRING,0,(LPARAM)"1 record");
SendMessage(Combo1,CB_ADDSTRING,0,(LPARAM)"5 record");
SendMessage(Combo1,CB_ADDSTRING,0,(LPARAM)"3 record");
SendMessage(Combo1,CB_SETCURSEL,1,0);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}
Пример 5
Создание скролбара
#include <windows.h>
#include <stdio.h>
#include <string.h>
#define ID_SCROLL 1001
LONG MyWinP(HWND, UINT,WPARAM,LPARAM);