- •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;
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 TBBUTTON but[5];
static HWND hToolBar;
switch(msg)
{ case WM_CREATE:
but[0].fsStyle=TBSTYLE_SEP;
but[1].iBitmap=STD_FILENEW;
but[1].idCommand=ID_FILENEW;
but[1].fsState=TBSTATE_ENABLED;
but[1].fsStyle=TBSTYLE_GROUP;
but[2].fsStyle=TBSTYLE_SEP;
but[3].iBitmap=STD_FILEOPEN;
but[3].idCommand=ID_FILEOPEN;
but[3].fsState=TBSTATE_ENABLED;
but[3].fsStyle=TBSTYLE_GROUP;
but[4].iBitmap=STD_FILESAVE;
but[4].idCommand=ID_FILESAVE;
but[4].fsState=TBSTATE_ENABLED;
but[4].fsStyle=TBSTYLE_GROUP;
hToolBar=CreateToolbarEx(hWnd,WS_CHILD|WS_VISIBLE|WS_DLGFRAME,ID_TOOLBAR,0,HINST_COMMCTRL,IDB_STD_LARGE_COLOR,but,5,0,0,0,0,sizeof(TBBUTTON));
break;
case WM_SIZE:
MoveWindow(hToolBar,0,0,0,0,TRUE);
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_FILEOPEN:
MessageBox(hWnd,"Открыть файл","",MB_OK);
break;
case ID_FILESAVE:
MessageBox(hWnd,"Сохранить файл","",MB_OK);
break;
case ID_FILENEW:
MessageBox(hWnd,"Новый файл","",MB_OK);
break;
} break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;}
Пример 9
В текстовое поле вводим число, по нажатию на кнопку «добавить» сохраняем его, по нажатию на кнопку «распечатать» - выводим его в листбокс
LONG MyWinP(HWND, UINT,WPARAM,LPARAM);
char item[150];
struct list{
int info;
struct list *next;
};
class CList
{
struct list *head,*p;
public:
int kol;
CList()
{head=p=NULL;kol=0;}
/////////////////////////
void AddElem (float s)
{if (head==NULL)
{head= new struct list;
head->info=s;
head->next=NULL;
p=head;kol++;
} else
{ p->next=new struct list;
p->next->info=s;
p->next->next=NULL;
p=p->next;kol++;
}}
void PrintAllElem ()
{ struct list *tmp;
tmp=new struct list;
if (head==NULL)
{SendMessage(List1,LB_ADDSTRING,0,(LPARAM)"HET elementov");}
else{
tmp=head;
sprintf(item,"%d",tmp->info);
SendMessage(List1,LB_ADDSTRING,0,(LPARAM)item);
tmp=tmp->next;
while (tmp!=NULL)
{sprintf(item,"%d",tmp->info);
SendMessage(List1,LB_ADDSTRING,0,(LPARAM)item);
tmp=tmp->next;}
} }
////////////////////////////////////////////////
~CList()
{
struct list *p;
while (head!=NULL)
{
p=head;
head=head->next;
delete p;
} }
///////////////////////////////////
void PrintElem(int k)
{ int i;struct list *tmp;
if (k>kol) {
SendMessage(List1,LB_ADDSTRING,0,(LPARAM)"нет столько єлементов");}
tmp=new struct list;
if (head==NULL)
{SendMessage(List1,LB_ADDSTRING,0,(LPARAM)"нет элементов");}
else{ tmp=head;
for (i=1;i<=(kol-k);i++)
{ tmp=tmp->next;}
sprintf(item,"%d",tmp->info);
SendMessage(List1,LB_ADDSTRING,0,(LPARAM)item);
tmp=tmp->next;
while (tmp!=NULL)
{sprintf(item,"%d",tmp->info);
SendMessage(List1,LB_ADDSTRING,0,(LPARAM)item);
tmp=tmp->next;}
}} };
CList a;
///////////////////////////////////////////