LewisJT

I use the following method to display a webpage (usually a help page) in my MDI WIN32 application using Visual Studio 6. When I compile my app with VS 2003 it compiles but no page is displayed. GetLastError() returns "Class does not exist.". Any help would be appreciated.

HTML::HTML(char * heading,char * url)
{
HCURSOR hCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
hWndWB = 0;
strcpy(title,heading);
createMDI();

hWndWB = CreateWindow("AtlAxWin",url
,WS_CHILD|WS_VISIBLE|WS_VSCROLL
,0,48,rect.right,rect.bottom -48 -22
,hWnd,NULL,hInstance,NULL
);

SetWindowText(hWnd,title);
SetWindowText(hWndStatusbar,url);
wmSize();
SetFocus(hWndWB);
//app.hWndMDI = hWnd;
SetCursor(hCursor);
}




Re: Windows SDK CreateWindow("AtlAxWin",... does not work using VS2003

Calpol

I've used the same class but with assembly using Windows API functions so this may not work (might be different somehow). But I've always had to use AtlAxWinInit() before creating the window. The function can be imported from atl.dll.






Re: Windows SDK CreateWindow("AtlAxWin",... does not work using VS2003

Fred Foobar

Try using AtlAxWin80 or AtlAxWin71 (or whatever version comes with VS2003). See also
http://msdn2.microsoft.com/en-us/library/1stby863(VS.80).aspx

Cheers




Re: Windows SDK CreateWindow("AtlAxWin",... does not work using VS2003

LewisJT

The following code now works for me with VS2005. Please note the pragma statement to add to the executables manifest. If anyone can tell me how to make the toolbar (with the back page button) visible I will be grateful

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <TCHAR.H>
//#include "atltest.h"
#pragma comment(linker, "\"/manifestdependency:type='Win32' name='Microsoft.VC80.ATL' version='8.0.50727.762' processorArchitecture='X86' publicKeyToken='1fc8b3b9a1e18e3b' language='*'\"")
//#pragma comment(lib, "atl.lib")
//#define _ATL_DLL_IMPL
//#define _ATL_STATIC_IMPL
#include <atldef.h>
#include <atliface.h>
using namespace ATL;

#define APP _T("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,_T("atl 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((LPCSTR)"AtlAxWin80",(LPCSTR)"http://www.google.com",WS_CHILD|WS_VISIBLE,0,0,0,0,hWnd,NULL,lpcs->hInstance,NULL
//);
hWndX = CreateWindow(ATLAXWIN_CLASS,_T("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);
}