View Full Version: Message Box Maker 2

C++ Learning Community > C++ Creations > Message Box Maker 2


Title: Message Box Maker 2
Description: now its usefull


shortys team - October 4, 2003 04:50 PM (GMT)
Right click save as

it now exports the code into a textbox where you can copy and paste in and it has a scrollbar :blink:

TheHawgMaster - October 4, 2003 07:35 PM (GMT)
Nice.

Dragon - October 5, 2003 12:36 AM (GMT)
Error: Cannot find server.

shortys team - October 5, 2003 02:01 AM (GMT)
you have to right click save target as
or go to my site in my sig

Dragon - October 5, 2003 02:37 AM (GMT)
Nothing works. Your site is down or something.

shortys team - October 5, 2003 02:45 AM (GMT)
ah it is too
it was just workin but ittle probly be up tomorow

shortys team - October 6, 2003 09:13 PM (GMT)
ok its workin now
i think you have to d/l it from my site tho

that person - October 14, 2003 06:21 PM (GMT)
I've never made GUIs, so how do you use the code and put it in an exe?

MonkeyMan - October 14, 2003 08:41 PM (GMT)
I dont know how your message box looks but here is an example:
CODE
#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hParent,LPSTR CmdLine,int Show)
{
 MessageBox(NULL,"This is the first line of the message box.\nTHis is the second line of the message box.\nThis is the last line. Thanks","The Title",MB_OK);
 return 1;
}

shortys team - October 14, 2003 09:55 PM (GMT)
its not just a message box its a program that lest you pick your settings then gives you the code

Dragon - October 14, 2003 10:51 PM (GMT)
QUOTE
I've never made GUIs, so how do you use the code and put it in an exe?


Uhh, what are you talking about? You compile your source to create a file (DLL, executable, etc.). You don't "put" it in an exe.

MonkeyMan - October 14, 2003 11:18 PM (GMT)
QUOTE
its not just a message box its a program that lest you pick your settings then gives you the code

I know... Im just saying I dont know what he choose as the text and all of the settings so i made up my own.

7OD - October 24, 2003 04:22 AM (GMT)
Dunno why, but I've always liked doing the old

CODE
#include "stdafx.h"

int APIENTRY WinMain(HINSTANCE hInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR     lpCmdLine,
                    int       nCmdShow)
{
 for (int i=0; i>=0; i++)
{MessageBox(NULL, "Text", "Title", MB_ICONERROR | MB_OK);
}
return 0;
}
.

TheHawgMaster - October 24, 2003 05:26 AM (GMT)
QUOTE
return 1;
You're supposed to return 0 if you return before the message loop.

And 70D, I've made programs likethat (who hasn't), but wouldn't
CODE
for(;;)
be a little more efficient?

7OD - October 25, 2003 05:49 AM (GMT)
Of course, everyone has...

ZerO - December 8, 2003 05:40 PM (GMT)
Nice... Than you for sharing it with uss! Made it work, now I'll just find a usefull way to use it... ;)

shortys team - December 8, 2003 08:45 PM (GMT)
thanks :P
anyways heres the source
i know its not coded the best cause i did this a while ago
CODE

#include <windows.h>
#include<stdio.h>

#define IDI_MYICON1 201
#define EXIT1 1001
#define PLAY 1002
#define OPT1 1003
#define OPT2 1004
#define OPT3 1005
#define ID_EXIT 1006
#define IDC_MAIN_TEXT 1007

HWND output,box,play,exit1,edit,entermessage,entertitle,edit2,opterror,optinfo,optnone; //button names
char text1[100];
char text2[100];
int opt1 = 0;
int opt2 = 0;
int opt3 = 0;
char* wicon2= "NULL";
char wicon;

char Buffer[512];
int BufferLength;



const char g_szClassName[] = "myWindowClass";
         
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
  switch(msg)
  {
case WM_CREATE:
  {
//buttons
 
box = CreateWindowEx(0,TEXT("BUTTON"),TEXT("Icon"),                      
   WS_CHILD|WS_VISIBLE|BS_GROUPBOX,        
   5,80,150,120,hwnd,                                  
   NULL,                                
   GetModuleHandle(NULL),                            
   NULL);
 
entermessage =CreateWindow("STATIC","Message",
WS_CHILD|WS_VISIBLE,
5,50,100,20,
hwnd,NULL,GetModuleHandle(NULL),NULL);

entertitle =CreateWindow("STATIC","Title",
WS_CHILD|WS_VISIBLE,
5,5,100,20,
hwnd,NULL,GetModuleHandle(NULL),NULL);
 
   edit=CreateWindowEx(WS_EX_CLIENTEDGE,"EDIT","",
      ES_AUTOHSCROLL|WS_CHILD|WS_VISIBLE,
      105,50,80,20,
      hwnd,NULL,GetModuleHandle(NULL),NULL);

   output=CreateWindowEx(WS_EX_CLIENTEDGE,"EDIT","",
      ES_AUTOVSCROLL|ES_MULTILINE|WS_CHILD|WS_VISIBLE| WS_VSCROLL,
      205,5,120,190,
      hwnd,(HMENU)IDC_MAIN_TEXT,GetModuleHandle(NULL),NULL);

   edit2=CreateWindowEx(WS_EX_CLIENTEDGE,"EDIT","",
      ES_AUTOHSCROLL|WS_CHILD|WS_VISIBLE,
      105,5,80,20,
      hwnd,NULL,GetModuleHandle(NULL),NULL);
   
       play =CreateWindow("BUTTON","Generate",
       WS_CHILD|WS_VISIBLE,
       265,220,70,20,
       hwnd,(HMENU)PLAY ,GetModuleHandle(NULL),NULL);
   
   
       exit1 =CreateWindow("BUTTON","Exit",
       WS_CHILD|WS_VISIBLE,
       5,220,60,20,
       hwnd,(HMENU)EXIT1 ,GetModuleHandle(NULL),NULL);

 opterror=  CreateWindowEx(0,TEXT("BUTTON"),TEXT("Icon Info"),                  
 WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON,
 10,160,130,30,                                    
 hwnd,(HMENU)OPT1,GetModuleHandle(NULL),NULL);

 optinfo=  CreateWindowEx(0,TEXT("BUTTON"),TEXT("Icon Error"),                  
 WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON,
 10,130,100,30,                                    
 hwnd,(HMENU)OPT2,GetModuleHandle(NULL),NULL);

 optnone=  CreateWindowEx(0,TEXT("BUTTON"),TEXT("No Icon"),                  
 WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON,
 10,100,100,30,                                    
 hwnd,(HMENU)OPT3,GetModuleHandle(NULL),NULL);
 SendMessage(GetDlgItem(hwnd,IDC_MAIN_TEXT),WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(FALSE,0));
  }
   break;
case WM_COMMAND:
      {
          switch (LOWORD(wParam))
          {
            case EXIT1:
             DestroyWindow(hwnd);

           
    break;

   case PLAY:
    MessageBox(hwnd, text1, text2,
    wicon|MB_OK);  
    BufferLength =sprintf(&Buffer[0], "MessageBox(NULL, \"%s\", \"%s\", %s | MB_OK);", text1, text2, wicon2);
    SetWindowText(output, Buffer);

    break;
   case OPT1:
    if (opt1 == 0) {opt1 = 1;wicon = MB_ICONINFORMATION;wicon2 = "MB_ICONINFORMATION";}
    if (opt1 == 1) opt1 = 0;
    break;
   case OPT2:
    if (opt2 == 0) {opt2 = 1;wicon = MB_ICONERROR;wicon2 = "MB_ICONERROR";}
    if (opt2 == 1) opt2 = 0;
    break;
   case OPT3:
    if (opt3 == 0) {opt3 = 1; wicon = NULL;wicon2 = "NULL";}
    if (opt3 == 1) opt3 = 0;
    break;



    }    
   }
     break;


case WM_CLOSE:
          DestroyWindow(hwnd);
      break;
      case WM_DESTROY:
          PostQuitMessage(0);
      break;
   default:
          return DefWindowProc(hwnd, msg, wParam, lParam);
  }
  return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  LPSTR lpCmdLine, int nCmdShow)
{
  WNDCLASSEX wc;
  HWND hwnd;
  MSG Msg;
  wc.cbSize        = sizeof(WNDCLASSEX);
  wc.style         = 0;
  wc.lpfnWndProc   = WndProc;
  wc.cbClsExtra    = 0;
  wc.cbWndExtra    = 0;
  wc.hInstance     = hInstance;
  wc.hIcon  = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON1));
  wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
  wc.hbrBackground =(HBRUSH)(COLOR_BTNFACE+1);
  wc.lpszMenuName  = NULL;
  wc.lpszClassName = g_szClassName;
  wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);

  if(!RegisterClassEx(&wc))
  {
      MessageBox(NULL, "Window Registration Failed!", "Error!",
          MB_ICONERROR | MB_OK);
      return 0;
  }
 
  hwnd = CreateWindowEx(
      WS_EX_CLIENTEDGE,
      g_szClassName,
      "C++ Message Box Maker - Shorty's Team",
      WS_OVERLAPPEDWINDOW,
      CW_USEDEFAULT, CW_USEDEFAULT, 350, 280,
      NULL, NULL, hInstance, NULL);

  if(hwnd == NULL)
  {
      MessageBox(NULL, "Window Creation Failed!", "Error!",
          MB_ICONERROR | MB_OK);
      return 0;
  }

  ShowWindow(hwnd, nCmdShow);
  UpdateWindow(hwnd);


  while(GetMessage(&Msg, NULL, 0, 0) > 0)
  {
      TranslateMessage(&Msg);
      DispatchMessage(&Msg);
GetWindowText(edit,text1,100); //checks for changes
GetWindowText(edit2,text2,100); //checks for changes
  }
  return Msg.wParam;
}




* Hosted for free by InvisionFree