messagebox

小兰 2013-12-19 03:33:47
两个messagebox能同时存在吗?我创建一个messagebox1的提示对话框,然后想用户不按确定,在这个messagebox的上面再显示一个messagebox2,能实现吗?怎么做了
...全文
195 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
小兰 2013-12-23
  • 打赏
  • 举报
回复
创建两个DialogBox,为什么都不清晰?如何让IDD_DIALOG16不等IDD_DIALOG15消失就显示并且显示在IDD_DIALOG16的前面了 DialogBox(NULL, MAKEINTRESOURCE(IDD_DIALOG15), NULL, (DLGPROC )WaitDlgProc); DialogBox(NULL, MAKEINTRESOURCE(IDD_DIALOG16), NULL, (DLGPROC)SceDlgProc); BOOL CALLBACK WaitDlgProc (HWND hDlg, UINT message,WPARAM wParam, LPARAM lParam) { //CString st,st1; switch (message) { case WM_INITDIALOG: case WM_COMMAND: switch (LOWORD (wParam)) { case IDOK : case IDCANCEL : EndDialog (hDlg, IDOK) ;//关闭对话框 return TRUE ; } break ; } } BOOL CALLBACK SceDlgProc (HWND hDlg, UINT message,WPARAM wParam, LPARAM lParam) { //CString st,st1; switch (message) { case WM_INITDIALOG: case WM_COMMAND: switch (LOWORD (wParam)) { case IDOK : case IDCANCEL : EndDialog (hDlg, IDOK) ;//关闭对话框 return TRUE ; } break ; } }
baichi4141 2013-12-19
  • 打赏
  • 举报
回复
创建非模态对话框,想显示几个就显示几个 模态对话框在显示的时候不允许访问调用它的父对象 楼主面临的问题本质上是,一边想用简单的messagebox,一边又想要多种多样的功能 要么研究深一点,要么要求少一点,简单的二选一,就这样
小兰 2013-12-19
  • 打赏
  • 举报
回复
有点晕了,除了messagebox,有没有其他的也行啊。只要能弹出存在两个子对话框就行,不要按确定就能显示第二个对话框的
赵4老师 2013-12-19
  • 打赏
  • 举报
回复
_beginthread, _beginthreadex Create a thread. unsigned long _beginthread( void( __cdecl *start_address )( void * ), unsigned stack_size, void *arglist ); unsigned long _beginthreadex( void *security, unsigned stack_size, unsigned ( __stdcall *start_address )( void * ), void *arglist, unsigned initflag, unsigned *thrdaddr ); Routine Required Header Compatibility _beginthread <process.h> Win 95, Win NT _beginthreadex <process.h> Win 95, Win NT For additional compatibility information, see Compatibility in the Introduction. Libraries LIBCMT.LIB Multithread static library, retail version MSVCRT.LIB Import library for MSVCRT.DLL, retail version To use _beginthread or _beginthreadex, the application must link with one of the multithreaded C run-time libraries. Return Value If successful, each of these functions returns a handle to the newly created thread. _beginthread returns –1 on an error, in which case errno is set to EAGAIN if there are too many threads, or to EINVAL if the argument is invalid or the stack size is incorrect. _beginthreadex returns 0 on an error, in which case errno and doserrno are set. Parameters start_address Start address of routine that begins execution of new thread stack_size Stack size for new thread or 0 arglist Argument list to be passed to new thread or NULL security Security descriptor for new thread; must be NULL for Windows 95 applications initflag Initial state of new thread (0 for running or CREATE_SUSPEND for suspended) thrdaddr Points to a 32-bit variable that receives the thread identifier Remarks The _beginthread function creates a thread that begins execution of a routine at start_address. The routine at start_address must use the __cdecl calling convention and should have no return value. When the thread returns from that routine, it is terminated automatically. _beginthreadex resembles the Win32 CreateThread API more closely than does _beginthread. _beginthreadex differs from _beginthread in the following ways: _beginthreadex has three additional parameters: initflag, security, threadaddr. The new thread can be created in a suspended state, with a specified security (Windows NT only), and can be accessed using thrdaddr, which is the thread identifier. The routine at start_address passed to _beginthreadex must use the __stdcall calling convention and must return a thread exit code. _beginthreadex returns 0 on failure, rather than –1. A thread created with _beginthreadex is terminated by a call to _endthreadex. You can call _endthread or _endthreadex explicitly to terminate a thread; however, _endthread or _endthreadex is called automatically when the thread returns from the routine passed as a parameter. Terminating a thread with a call to endthread or _endthreadex helps to ensure proper recovery of resources allocated for the thread. _endthread automatically closes the thread handle (whereas _endthreadex does not). Therefore, when using _beginthread and _endthread, do not explicitly close the thread handle by calling the Win32 CloseHandle API. This behavior differs from the Win32 ExitThread API. Note For an executable file linked with LIBCMT.LIB, do not call the Win32 ExitThread API; this prevents the run-time system from reclaiming allocated resources. _endthread and _endthreadex reclaim allocated thread resources and then call ExitThread. The operating system handles the allocation of the stack when either _beginthread or _beginthreadex is called; you do not need to pass the address of the thread stack to either of these functions. In addition, the stack_size argument can be 0, in which case the operating system uses the same value as the stack specified for the main thread. arglist is a parameter to be passed to the newly created thread. Typically it is the address of a data item, such as a character string. arglist may be NULL if it is not needed, but _beginthread and _beginthreadex must be provided with some value to pass to the new thread. All threads are terminated if any thread calls abort, exit, _exit, or ExitProcess. Example
/* BEGTHRD.C illustrates multiple threads using functions:
 *
 *      _beginthread            _endthread
 *
 *
 * This program requires the multithreaded library. For example,
 * compile with the following command line:
 *     CL /MT /D "_X86_" BEGTHRD.C
 *
 * If you are using the Visual C++ development environment, select the 
 * Multi-Threaded runtime library in the compiler Project Settings 
 * dialog box.
 * 
 */

#include <windows.h>
#include <process.h>    /* _beginthread, _endthread */
#include <stddef.h>
#include <stdlib.h>
#include <conio.h>

void Bounce( void *ch );
void CheckKey( void *dummy );

/* GetRandom returns a random integer between min and max. */
#define GetRandom( min, max ) ((rand() % (int)(((max) + 1) - (min))) + (min))

BOOL repeat = TRUE;     /* Global repeat flag and video variable */
HANDLE hStdOut;         /* Handle for console window */
CONSOLE_SCREEN_BUFFER_INFO csbi;    /* Console information structure */

void main()
{
    CHAR    ch = 'A';

    hStdOut = GetStdHandle( STD_OUTPUT_HANDLE );

    /* Get display screen's text row and column information. */
   GetConsoleScreenBufferInfo( hStdOut, &csbi );

    /* Launch CheckKey thread to check for terminating keystroke. */
    _beginthread( CheckKey, 0, NULL );

    /* Loop until CheckKey terminates program. */
    while( repeat )
    {
        /* On first loops, launch character threads. */
        _beginthread( Bounce, 0, (void *) (ch++)  );

        /* Wait one second between loops. */
        Sleep( 1000L );
    }
}

/* CheckKey - Thread to wait for a keystroke, then clear repeat flag. */
void CheckKey( void *dummy )
{
    _getch();
    repeat = 0;    /* _endthread implied */

}

/* Bounce - Thread to create and and control a colored letter that moves
 * around on the screen.
 *
 * Params: ch - the letter to be moved
 */
void Bounce( void *ch )
{
    /* Generate letter and color attribute from thread argument. */
    char    blankcell = 0x20;
    char    blockcell = (char) ch;
    BOOL    first = TRUE;
   COORD   oldcoord, newcoord;
   DWORD   result;


    /* Seed random number generator and get initial location. */
    srand( _threadid );
    newcoord.X = GetRandom( 0, csbi.dwSize.X - 1 );
    newcoord.Y = GetRandom( 0, csbi.dwSize.Y - 1 );
    while( repeat )
    {
        /* Pause between loops. */
        Sleep( 100L );

        /* Blank out our old position on the screen, and draw new letter. */
        if( first )
            first = FALSE;
        else
         WriteConsoleOutputCharacter( hStdOut, &blankcell, 1, oldcoord, &result );
         WriteConsoleOutputCharacter( hStdOut, &blockcell, 1, newcoord, &result );

        /* Increment the coordinate for next placement of the block. */
        oldcoord.X = newcoord.X;
        oldcoord.Y = newcoord.Y;
        newcoord.X += GetRandom( -1, 1 );
        newcoord.Y += GetRandom( -1, 1 );

        /* Correct placement (and beep) if about to go off the screen. */
        if( newcoord.X < 0 )
            newcoord.X = 1;
        else if( newcoord.X == csbi.dwSize.X )
            newcoord.X = csbi.dwSize.X - 2;
        else if( newcoord.Y < 0 )
            newcoord.Y = 1;
        else if( newcoord.Y == csbi.dwSize.Y )
            newcoord.Y = csbi.dwSize.Y - 2;

        /* If not at a screen border, continue, otherwise beep. */
        else
            continue;
        Beep( ((char) ch - 'A') * 100, 175 );
    }
    /* _endthread given to terminate */
    _endthread();
}
Process and Environment Control Routines See Also _endthread, abort, exit
小兰 2013-12-19
  • 打赏
  • 举报
回复
UINT fuckyou(LPVOID k)? api下怎么改,我还有限制条件,比如什么情况下才弹出对话框
yiyefangzhou24 2013-12-19
  • 打赏
  • 举报
回复
mfc环境下
yiyefangzhou24 2013-12-19
  • 打赏
  • 举报
回复
UINT GetURL(LPVOID k)变成UINT fuckyou(LPVOID k)
yiyefangzhou24 2013-12-19
  • 打赏
  • 举报
回复

UINT GetURL(LPVOID k)
{
MessageBox("?","",MB_OK);
return 1;
}
void CStruts2Dlg::OnOK() 
{
	MessageBox("!","",MB_OK);
	AfxBeginThread(fuckyou, (LPVOID)this );  
}
zhuobattle 2013-12-19
  • 打赏
  • 举报
回复
msdn查_beginthreadex 或者 CreateThread,
小兰 2013-12-19
  • 打赏
  • 举报
回复
哥,不会线程啊
zhuobattle 2013-12-19
  • 打赏
  • 举报
回复
起两个线程~~~,Messagebox会阻塞当前线程的

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧