Like Tree1Likes
  • 1 Post By kmdv

Mesagebox>>EDIT aka TextBox. PLZ HELP!!!

This is a discussion on Mesagebox>>EDIT aka TextBox. PLZ HELP!!! within the C++ Programming forums, part of the General Programming Boards category; i dont know how to make the button to messagebox what i type on edit. please help!! i try "hwnd, ...

  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    6

    Mesagebox>>EDIT aka TextBox. PLZ HELP!!!

    i dont know how to make the button to messagebox what i type on edit. please help!! i try "hwnd, "title",2,NULL..." but not working!!!! here is my code...
    Code:
    #include <windows.h>
    #include <winnt.h>
    #include <tlhelp32.h> 
    /*  Declare Windows procedure  */
    LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
    
    /*  Make the class name into a global variable  */
    char szClassName[ ] = "WindowsApp";
    
    int WINAPI WinMain (HINSTANCE hThisInstance,
                        HINSTANCE hPrevInstance,
                        LPSTR lpszArgument,
                        int nFunsterStil)
    
    {
        HWND hwnd;               /* This is the handle for our window */
        MSG messages;            /* Here messages to the application are saved */
        WNDCLASSEX wincl;        /* Data structure for the windowclass */
    
        /* The Window structure */
        wincl.hInstance = hThisInstance;
        wincl.lpszClassName = szClassName;
        wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
        wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
        wincl.cbSize = sizeof (WNDCLASSEX);
    
        /* Use default icon and mouse-pointer */
        wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
        wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
        wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
        wincl.lpszMenuName = NULL;                 /* No menu */
        wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
        wincl.cbWndExtra = 0;                      /* structure or the window instance */
        /* Use Windows's default color as the background of the window */
        wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
    
        /* Register the window class, and if it fails quit the program */
        if (!RegisterClassEx (&wincl))
            return 0;
    
        /* The class is registered, let's create the program*/
        hwnd = CreateWindowEx (
               0,                   /* Extended possibilites for variation */
               szClassName,         /* Classname */
               "+",           /* Title Text */
               WS_SYSMENU,          /* default window */
               CW_USEDEFAULT,       /* Windows decides the position */
               CW_USEDEFAULT,       /* where the window ends up on the screen */
               150,                 /* The programs width */
               140,                 /* and height in pixels */
               HWND_DESKTOP,        /* The window is a child-window to desktop */
               NULL,                /* No menu */
               hThisInstance,       /* Program Instance handler */
               NULL                 /* No Window Creation data */
               );
    
        /* Make the window visible on the screen */
        ShowWindow (hwnd, nFunsterStil);
    
        /* Run the message loop. It will run until GetMessage() returns 0 */
        while (GetMessage (&messages, NULL, 0, 0))
        {
            /* Translate virtual-key messages into character messages */
            TranslateMessage(&messages);
            /* Send message to WindowProcedure */
            DispatchMessage(&messages);
        }
    
        /* The program return-value is 0 - The value that PostQuitMessage() gave */
        return messages.wParam;
    }
    
    
    /*  This function is called by the Windows function DispatchMessage()  */
    
    LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
            
            
        switch (message)                  /* handle the messages */
        {
              
              case WM_CREATE:
                   CreateWindow(TEXT("button") , TEXT("Hi"),
                   WS_VISIBLE | WS_CHILD,
                   24,50,100,25,
                   hwnd, (HMENU) 1,NULL ,NULL
                   );
                   
                    CreateWindow(TEXT("edit") , TEXT("..."),
                   WS_VISIBLE | WS_CHILD | WS_BORDER | ES_AUTOHSCROLL,
                   24,7,100,25,
                   hwnd, (HMENU) 2,NULL ,NULL
                  // (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL);
    
    
                   );
                   
                   
                   
               break; 
         
              case WM_COMMAND:                 
               if (LOWORD(wParam) == 1){
               MessageBox(hwnd, "HI!", "mark" , MB_OK | MB_ICONINFORMATION);
               }
              break; 
               
               
               
            case WM_DESTROY:
                PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
                break;
            default:                      /* for messages that we don't deal with */
                return DefWindowProc (hwnd, message, wParam, lParam);
        }
    
        return 0;
    }
    Last edited by mark99; 12-05-2011 at 09:25 AM.

  2. #2
    Registered User
    Join Date
    Dec 2011
    Posts
    6
    i need help here >>

    Code:
    MessageBox(hwnd, "HI!", "mark" , MB_OK | MB_ICONINFORMATION);
    ___________________/\______----->how to make the title or text to display edit/texbox??

  3. #3
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    681
    You have to create a separate window, just like you do it in your WinMain().
    I never put signature, but I decided to make an exception.

  4. #4
    Registered User
    Join Date
    Dec 2011
    Posts
    6
    thx bro ,but can u give me an example source ?
    i am beginner!

  5. #5
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    681
    You already have! Just copy and set it up for the second window (to be clear, code in both functions). And then, instead of calling MessageBox(), you would call ShowWindow() for the second window (in the same way you do it for the first one in WinMain()).
    It looks like you have only copy-pasted someone's else code. You should get some idea of what it is currently doing first.
    mark99 likes this.
    I never put signature, but I decided to make an exception.

  6. #6
    Registered User
    Join Date
    Dec 2011
    Posts
    6
    Name:  1.jpg
Views: 40
Size:  46.3 KB
    i get this error plz help !!!

  7. #7
    Registered User
    Join Date
    Dec 2011
    Posts
    6
    i already did function and i have put:
    #define TXTU 101
    and function :
    Code:
    char msg()
    { 
    MessageBox(NULL,TXTU, "mark" , MB_OK | MB_ICONINFORMATION);
        }

  8. #8
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    681
    The second parameter is of const char* type (text), which means that you must not pass integer arguments, and TXTU (whatever it is supposed to be) is an integer.
    And your msg() function should return a char (which is obviously not the thing you want).
    I never put signature, but I decided to make an exception.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Textbox
    By maxorator in forum Windows Programming
    Replies: 20
    Last Post: 09-25-2005, 10:04 AM
  2. Textbox
    By Salibea in forum C++ Programming
    Replies: 6
    Last Post: 07-27-2005, 09:55 AM
  3. Need to set EDIT background BLACK and EDIT text WHITE
    By Garfield in forum Windows Programming
    Replies: 3
    Last Post: 08-29-2003, 01:36 PM
  4. How can I add to TextBox??(MFC)
    By c-- in forum Windows Programming
    Replies: 4
    Last Post: 09-03-2002, 06:32 AM
  5. Edit/Rich Edit window size restrictions
    By Echidna in forum Windows Programming
    Replies: 2
    Last Post: 01-19-2002, 02:23 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21