|
#include<afxwin.h>
class myframe :public CFrameWnd
{
private:
CButton b[2];
CFont myfont1,myfont2;
public:
myframe()
{
CString mywindowclass;
mywindowclass= AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW,0,(HBRUSH)::GetStockObject(LTGRAY_BRUSH),0);
Create("mywindowclass","Push Buttons");
}
int OnCreate(LPCREATESTRUCT l)
{
CFrameWnd::OnCreate(l);
b[0].Create("OK",BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE,CRect(250,100,310,150),this,1);
myfont1.CreateFont(30,5,0,0,0,0,1,0,0,0,0,0,0,"Times New Roman");
b[0].SetFont(&myfont1,TRUE);
b[1].Create("OK",BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE,CRect(250,100,310,150),this,1);
myfont2.CreateFont(30,5,0,0,0,0,1,0,0,0,0,0,0,"Times New Roman");
b[1].SetFont(&myfont2,TRUE);
b[0].SetFocus();
return 0;
}
void OK()
{
MessageBox("U HAVE CLICKED OK","OK");
b[1].SetFocus();
}
void Cancel()
{
MessageBox("U HAVE CLICKED CANCEL","CANCEL");
b[0].SetFocus();
}
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP(myframe,CFrameWnd)
ON_WM_CREATE()
ON_COMMAND(1,OK)
ON_COMMAND(2,Cancel)
END_MESSAGE_MAP()
class myapp :public CWinApp
{
public:
int InitInstance()
{
myframe *p;
p = new myframe;
p -> ShowWindow(3);//
m_pMainWnd= p;
return 1;
}
};
myapp a;
Warning: Window creation failed: GetLastError returns 0x0000057F
Warning: failed to create CFrameWnd.
|
|
|
|