Monday, April 1, 2013

visual c++(mfc) program to display dialog box

visual c++(mfc) program to  display dialog box

#include<afxwin.h>
#include<afxdlgs.h>
#include"resource.h"
class myframe:public CFrameWnd
{
public:
      myframe()
      {
        Create(0,"my mfc",WS_OVERLAPPEDWINDOW|WS_MINIMIZEBOX|WS_VSCROLL|WS_HSCROLL,rectDefault,0,MAKEINTRESOURCE(IDR_MENU1),0,0);
      }
      CFontDialog fd;
      CFont f;
      void font()
      {
          int a,b;
          CString s;
          BOOL i,u,bd,s1;
          COLORREF c1;
          CClientDC dc(this);
          if(fd.DoModal()==IDOK)
          {
              s=fd.GetFaceName();
              a=fd.GetSize();
              b=fd.GetWeight();
              i=fd.IsItalic();
              u=fd.IsUnderline();
              bd=fd.IsBold();
              s1=fd.IsStrikeOut();
              c1=fd.GetColor();
              f.CreateFont(a,0,0,0,b,i,u,s1,0,0,0,0,0,s);
              dc.SelectObject(&f);
              dc.SetTextColor(c1);
              dc.TextOut(10,20,"HAVE A NICE DAY");
          }
      }
   
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP(myframe,CFrameWnd)
ON_COMMAND(ID_MENU_FONT,font)
END_MESSAGE_MAP()
class myapp:public CWinApp
{
public:
         virtual BOOL InitInstance()
         {
            m_pMainWnd=new myframe();
            m_pMainWnd->ShowWindow(1);
            m_pMainWnd->UpdateWindow();
            return TRUE;
         }
};
myapp app;


definition
A program is a list of detailed instructions.
A program is simply a list of instructions that tells the computer what to do. Computers are only dumb machines. They cannot think; they can only execute your orders within the programs that you write. Without programs, computers are worthless.

A program is to a computer what a recipe is to a cook. A recipe is nothing more than a program (a list of instructions) that tells the cook exactly what to do. The recipe's end result is a finished dish, and the end result of a computer program is an application such as a word processor or a payroll program. By itself, your computer does not know how to be a word processor. By following a list of detailed programming instructions written by a programmer, however, the computer performs the actions necessary to do word processing.

If you want your computer to help you with your household budget, keep track of names and addresses, or play a game of solitaire, you have to supply a program so that it knows how to do those things. You can either buy the program or write one yourself.

There are several advantages to writing your own programs. When you write your own programs, they do exactly what you want them to (you hope!). Although it would be foolish to try to write every program that you need to use (there is not enough time, and there are many good programs on the market), some applications are so specific that you simply cannot find a program that does exactly what you want..

No comments:

Post a Comment