Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2014
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. class MsgBox{
  5.  
  6. public:
  7.  
  8.  
  9. static void gotoxy(short x, short y){
  10. COORD pos = {x,y};
  11. SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
  12. }
  13.  
  14. static void showBox(int x1, int y1, int x2, int y2,string n){
  15.  
  16. int centerx, centery;
  17. centerx=x1+5;
  18. centery=y1+3;
  19.  
  20. for(int x=x1;x<=x2;x++){
  21. gotoxy(x,y1);
  22. cout<<(char)205;
  23. gotoxy(x,y2);
  24. cout<<(char)205;
  25. }
  26. for(int y=y1;y<=y2;y++){
  27. gotoxy(x1,y);
  28. cout<<(char)186;
  29. gotoxy(x2,y);
  30. cout<<(char)186;
  31. }
  32.  
  33. gotoxy(centerx,centery);
  34. cout<<n;
  35. }
  36.  
  37. static void showBox(int x1, int y1, int x2, int y2,string n,string a){
  38.  
  39. int centerx, centery;
  40. centerx=x1+5;
  41. centery=y1+3;
  42.  
  43. for(int x=x1;x<=x2;x++){
  44. gotoxy(x,y1);
  45. cout<<(char)205;
  46. gotoxy(x,y2);
  47. cout<<(char)205;
  48. }
  49. for(int y=y1;y<=y2;y++){
  50. gotoxy(x1,y);
  51. cout<<(char)186;
  52. gotoxy(x2,y);
  53. cout<<(char)186;
  54. }
  55.  
  56. gotoxy(x1,y1);
  57. cout<<a;
  58.  
  59. gotoxy(centerx,centery);
  60. cout<<n;
  61. }
  62.  
  63. };
  64.  
  65. #include <windows.h>
  66. #include <iostream>
  67. #include "MsgBox.h"
  68.  
  69. using namespace std;
  70.  
  71. void gotoxy(short x, short y){
  72. COORD pos = {x,y};
  73. SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
  74. }
  75.  
  76.  
  77. int main(){
  78. system("color 47");
  79.  
  80. MsgBox::showBox(10,5,70,20,"Hello");
  81. system("pause>nul");
  82. system("cls");
  83. MsgBox::showBox(10,5,70,20,"Hello","Info Box");
  84.  
  85. system("pause>nul");
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement