CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 1999
    Posts
    30

    Modeless Message box

    Hi,

    Can I create a modeless message box?
    Please help.

    Regards,
    Pabitra


  2. #2
    Join Date
    Apr 1999
    Posts
    25

    Re: Modeless Message box

    Hi,
    You can create modeless dlg box & then create a list box inside it. When u want to display a msg, you can do an InsertString() (remove any existing strings) to this listbox, and then bring that window to top & set focus to it. However, u cannot get any Yes/No/Cancel sort of user input. This is output only.

    In fact, I use this technique to debug my applications. My debug messages go to this modeless dlg box, instead of OutputDebugString(). I maintain the last 25 messages in the listbox.
    You can have a sizing border on the modeless dlg box, so that u can size it acc to your specs.

    regards,
    anant


  3. #3
    Join Date
    May 1999
    Posts
    78

    Re: Modeless Message box

    If ananta's response was not working for you,let me know i have a solution for a modless dialogue as well.or search for my posts and i have replied to the similar quetsions in the past.

    Good Luck


  4. #4
    Join Date
    Nov 2008
    Posts
    1

    Re: Modeless Message box

    what about this implementation:





    #pragma once


    /********************************************************************
    created: 2008/11/23
    created: 23:11:2008 11:16
    filename: ModelessMessageBox.h
    file path:
    file base: ModelessMessageBox
    file ext: h
    author: Shay

    purpose: Creating a message box not on the stack, without
    Stopping the code flow.
    Using thread and message box data on the heap.
    usage: ModelessMessageBox(NULL, sEvent, L"Debug events form menu", MB_OK);

    *********************************************************************/
    class _ModelessMessageBox
    {
    protected:
    struct MessageData
    {
    HWND hWnd;
    CString lpText;
    CString lpCaption;
    UINT uType;
    };
    static DWORD WINAPI DoMessageBoxThreadProc(LPVOID lpParameter)
    {
    if(lpParameter == NULL)
    return 1L;
    MessageData * pData= static_cast<MessageData *>(lpParameter);
    if (NULL == pData )
    return 1L;
    //else
    ::MessageBox(pData->hWnd, pData->lpCaption, pData->lpText, pData->uType);
    delete pData;
    return 0L;

    }

    public:

    static void Show( HWND hWnd = NULL,
    LPCTSTR lpText = L"",
    LPCTSTR lpCaption = L"",
    UINT uType = MB_OK
    )
    {

    MessageData * pMessageData = new MessageData;

    pMessageData->hWnd= hWnd;
    pMessageData->lpText = lpText;
    pMessageData->lpCaption = lpCaption;
    pMessageData->uType = uType;
    LPDWORD threadId = 0;
    CreateThread(NULL, 0, DoMessageBoxThreadProc, pMessageData/*(LPVOID)&m_messageData*/, 0, threadId);
    }

    };

    void ModelessMessageBox(HWND hWnd = NULL,
    LPCTSTR lpText = L"",
    LPCTSTR lpCaption = L"",
    UINT uType = MB_OK
    );


    in the cpp file
    ====================
    #include "ModelessMessageBox.h"
    void ModelessMessageBox( HWND hWnd /*= NULL*/, LPCTSTR lpText /*= L""*/, LPCTSTR lpCaption /*= L""*/, UINT uType /*= MB_OK */ )
    {
    _ModelessMessageBox::Show(hWnd /*= NULL*/,
    lpText/* = L""*/,
    lpCaption /*= L""*/,
    uType/* = MB_OK*/
    );
    }

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Modeless Message box

    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured