Create a new Win32 project in VC6.0
New C++ source file
#include <windows.h>
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
return 0;
}
#include <windows.h>
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
if(IDCANCEL == MessageBox(NULL, TEXT ("Pop-up message"), TEXT ("Pop 1"), MB_OKCANCEL))
{
//If you click cancel
MessageBox (NULL, TEXT ("Pop-up message"), TEXT ("Pop 2"), MB_OK);
}
return 0;
}
#include <windows.h>
// thread running function
DWORD WINAPI CloseDialog(LPVOID param)
{
ExitThread(0);
return 0;
}
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
DWORD parameter = 0;
DWORD id;
//Create thread
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CloseDialog, ¶meter, 0, &id);
if(IDCANCEL == MessageBox(NULL, TEXT ("Pop-up message"), TEXT ("Pop 1"), MB_OKCANCEL))
{
//If you click cancel
MessageBox (NULL, TEXT ("Pop-up message"), TEXT ("Pop 2"), MB_OK);
}
return 0;
}
#include <windows.h>
static TCHAR title[] = TEXT ("Pop 1");
// thread running function
DWORD WINAPI CloseDialog(LPVOID param)
{
//Sleep for 8000ms
Sleep(8000);
HANDLE hWnd = ::FindWindowEx(NULL, NULL, NULL,title);
if (hWnd)
{
//Close the dialog
::EndDialog((HWND)hWnd, IDNO);
}
ExitThread(0);
return 0;
}
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
DWORD parameter = 0;
DWORD id;
//Create thread
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CloseDialog, ¶meter, 0, &id);
if(IDCANCEL == MessageBox(NULL, TEXT ("Close in 8 seconds"), title, MB_OKCANCEL))
{
//If you click cancel
MessageBox (NULL, TEXT ("Won't close"), TEXT ("Pop 2"), MB_OK);
}
return 0;
}
The following content is collected from the Internet.
To spawn a thread (and thus achieve a multi-threaded program), with CreateThread () as the beginning of all actions.
HANDLE CreateThread(
LPSECURITY_ATTRIBUTES lpThreadAttributes,
SIZE_T dwStackSize,
LPTHREAD_START_ROUTINE lpStartAddress,
LPVOID lpParameter,
DWORD dwCreationFlags,
LPDWORD lpThreadId
);
lpThreadAttributes: Describe the security attributes applied to this new thread. NULL means use the default value.
dwStatckSize: The new thread has its own stack, 0 means to use the default size.
lpStartAddress: The starting address where the new thread will start. This is a function pointer (in the C language, the function name represents the function pointer).
lpParameter: This value will be passed to the new thread function specified above as a parameter (the only parameter).
dwCreationFlags: Allows you to spawn a temporarily suspended thread, the default is "start execution immediately".
lpThreadId: The ID of the new thread will be passed back here.
If CreateThread() succeeds, it returns a handle representing the new thread, otherwise it returns FALSE. If it fails, you can call GetLastError() to find out the reason.
A dialog box pops up.
int MessageBox(
HWND hWnd,
LPCTSTR lpText,
LPCTSTR lpCaption,
UINT uType
);
hWnd
handles the owner window of the message box to be created. If this parameter is empty, the message box has no owner window.
lpText
Pointer to a null-terminated string containing the message to be displayed
lpCaption
A pointer to a null-terminated string containing the title of the dialog box. If this parameter is empty, the default title Error is used.
uType
Specify the content and behavior of the dialog box. This parameter can be a combination of the following sets of flags. Point out the button displayed in the message box.
MB_OK
The default value. There is a confirmation button inside.
MB_YESNO
has yes and no in it.
MB_ABORTRETRYIGNORE
There are Abort, Retry and Ignore
MB_YESNOCANCEL
The message box contains three buttons: Yes, No and Cancel
MB_RETRYCANCEL
Retry (retry) and Cancel (cancel)
MB_OKCANCEL
The message box contains two buttons: OK and Cancel
X error MB_ICONHAND, MB_ICONSTOP, MB_ICONERROR
? Ask MB_ICONQUESTION
! Warning MB_ICONEXCLAMATION, MB_ICONWARNING
i information MB_ICONASTERISK, MB_ICONINFORMATION
The above things can be seen in msdn.
If a message box has a cancel button, then if the ESC key is pressed or the cancel button is cancelled, the function will return the IDCANCEL value.
If the message box does not have a cancel button, pressing the ESC key has no effect.
If the function fails, the return value is 0.
If the function succeeds, the return value is one of the values of the following menu items.
The IDABORT Abort button is selected.
IDCANCEL Cancel button is selected.
IDCONTINUE Continue button is selected.
The IDIGNOR EIgnore button is selected.
IDNO No button is selected.
IDOK OK button is selected.
The IDRETRY Retry button is selected.
IDYES Yes button is selected.
Find the first child window that matches the specified conditions in the window list.
This function obtains the handle of a window whose class name and window name match the given string. This function finds the child window, starting from the next child window behind the given child window. The search is not case sensitive.
HWND FindWindowEx(
HWND hwndParent,
HWND hwndChildAfter,
LPCTSTR lpszClass,
LPCTSTR lpszWindow
);
hwndParent: The handle of the parent window where the child window to be found is located (if hwndParent is set, it means that the child window is searched from the parent window pointed to by this hwndParent).
If hwndParent is 0, the function uses the desktop window as the parent window to find all child windows of the desktop window.
Windows NT5.0 and later: If hwndParent is HWND_MESSAGE, the function only finds all message windows.
hwndChildAfter: The handle of the child window. The search starts from the next child window in the Z sequence. The child window must be a direct child window of the hwndParent window and not a descendant window. If HwndChildAfter is NULL, the search starts from the first child window of hwndParent. If hwndParent and hwndChildAfter are both NULL, the function finds all top-level windows and message windows.
lpszClass: Pointer to a null-terminated string specifying the class name, or a pointer to a member of the class name string. If the parameter is a member, it must be the global member generated by the previous call to theGlobaIAddAtom function. This member is 16 bits and must be located in the low 16 bits of lpClassName, and the high bit must be 0.
lpszWindow: points to a null-terminated string that specifies the window name (window title). If this parameter is NULL, all windows are matched.
Long, the handle of the window found. If no matching window is found, zero is returned. Will set GetLastError
If the function succeeds, the return value is the window handle with the specified class name and window name. If the function fails, the return value is NULL.
If you want to get more error information, please call GetLastError function.
This function clears a modal dialog box and causes the system to suspend any processing of the dialog box.
BOOL EndDialog(HWND hDlg,int nResult);
hDlg: Indicates the dialog window to be cleared.
NResult: Specify the value returned to the application from the dialog box creation function.
If the function call succeeds, the return value is non-zero; if the function call fails, the return value is zero. If you want to get error information, please call GetLastError function.
Callable interface and the use FutureTask class is created, and the difference between using the Thread class and Runnable interface before is that this method returns the return value of the thread e...
1, define the message 2, an announcement message 4, adding the message map 3, implement the message response function 4, sends a message in the thread Reproduced in: https: //www.cnblogs...
Recently, I received a job, imitating an interface to make a calculation book function. The fake interface is as follows The left is the tree control, and the right is the sub-window interface. When t...
Solve the problem of multiple nesting of el-dialog bullet boxes. Realize the best el-dialog With the widespread use of vueJs, Element components are gradually gaining popularity. But when using elemen...
Use jquery to automatically select the multi-select box on the page when the page loads When entering the page, the check box is automatically selected Code demo: The important one is the code: $(&quo...
Article directory foreword 1. Causes 2. Experiment foreword When closing the "Computer Management" application, the problem "You must close all dialog boxes before closing Computer Mana...
Dialog with custom dialog box Dialog Ordinary dialog Radio dialog Checkbox Customize dialog box Horizontal progress bar dialog Round fuzzy progress dialog Date selection dialog Time selection dialog D...
1. Simple introductory dialog activity_main.xml MainActivity.java Two, list dialog box and single selection dialog box activity_main.xml MainActivity.java Three, multiple selection dialog box and wait...
Dialog dialog 1. Common dialog 1. Common dialog 2. Single selection dialog 3. Multiple selection dialog 4. Customize the dialog 5. Horizontal progress bar dialog 6. Circular progress bar dialog 7. Dat...