Connecting Tech Pros Worldwide Forums | Help | Site Map

access conflict with (LPVOID)this in CreateWindowEx

Young
Guest
 
Posts: n/a
#1: Dec 24 '07
This makes me very puzzled and angry.Please have a look at :
.......
.......
_hSelf=::CreateWindowEx(
WS_EX_ACCEPTFILES,
(LPCWSTR)_className,\
(LPCWSTR)"Web Studio 2008",\
WS_OVERLAPPEDWINDOW,\
CW_USEDEFAULT,\
CW_USEDEFAULT,\
CW_USEDEFAULT,\
CW_USEDEFAULT,\
_hParent,\
NULL,\
_hInst,\
(LPVOID)this);
........
........
The code is compiled and linked successly under VS2005.But ever time
it runs to "(LPVOID)this" in the function "CreateWindowEx" ,an
exception occurs which say
0x00000000 Department untreated anomaly: 0xC0000005: reading position
0 x00000000 visit when conflict
in the VS 2005.

Why?Why?WWWWW?

Barry
Guest
 
Posts: n/a
#2: Dec 24 '07

re: access conflict with (LPVOID)this in CreateWindowEx


Young wrote:
Quote:
This makes me very puzzled and angry.Please have a look at :
......
......
_hSelf=::CreateWindowEx(
WS_EX_ACCEPTFILES,
(LPCWSTR)_className,\
(LPCWSTR)"Web Studio 2008",\
WS_OVERLAPPEDWINDOW,\
CW_USEDEFAULT,\
CW_USEDEFAULT,\
CW_USEDEFAULT,\
CW_USEDEFAULT,\
_hParent,\
NULL,\
_hInst,\
(LPVOID)this);
.......
.......
The code is compiled and linked successly under VS2005.But ever time
it runs to "(LPVOID)this" in the function "CreateWindowEx" ,an
exception occurs which say
0x00000000 Department untreated anomaly: 0xC0000005: reading position
0 x00000000 visit when conflict
in the VS 2005.
Your code is not detailed enough, what kind of class object does "this"
points to?

And I suspect that this is off-topic, better post it to windows
programming NG.
Young
Guest
 
Posts: n/a
#3: Dec 24 '07

re: access conflict with (LPVOID)this in CreateWindowEx


Oh,I'm sorry I'm new to this usernet.I think the bug concerned with
cpp,so...And if it can't be solved here ,I will go windows programming
NG. But please do me a favor, thanks.
......
class WebStudio:public Window
{
public:
WebStudio():Window(){};
//,_mainWindowStatus(0),_pMainSplitter(NULL),_hTabPo pupMenu(NULL),_hTabPopupDropMenu(NULL),_pEditView( NULL),_pDocTab(NULL)
{};

void init(HINSTANCE,HWND,const char*);
bool doOpen(const char *fileName);
static const char * getClassName() {
return _className;
};
private:
static const char _className[32];
};
.....
class Window
{
public:
Window():_hSelf(NULL),_hParent(NULL),_hInst(NULL){ };
virtual ~Window(){};
virtual void init(HINSTANCE hInst, HWND parent)
{
_hInst = hInst;
_hParent = parent;
}

protected:
HINSTANCE _hInst;
HWND _hParent;
HWND _hSelf;
};
.....
Young
Guest
 
Posts: n/a
#4: Dec 24 '07

re: access conflict with (LPVOID)this in CreateWindowEx


Mm,after I send the last message,I suddenly notice that the last param
in CreateWindowEx should point to a CREATESTRUCT struct.But if so, I
have no idea to make it point to the CREATESTRUCT struct.How to do
that?
Barry
Guest
 
Posts: n/a
#5: Dec 24 '07

re: access conflict with (LPVOID)this in CreateWindowEx


Young wrote:
Quote:
Oh,I'm sorry I'm new to this usernet.I think the bug concerned with
cpp,so...And if it can't be solved here ,I will go windows programming
NG. But please do me a favor, thanks.
.....
class WebStudio:public Window
{
public:
WebStudio():Window(){};
//,_mainWindowStatus(0),_pMainSplitter(NULL),_hTabPo pupMenu(NULL),_hTabPopupDropMenu(NULL),_pEditView( NULL),_pDocTab(NULL)
{};
>
void init(HINSTANCE,HWND,const char*);
bool doOpen(const char *fileName);
static const char * getClassName() {
return _className;
};
private:
static const char _className[32];
};
....
class Window
{
public:
Window():_hSelf(NULL),_hParent(NULL),_hInst(NULL){ };
virtual ~Window(){};
virtual void init(HINSTANCE hInst, HWND parent)
{
_hInst = hInst;
_hParent = parent;
}
>
protected:
HINSTANCE _hInst;
HWND _hParent;
HWND _hSelf;
};
....
Well, after I looked at the CreateWindowEx API on MSDN,
the last parameter requires a pointer to "CREATESTRUCT", "this " is
absolutely not typeof(CREATESTRUCT*).
johanatan
Guest
 
Posts: n/a
#6: Dec 24 '07

re: access conflict with (LPVOID)this in CreateWindowEx


On Dec 23, 9:23 pm, Young <myfriend...@gmail.comwrote:
Quote:
Mm,after I send the last message,I suddenly notice that the last param
in CreateWindowEx should point to a CREATESTRUCT struct.But if so, I
have no idea to make it point to the CREATESTRUCT struct.How to do
that?
Declare a struct like so:

CREATESTRUCT cs;

then fill in the members of cs like:

cs.x = y;
cs.a = b;
....

then pass "&cs" as the last param.
Young
Guest
 
Posts: n/a
#7: Dec 24 '07

re: access conflict with (LPVOID)this in CreateWindowEx


I did that,such as:
.....
CREATESTRUCT p;
p.cx=0;
p.cy=0;
p.dwExStyle=0;
p.hInstance=hInst;
p.hMenu=NULL;
p.hwndParent=NULL;
p.lpCreateParams=NULL;
p.lpszClass=(LPCWSTR)_className;
p.lpszName=TEXT("SB");
p.style=NULL;
p.x=0;
p.y=0;
_hSelf=::CreateWindowEx(
WS_EX_ACCEPTFILES,\
(LPCWSTR)_className,\
(LPCWSTR)"Web Studio 2008",\
WS_OVERLAPPEDWINDOW,\
CW_USEDEFAULT,\
CW_USEDEFAULT,\
CW_USEDEFAULT,\
CW_USEDEFAULT,\
_hParent,\
NULL,\
_hInst,\
(LPVOID)&p);
.....
But the same conflict still exists.
Where's the problem ??
johanatan
Guest
 
Posts: n/a
#8: Dec 24 '07

re: access conflict with (LPVOID)this in CreateWindowEx


On Dec 23, 11:15 pm, Young <myfriend...@gmail.comwrote:
Quote:
I did that,such as:
....
CREATESTRUCT p;
p.cx=0;
p.cy=0;
p.dwExStyle=0;
p.hInstance=hInst;
p.hMenu=NULL;
p.hwndParent=NULL;
p.lpCreateParams=NULL;
p.lpszClass=(LPCWSTR)_className;
p.lpszName=TEXT("SB");
p.style=NULL;
p.x=0;
p.y=0;
_hSelf=::CreateWindowEx(
WS_EX_ACCEPTFILES,\
(LPCWSTR)_className,\
(LPCWSTR)"Web Studio 2008",\
WS_OVERLAPPEDWINDOW,\
CW_USEDEFAULT,\
CW_USEDEFAULT,\
CW_USEDEFAULT,\
CW_USEDEFAULT,\
_hParent,\
NULL,\
_hInst,\
(LPVOID)&p);
....
But the same conflict still exists.
Where's the problem ??
One other problem I see is that your constant string "Web Studio 2008"
ought to be:

L"Web Studio 2008"

you could be causing a runaway scan since the null terminator of the
first is only one byte and the API might be looking for a double-byte
zero.
Closed Thread