Link to home
Start Free TrialLog in
Avatar of Veratil
Veratil

asked on

CreateWindowEx returns error 1400

I've looked at MSDN, and the 4 things they say to look at for CreateWindowEx failing as far as I know are false. None of the params are invalid. I highly doubt the system class is registered when I've changed the class to different names (hope I'm understanding that one right). I'm not sure if the 3rd one is true or not, this is a plugin for AstonShell, but then I look at another plugin I've made with the EXACT same code for CreateWindowEx and only this one errors. And then WM_CREATE and NCCREATE are handled by DefWindowProc. Are there any other things that can cause CreateWindowEx to return NULL? I've tried everything. If anyone wants to see the code, then I'll paste it.
Avatar of AlexFM
AlexFM

Please show your code.
Do you mean that GetLastError is 1400? This is "Invalid window handle". Possibly HWND hWndParent parameter is wrong.
Avatar of Veratil

ASKER

void WINAPI InitGlobalModule(const PAstonData AstonData)
{
  WNDCLASS WindowClass;

  if (AstonData->cbsize < sizeof(TAstonData))
    return;
  RtlMoveMemory(&AData, AstonData, sizeof(TAstonData));

  RtlZeroMemory(&WindowClass, sizeof(WNDCLASS));
  WindowClass.style = CS_HREDRAW | CS_VREDRAW;
  WindowClass.hCursor = LoadCursor(0, IDC_ARROW);
  WindowClass.hInstance = hInstance;
  WindowClass.lpfnWndProc = WindowProc;
  WindowClass.lpszClassName = szClassName;
  if (!RegisterClass(&WindowClass))
  {
    error("RegisterClass");
    return;
  }

  ReadConfig(); // this reads plugin settings

  ChildWindow = CreateWindowEx(WS_EX_TRANSPARENT, szClassName,
    NULL,
    WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
    0,
    0, 64,
    48, AData.Desktop, // AData.Desktop is a HWND in the AstonData structure, it isn't 0 because if it was other plugins wouldn't work either
    NULL,
    hInstance,
    NULL);

  if (ChildWindow == NULL)
  {
    error("CreateWindowEx");
    return;
  }

 // all after this is never executed...
  AData.Node->Wnd = ChildWindow;
  ResizeWindow();
  GetClientRect(ChildWindow, &ClientRC);
}
So, GetLastError is 1400? In this case test whether AData.Desktop is valid window handle. Use IsWindow API for this.
Avatar of Veratil

ASKER

I've tested, and it is a valid handle.

I've tracked down another small thing in the ReadConfig, but that's still not what's causing it I think. I'm doing some more tests with it.

Ok, I did a quick test before I posted. The problem in ReadConfig was for some reason causing CreateWindowEx to error. Thanks for your help, at least I figured it out. Also, is there any way I can give you some points for your time? I'd like to at least give you something for the time you've used trying to help.
ASKER CERTIFIED SOLUTION
Avatar of AlexFM
AlexFM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial