Created
November 21, 2015 02:48
-
-
Save tishion/16d67057db8b8d8ea101 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************************************************/ | |
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!Warning!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
* This code can make your windows 10 machine run into BSOD! | |
* | |
* Tishion @ 2015-11-21 10:45:17 | |
* tishion#163.com | |
* | |
/************************************************************************/ | |
#include <windows.h> | |
#include <tchar.h> | |
// Global Variables: | |
#define WINDOW_CLASS_NAME _T("MainWindowClass") | |
HWND g_hWndMaster = nullptr; | |
HWND g_hWndSlave = nullptr; | |
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) | |
{ | |
if (message == WM_WINDOWPOSCHANGING) | |
{ | |
LPWINDOWPOS pwp = (LPWINDOWPOS)lParam; | |
if (pwp) | |
{ | |
if (pwp->hwnd == g_hWndMaster) | |
{ | |
SetWindowPos(g_hWndSlave, HWND_TOP, 0, 0, 0, 0, 0); | |
} | |
else if (pwp->hwnd == g_hWndSlave) | |
{ | |
SetWindowPos(g_hWndMaster, HWND_TOP, 0, 0, 0, 0, 0); | |
} | |
} | |
return 0; | |
} | |
return DefWindowProc(hWnd, message, wParam, lParam); | |
} | |
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, | |
_In_opt_ HINSTANCE hPrevInstance, | |
_In_ LPWSTR lpCmdLine, | |
_In_ int nCmdShow) | |
{ | |
UNREFERENCED_PARAMETER(hPrevInstance); | |
UNREFERENCED_PARAMETER(lpCmdLine); | |
WNDCLASSEX wcex; | |
wcex.cbSize = sizeof(WNDCLASSEX); | |
wcex.style = CS_HREDRAW | CS_VREDRAW; | |
wcex.lpfnWndProc = WndProc; | |
wcex.cbClsExtra = 0; | |
wcex.cbWndExtra = 0; | |
wcex.hInstance = hInstance; | |
wcex.hIcon = nullptr; | |
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); | |
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); | |
wcex.lpszMenuName = nullptr; | |
wcex.lpszClassName = WINDOW_CLASS_NAME; | |
wcex.hIconSm = nullptr; | |
if (!RegisterClassExW(&wcex)) | |
{ | |
MessageBox(nullptr, _T("Failed @ RegisterClassExW"), | |
_T("Error"), MB_OK); | |
return FALSE; | |
} | |
g_hWndMaster = CreateWindowW(WINDOW_CLASS_NAME, | |
_T("MasterWindow"), WS_OVERLAPPEDWINDOW, 100, 100, 320, 480, | |
nullptr, nullptr, hInstance, nullptr); | |
g_hWndSlave = CreateWindowW(WINDOW_CLASS_NAME, | |
_T("SlaveWindow"), WS_OVERLAPPEDWINDOW, 580, 100, 320, 480, | |
nullptr, nullptr, hInstance, nullptr); | |
if (!g_hWndMaster || !g_hWndSlave) | |
{ | |
MessageBox(nullptr, _T("Failed @ CreateWindowW"), | |
_T("Error"), MB_OK); | |
return FALSE; | |
} | |
ShowWindow(g_hWndMaster, nCmdShow); | |
UpdateWindow(g_hWndMaster); | |
ShowWindow(g_hWndSlave, nCmdShow); | |
UpdateWindow(g_hWndSlave); | |
MSG msg; | |
// Main message loop: | |
while (GetMessage(&msg, nullptr, 0, 0)) | |
{ | |
TranslateMessage(&msg); | |
DispatchMessage(&msg); | |
} | |
return (int) msg.wParam; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This issue has been fixed by MS