0

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);
3
Contributors
7
Replies
9
Views
7 Years
Discussion Span
Last Post by newToC
0

>>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.

0

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

0

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,

0

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

0

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);
0

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

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.