Go through the below code....
BOOL CWindow::createImgWin(){
DWORD err;
//1. Get instance of parent window.
HINSTANCE hInstance = (HINSTANCE)GetWindowLong(m_hParentWnd, GWL_HINSTANCE);
//2. Create window class style for acsys image window.
WNDCLASSEX wcImg;
ATOM clsAtom(NULL);
std::wstring winName = L"ImageWindow";
std::wstring className = L"ImageWindowClass";
if (!clsAtom) {
//3. structuring the Window Class
wcImg.cbSize = sizeof(WNDCLASSEX);
wcImg.style = CS_DBLCLKS | CS_NOCLOSE | CS_VREDRAW | CS_HREDRAW | CS_DROPSHADOW | CS_NOCLOSE;
wcImg.lpfnWndProc = &CWindow::acsysWinProc;
wcImg.cbClsExtra = 0;
wcImg.cbWndExtra = 0;
wcImg.hInstance = hInstance;
wcImg.lpszMenuName = NULL;
wcImg.lpszClassName = className.c_str();
wcImg.hIcon = NULL;
wcImg.hCursor = NULL;
wcImg.hIconSm = NULL;
wcImg.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
//4. Registering Class
if (!(clsAtom = ::RegisterClassEx(&wcImg))) {
err = GetLastError();
if (err != ERROR_CLASS_ALREADY_EXISTS) {
throw std::runtime_error("Could not register window class");
}
}
}
//4. Create image window class
g_hChildWin = CreateWindowEx(
WS_EX_WINDOWEDGE | WS_EX_NOPARENTNOTIFY, //Extended Window Styles - WS_EX_TOOLWINDOW, WS_OVERLAPPEDWINDOW, WS_OVERLAPPED, WS_EX_STATICEDGE
className.c_str(), //window class name
winName.c_str(), //window caption
WS_CHILDWINDOW | WS_VISIBLE |
WS_BORDER | WS_VSCROLL | WS_HSCROLL, //window style WS_VSCROLL WS_HSCROLL ES_AUTOHSCROLL, WS_CHILD
0, //initial x position
0, //initial y position
(int)getWndWidth(), //initial x size
(int)getWndHeight(), //initial y size
m_hParentWnd, //parent window handle
NULL, //window menu handle
hInstance, //program instance handle
NULL //creation parameters
);
if (!g_hChildWin) {
throw std::runtime_error("Could not create Message Window");
return FALSE;
}
int nCmdShow = SW_SHOWNORMAL;
ShowWindow(g_hChildWin, nCmdShow);
UpdateWindow(g_hChildWin);
return TRUE;
}
Thanks
Kannan