#include<windows.h>
#include<stdio.h>
class CMyWindow
{
public:
BOOL CreateEx (DWORD dwExStyle, // extended window style
LPCTSTR lpClassName, // registered class name
LPCTSTR lpWindowName, // window name
DWORD dwStyle, // window style
int x, // horizontal position of window
int y, // vertical position of window
int nWidth, // window width
int nHeight, // window height
HWND hWndParent, // handle to parent or owner window
HMENU hMenu, // menu handle or child identifier
HINSTANCE hInstance, // handle to application instance
LPVOID lpParam // window-creation data
);
BOOL ShowWindow(int CmdShow);
BOOL UpdateWindow();
public:
HWND m_hwnd;
};
BOOL CMyWindow::CreateEx(DWORD dwExStyle, // extended window style
LPCTSTR lpClassName, // registered class name
LPCTSTR lpWindowName, // window name
DWORD dwStyle, // window style
int x, // horizontal position of window
int y, // vertical position of window
int nWidth, // window width
int nHeight, // window height
HWND hWndParent, // handle to parent or owner window
HMENU hMenu, // menu handle or child identifier
HINSTANCE hInstance, // handle to application instance
LPVOID lpParam // window-creation data
)
{
m_hwnd=::CreateWindowEx(dwExStyle, lpClassName,lpWindowName,dwStyle,
x,y,nWidth,nHeight,hWndParent, hMenu,hInstance,lpParam);
if(m_hwnd!=NULL)
return TRUE;
else
return FALSE;
}
BOOL CMyWindow::ShowWindow(int CmdShow)
{
return ::ShowWindow(m_hwnd,CmdShow);
}
BOOL CMyWindow::UpdateWindow()
{
return ::UpdateWindow(m_hwnd);
}
LRESULT CALLBACK Function( HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
WNDCLASS ws;
ws.cbClsExtra=0;
ws.cbWndExtra=0;
ws.hbrBackground=(HBRUSH)GetStockObject(LTGRAY_BRUSH);
ws.hCursor=LoadCursor(NULL,IDC_IBEAM);
ws.hIcon=LoadIcon(NULL,IDI_QUESTION);
ws.hInstance=hInstance;
ws.lpfnWndProc=Function;
ws.lpszClassName="Kitus";
ws.lpszMenuName=NULL;
ws.style=CS_BYTEALIGNWINDOW;
RegisterClass(&ws);
CMyWindow window;
window.CreateEx(WS_EX_OVERLAPPEDWINDOW,ws.lpszClassName,"Kitus' window",WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL,NULL,hInstance,NULL);
window.ShowWindow(SW_SHOWNORMAL);
window.UpdateWindow();
MSG msg;
while(GetMessage(&msg,window.m_hwnd,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
};
LRESULT CALLBACK Function( HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
PAINTSTRUCT ps;
HDC hdc;
switch(uMsg)
{
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
TextOut(hdc,0,0,"I love my family!",strlen("I love my family!"));
EndPaint(hwnd,&ps);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"You pressed the left button!","Notice",MB_OKCANCEL);
hdc=GetDC(hwnd);
TextOut(hdc,20,20,"Good Good Study!",strlen("Good Good Study!"));
ReleaseDC(hwnd,hdc);
break;
case WM_CLOSE:
if(IDOK==MessageBox(hwnd,"Do you rellay want to close the window?","Warning!",MB_OKCANCEL))
CloseWindow(hwnd);
PostQuitMessage(0);
break;
case WM_DESTROY:
DestroyWindow(hwnd);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
#include<stdio.h>
class CMyWindow
{
public:
BOOL CreateEx (DWORD dwExStyle, // extended window style
LPCTSTR lpClassName, // registered class name
LPCTSTR lpWindowName, // window name
DWORD dwStyle, // window style
int x, // horizontal position of window
int y, // vertical position of window
int nWidth, // window width
int nHeight, // window height
HWND hWndParent, // handle to parent or owner window
HMENU hMenu, // menu handle or child identifier
HINSTANCE hInstance, // handle to application instance
LPVOID lpParam // window-creation data
);
BOOL ShowWindow(int CmdShow);
BOOL UpdateWindow();
public:
HWND m_hwnd;
};
BOOL CMyWindow::CreateEx(DWORD dwExStyle, // extended window style
LPCTSTR lpClassName, // registered class name
LPCTSTR lpWindowName, // window name
DWORD dwStyle, // window style
int x, // horizontal position of window
int y, // vertical position of window
int nWidth, // window width
int nHeight, // window height
HWND hWndParent, // handle to parent or owner window
HMENU hMenu, // menu handle or child identifier
HINSTANCE hInstance, // handle to application instance
LPVOID lpParam // window-creation data
)
{
m_hwnd=::CreateWindowEx(dwExStyle, lpClassName,lpWindowName,dwStyle,
x,y,nWidth,nHeight,hWndParent, hMenu,hInstance,lpParam);
if(m_hwnd!=NULL)
return TRUE;
else
return FALSE;
}
BOOL CMyWindow::ShowWindow(int CmdShow)
{
return ::ShowWindow(m_hwnd,CmdShow);
}
BOOL CMyWindow::UpdateWindow()
{
return ::UpdateWindow(m_hwnd);
}
LRESULT CALLBACK Function( HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
WNDCLASS ws;
ws.cbClsExtra=0;
ws.cbWndExtra=0;
ws.hbrBackground=(HBRUSH)GetStockObject(LTGRAY_BRUSH);
ws.hCursor=LoadCursor(NULL,IDC_IBEAM);
ws.hIcon=LoadIcon(NULL,IDI_QUESTION);
ws.hInstance=hInstance;
ws.lpfnWndProc=Function;
ws.lpszClassName="Kitus";
ws.lpszMenuName=NULL;
ws.style=CS_BYTEALIGNWINDOW;
RegisterClass(&ws);
CMyWindow window;
window.CreateEx(WS_EX_OVERLAPPEDWINDOW,ws.lpszClassName,"Kitus' window",WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL,NULL,hInstance,NULL);
window.ShowWindow(SW_SHOWNORMAL);
window.UpdateWindow();
MSG msg;
while(GetMessage(&msg,window.m_hwnd,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
};
LRESULT CALLBACK Function( HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
PAINTSTRUCT ps;
HDC hdc;
switch(uMsg)
{
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
TextOut(hdc,0,0,"I love my family!",strlen("I love my family!"));
EndPaint(hwnd,&ps);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"You pressed the left button!","Notice",MB_OKCANCEL);
hdc=GetDC(hwnd);
TextOut(hdc,20,20,"Good Good Study!",strlen("Good Good Study!"));
ReleaseDC(hwnd,hdc);
break;
case WM_CLOSE:
if(IDOK==MessageBox(hwnd,"Do you rellay want to close the window?","Warning!",MB_OKCANCEL))
CloseWindow(hwnd);
PostQuitMessage(0);
break;
case WM_DESTROY:
DestroyWindow(hwnd);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}