Здравствуйте, помогите пожалуйста. Моя программа создает диалоговое окно но оно создается с прозрачным фоном и почему-то при нажатии на кнопку новый объект ничего не происходит. Код:
Код:
#include <windows.h>
#include <stdio.h>
#include "resource.h"
UINT cur=1;
int x0,y0,rad0,r0,g0,b0;
HINSTANCE hi0;
class Oval
{
private: int xc,yc,rad,R,G,B;
public:
static int n;
Oval(){ xc=0; yc=0;rad=0;R=0;G=0;B=0;}
void set(int x, int y, int ra, int re, int gr, int bl)
{
xc=x; yc=y; rad=ra; R=re; G=gr; B=bl;
}
double perimetr()
{
return 3.14*2*rad;
}
double ploshchad()
{
return 3.14*rad*rad;
}
void set_colour(int nR,int nG,int nB)
{
R=nR; G=nG; B=nB;
}
void Init(int nxc,int nyc, int nrad, int nR,int nG,int nB)
{
xc=nxc; yc=nyc; rad=nrad; R=nR; G=nG; B=nB;
}
void display(HDC hdc, int cur)
{
HBRUSH b1,b0;
b1=CreateSolidBrush(RGB(R,G,B)); // кисти
b0=(HBRUSH)SelectObject(hdc,b1); // текущая кисть
Ellipse(hdc,xc,yc,xc+2*rad,yc+2*rad);
wchar_t buf[20];
swprintf(buf,L"%d",cur);
TextOut(hdc,xc,yc,buf,wcslen(buf));
SelectObject(hdc,b0);
DeleteObject(b1);
}
};
int Oval::n=0;
Oval mas[20];
int WINAPI ab(HWND hwnd,int cmd,WPARAM wp,LPARAM lp)
{
switch(cmd)
{
case WM_INITDIALOG:
{
SetDlgItemInt(hwnd,CHISLO,cur,true);
SetDlgItemInt(hwnd,X,100,true);
SetDlgItemInt(hwnd,Y,200,true);
SetDlgItemInt(hwnd,Radius,20,true);
SetDlgItemInt(hwnd,NRed,255,true);
SetDlgItemInt(hwnd,NGreen,255,true);
SetDlgItemInt(hwnd,NBlue,255,true);
}
case WM_CLOSE:
{
x0=GetDlgItemInt(hwnd,X,NULL,true);
y0=GetDlgItemInt(hwnd,Y,NULL,true);
rad0=GetDlgItemInt(hwnd,Radius,NULL,true);
r0=GetDlgItemInt(hwnd,NRed,NULL,true);
g0=GetDlgItemInt(hwnd,NGreen,NULL,true);
b0=GetDlgItemInt(hwnd,NBlue,NULL,true);
EndDialog(hwnd,3);
return 1;
}
case WM_COMMAND:
if(LOWORD(wp)==IDOK)
{
SendMessage(hwnd,WM_CLOSE,0,0);
return 1;
}
return 0;
}
return 0;
};
int WINAPI fn(HWND hwnd,int cmd,WPARAM wp,LPARAM lp)
{
switch(cmd)
{
case WM_INITDIALOG:
{
SetDlgItemInt(hwnd,Nomer,1,true);
SetDlgItemInt(hwnd,Red,0,true);
SetDlgItemInt(hwnd,Green,0,true);
SetDlgItemInt(hwnd,Blue,0,true);
return 1;
}
case WM_COMMAND:
{
switch (LOWORD(wp))
{
case New_item:
{
cur=GetDlgItemInt(hwnd,Nomer,NULL,true);
int r=DialogBox(hi0,MAKEINTRESOURCE(DIALOG2),NULL,(DLGPROC)ab);
mas[cur].set(x0,y0,rad0,r0,g0,b0);
}
case Set_color:
{
int nr=GetDlgItemInt(hwnd,Red,NULL,true);
int ng=GetDlgItemInt(hwnd,Green,NULL,true);
int nb=GetDlgItemInt(hwnd,Blue,NULL,true);
mas[cur].set_colour(nr,ng,nb);
}
}
return 1;
}
case WM_CLOSE:
{
EndDialog(hwnd,1);
return 0;
}
case WM_SIZE:
{
InvalidateRect(hwnd,NULL,RDW_ERASE);
return 1;
}
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc=BeginPaint(hwnd, &ps);
RECT rt;
GetClientRect(hwnd, &rt);
for(int i=0;i<Oval::n;i++)
mas[i].display(hdc, i);
EndPaint(hwnd, &ps);
return 1;
}
}
return 1;
}
int WINAPI WinMain(HINSTANCE hi,HINSTANCE,LPSTR,int)
{
hi0=hi;
return DialogBox(hi,MAKEINTRESOURCE(DIALOG),NULL,(DLGPROC)fn);
}