Logo 
Search:

C++ Programming Articles

Submit Article
Home » Articles » C++ Programming » Computer GraphicsRSS Feeds

Program of moving message box like windows

Posted By: Easy Tutor     Category: C++ Programming     Views: 4123

This program creates a message or error box ,this box can move around like windows message box does. Click on top blue strip of message box and move around.In order to give it same look as windows getimage() & putimage() can be used,in this code i am just displaying a bar to erase old window on screen.

Code for Program of moving message box like windows in C++ Programming

#include <conio.h>
#include"win_mous.cpp"// Must include for Win & mouse functions#define DRAW 2
#define PUSH 1
#define UNPUSH 0
//--------------------------------------------------------------------------int mx,my,button;
void wmouse();
int check_pos(int cx,int cy,int cx1,int cy1);
void DrawMbox(int xx,int yy,char *e);
int Ebox(char *e);
//--------------------------------------------------------------------------void main()
{
 int ox,oy;
 G();
 setfillstyle(1,3);
 bar(0,0,640,480);
 showmouse();
 Ebox("Move me around !");
 getch();
 closegraph();
}
//--------------------------------------------------------------------------void wmouse() // stops continue looping
{
 int ox,oy;
 ox=mx;oy=my;
 while(ox==mx && oy==my && button==1)
 getmouse(&button,&mx,&my);
}
//--------------------------------------------------------------------------int check_pos(int cx,int cy,int cx1,int cy1)
{
 int flag;
 flag=0;
 if(mx>=cx && mx<=cx1 && my>=cy && my<=cy1) flag=1;
 return flag;
}
//--------------------------------------------------------------------------void DrawMbox(int xx,int yy,char *e)
{
 int t;
 Win("Message Box",xx+1,yy+1,xx+272,yy+119,1);
// setcolor(0);// rectangle(xx,yy,xx+273,yy+120);
 setfillstyle(1,0);
 fillellipse(xx+36,yy+58,15,15);
 setfillstyle(1,12);
 fillellipse(xx+33,yy+55,15,15);
 setcolor(15);
 for(t=0;t<=3;t++)
 {
 line(xx+26,yy+47+t,xx+42,yy+59+t);
 line(xx+42,yy+47+t,xx+26,yy+59+t);
 }
 Button("Ok",xx+110,yy+90,xx+160,yy+110,DRAW);
 setcolor(0);
 settextstyle(0,0,0);
 outtextxy(xx+68,yy+55,e);
}
//--------------------------------------------------------------------------int Ebox(char *e)
{
 int tx,ty,a,b;
// text="Message Box or Error Box";
 hidemouse();
 tx=177;ty=70;
 DrawMbox(tx,ty,e);
 showmouse();
 while(1)
 {
  if(kbhit()) break;
  showmouse();
  getmouse(&button,&mx,&my);
  if((button & 1)==1)
  {
   if(check_pos(tx+110,ty+90,tx+160,ty+110))//ok
   {
     Button("",tx+110,ty+90,tx+160,ty+110,PUSH);
     while((button & 1)==1)
     getmouse(&button,&mx,&my);
     Button("",tx+110,ty+90,tx+160,ty+110,UNPUSH);
     hidemouse();
     setfillstyle(1,3);// clear win
     bar(0,0,640,480);
     setcolor(1);
     outtextxy(260,200,"Press any key");
     showmouse();
     return(1);
   }
   if(check_pos(tx+4,ty,tx+252,ty+20))// click on top blue strip
   {
    a=mx-tx;
    b=my-ty;
    setcolor(15);
    setlinestyle(1,1,1);
    setwritemode(XOR_PUT);
    getmouse(&button,&mx,&my);
    while((button & 1)==1)
    {
    getmouse(&button,&mx,&my);
    tx=mx-a;
    ty=my-b;
    hidemouse();
    rectangle(tx+1,ty+1,tx+272,ty+119);
    showmouse();
    wmouse();
    hidemouse();
    rectangle(tx+1,ty+1,tx+272,ty+119);
    showmouse();
    }
    setlinestyle(0,0,0);
    setwritemode(COPY_PUT);
    hidemouse();
    setfillstyle(1,3);
    bar(0,0,640,480);
    DrawMbox(tx,ty,e);
    showmouse();
   }
  }
  while((button & 1)==1)
  getmouse(&button,&mx,&my);
 }
 showmouse();
 return 1;
}
  
Share: 


Didn't find what you were looking for? Find more on Program of moving message box like windows Or get search suggestion and latest updates.

Easy Tutor
Easy Tutor author of Program of moving message box like windows is from United States. Easy Tutor says

Hello Friends,

I am Free Lance Tutor, who helped student in completing their homework.

I have 4 Years of hands on experience on helping student in completing their homework. I also guide them in doing their final year projects.

I have share many programs on this website for everyone to use freely, if you need further assistance, than please contact me on easytutor.2ya [at the rate] gmail [dot] com

I have special discount scheme for providing tutor services. I am providing tutor service to students from various contries, currently most of my students are from United States, India, Australia, Pakistan, Germany, UK and Canada.

I am also here to expand my technical network to receive more opportunity in my career, make friends to help them in resolving their technical problem, learn and share my knowledge, If you like to be my friend, Please send me friend request.

Thanks,
Happy Programming :)

 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!