CreateWindow("AtlAxWin"... does not work in VS2005
The following code compiles and display the home page for google.com in VS6.
I can't get it to work in VS 2005. Any ideas?
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#pragma comment(lib, "atl.lib")
#define _ATL_DLL_IMPL
//#define _ATL_STATIC_IMPL
#include <atldef.h>
#include <atliface.h>
//using namespace ATL;
#define APP "MyWin32Window"
LRESULT CALLBACK MyWindowProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPrevInst,PSTR sxCommand,int
iShow)
{
WNDCLASSEX myWindow;
myWindow.cbClsExtra = 0;
myWindow.cbSize = sizeof(myWindow);
myWindow.cbWndExtra = 0;
myWindow.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
myWindow.hCursor = LoadCursor(NULL, IDC_ARROW);
myWindow.hIcon = LoadIcon(NULL, IDI_APPLICATION);
myWindow.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
myWindow.hInstance = hInst;
myWindow.lpfnWndProc = MyWindowProc;
myWindow.lpszClassName = APP;
myWindow.lpszMenuName = NULL;
myWindow.style = CS_HREDRAW | CS_VREDRAW;
RegisterClassEx(&myWindow);
AtlAxWinInit();
HWND hWnd;
hWnd = CreateWindow(APP,"AtlAxWin Test"
,WS_OVERLAPPEDWINDOW,0,0,640,480, NULL,NULL,hInst,NULL);
ShowWindow(hWnd, iShow);
UpdateWindow(hWnd);
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
//AtlAxWinTerm();
return msg.wParam;
}
LRESULT CALLBACK MyWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
lParam)
{
static HWND hWndX ;
RECT clientRect;
LPCREATESTRUCT lpcs;
switch(msg)
{
case WM_CREATE:
lpcs = (LPCREATESTRUCT) lParam;
hWndX = CreateWindow(
"AtlAxWin","http://www.google.com"
,WS_CHILD|WS_VISIBLE
,0,0,0,0
,hWnd,NULL,lpcs->hInstance,NULL
);
return 0;
case WM_SIZE:
GetClientRect(hWnd, &clientRect);
SetWindowPos(hWndX,HWND_TOP,0,0,clientRect.right,clientRect.bottom,SWP_NOZORDER);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}