1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
#include <windows.h>
#include <tchar.h>
#define IDC_SECOND_SCREEN 1500
LRESULT CALLBACK fnOutputScreen_WndProc(HWND hwnd, unsigned int msg, WPARAM wParam, LPARAM lParam)
{
return (DefWindowProc(hwnd, msg, wParam, lParam));
}
LRESULT CALLBACK fnWndProc(HWND hwnd, unsigned int msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
{
WNDCLASSEX wc;
HINSTANCE hIns = ((LPCREATESTRUCT)lParam)->hInstance;
HWND hWnd = CreateWindow(_T("button"),_T("Show Output Screen"),WS_CHILD|WS_VISIBLE,95,40,150,25,hwnd,(HMENU)IDC_SECOND_SCREEN,hIns,0);
TCHAR szClassName[] = _T("OutputScreen");
wc.lpszClassName = szClassName;
wc.lpfnWndProc = fnOutputScreen_WndProc;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wc.hInstance = hIns;
wc.hIconSm = 0;
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.cbWndExtra = 0;
wc.lpszMenuName = NULL;
wc.cbClsExtra = 0;
RegisterClassEx(&wc);
return 0;
}
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_SECOND_SCREEN:
HWND hWnd=CreateWindowEx(0,_T("OutputScreen"),_T("Output Screen"),WS_OVERLAPPEDWINDOW,350,450,450,450,HWND_DESKTOP,0,GetModuleHandle(NULL),0);
ShowWindow(hWnd,SW_SHOWNORMAL);
break;
}
return 0;
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
}
return (DefWindowProc(hwnd, msg, wParam, lParam));
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int iShow)
{
TCHAR szClassName[]=_T("Form1");
WNDCLASSEX wc;
MSG messages;
HWND hWnd;
wc.lpszClassName=szClassName, wc.lpfnWndProc=fnWndProc;
wc.cbSize=sizeof (WNDCLASSEX), wc.style=0;
wc.hIcon=LoadIcon(NULL,IDI_APPLICATION), wc.hInstance=hInstance;
wc.hIconSm=LoadIcon(NULL, IDI_APPLICATION), wc.hCursor=LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground=(HBRUSH)COLOR_BTNSHADOW, wc.cbWndExtra=0;
wc.lpszMenuName=NULL, wc.cbClsExtra=0;
RegisterClassEx(&wc),
hWnd=CreateWindowEx(0,szClassName,szClassName,WS_OVERLAPPEDWINDOW,150,150,350,150,HWND_DESKTOP,0,hInstance,0);
ShowWindow(hWnd,iShow);
while(GetMessage(&messages,NULL,0,0))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
return messages.wParam;
}
| |