Handles to a window object

I created this program (code below) only to display a window, the very basics. I am using Visual Studio 2010(trial), using Visual C++. I created a class windowmain which inherits from CWnd. When I execute the program, the compiler does not report any error and the linker creates the executable file. But on execution, the assemble debugger reports access violation and the object which points to the CWnd object cannot identify the handle for the window to be created. Appreciate some help in this code.

#include "Stdafx.h"
#include "DFL.h"
#include<stdio.h>
#include <afxwin.h>

class windowmain : public CWnd
{

public:
HWND WMHnd;
windowmain(){};
};

void WindowCreate(void);

void WindowCreate(void){
BOOL Suc=false; HWND WCHnd;

windowmain Cfrmwin2=(windowmain *) NULL;

RECT trect;
trect.bottom =23;
trect.left=30;
trect.right=120;
trect.top=5;

WNDCLASS twndclass;

twndclass.cbClsExtra=100;
twndclass.cbWndExtra=DLGWINDOWEXTRA;
twndclass.hbrBackground=(HBRUSH)COLOR_ACTIVEBORDER;
twndclass.hCursor=NULL;
twndclass.hIcon=NULL;
twndclass.hInstance=(HINSTANCE) Cfrmwin2.WMHnd;
twndclass.lpszClassName ="CLASS1";
twndclass.lpszMenuName ="MENU1";
twndclass.lpfnWndProc=(WNDPROC) (Cfrmwin2.WMHnd,ABM_ACTIVATE,NULL,NULL);
twndclass.style=WS_EX_DLGMODALFRAME;
CCreateContext *CCt=(CCreateContext*) 0;

Cfrmwin2->Attach(WMHnd);
Cfrmwin2->Create("CLASS1","Windows Main",WS_CAPTION,trect,NULL,1,NULL);
};

int main()
{
BOOL Suc;
Suc=false;

WindowCreate();
return(0);
};
Topic archived. No new replies allowed.