Hello everyone.
I am new to C++ and, I guess trying to pool task that is to advanced.
I have a MDI application written in PowerBuilder. One of the child windows in that application has MultiTab control with several tabs on it. What I’m trying to do is to add another tab to that window using APIs. I am getting windows information using Spy++ and until last statement everything works fine.
When I’m, actually trying to add a window, GetLatsError() returns 1407. I Googled error and from my findings it is indicates that one of the parameters is wrong.
Please, help. Thank you
Here is the code:

HWND parentWin=0,mdiWin=0,ansestWin=0,targetWin=0,resultWin;

	parentWin = FindWindow("FNWND390","TEST *** NOT PRODUCTION ***");
	mdiWin=FindWindowEx(parentWin,NULL,"MDIClient","");
	ansestWin = FindWindowEx(mdiWin,NULL,"FNWND390","Central Information");
	targetWin=FindWindowEx(ansestWin,NULL,"PBTabControl32_90","");

	
	resultWin=CreateWindowEx(
			WS_EX_LEFT || WS_EX_LTRREADING || WS_EX_RIGHTSCROLLBAR, 
			"FNUDO390", 
			"MyTabs", 
			WS_CHILDWINDOW || WS_CLIPSIBLINGS ||WS_CLIPCHILDREN, 
			1, 1, 300, 300, targetWin, NULL, hins, NULL);

	DWORD dw = GetLastError();
	if(dw!=NULL){
		char buf[16]; 
		LPCSTR psz = NULL;
		wsprintf(buf,"%d",dw);
		psz = buf; 
		int msgboxID = MessageBox(
NULL,
psz , 
"ERROR: No creation", 
MB_ICONERROR);

Recommended Answers

All 7 Replies

>>wsprintf

Are you compiling this program for UNICODE? If not, then why are you calling the unicode version of sprintf()? I know this doesn't answer your question, I don't know the answer.

Thank you for your post. I'm converting DWORD to string to display in in MessageBox

I know what that function does, but why use wsprintf() instead of sprintf()? The first argument to wspringf() is wchar_t*, not char*.

>>WS_EX_LEFT || WS_EX_LTRREADING || WS_EX_RIGHTSCROLLBAR,

That should be using the bitwise | operator, not the boolean || operator WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR,

Thank you.
After I changed my code to
>>WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR,
I have different error 1406

After calling GetLastError() I always call FormatMessage() to get the error's text

char buf[255];
DWORD dwError = GetLastError();
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0,
      dwError, 0, buf, sizeof(buf), 0);
MessageBox(NULL,buf, "",MB_OK);

If you haven't done it, make sure you also change:
WS_CHILDWINDOW || WS_CLIPSIBLINGS ||WS_CLIPCHILDREN
to
WS_CHILDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN

If you haven't done it, make sure you also change:
WS_CHILDWINDOW || WS_CLIPSIBLINGS ||WS_CLIPCHILDREN
to
WS_CHILDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN

Thank you for the response. I've done it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.