How To Create Window with CreateWindowEx ?

Miscellaneous Forums/Win32 Discussion/How To Create Window with CreateWindowEx ?

heres a c function from my max gui module thats still in development.


// The name of our window class.
TCHAR szClassName[] = TEXT("MicroMax_CLASS") ;

//
int CLASS_GOOD;

// Creates GUI Window.
int MicroMax_CreateWindow(LPCTSTR szWindowText,int x,int y,int width,int height,int group,int flags){
	
	HINSTANCE hThisInstance = GetModuleHandle(0);
	
	if(!CLASS_GOOD){
	
  		// Window class structure.
  		WNDCLASSEX wcx ;

  		// Now we must fill in the members of WNDCLASSEX.
  		wcx.hInstance     = hThisInstance;
  		wcx.lpszClassName = szClassName ;
  		wcx.lpfnWndProc   = (WNDPROC)MicoMaxWinProc;
  		wcx.style         = CS_DBLCLKS;
  		wcx.hIcon         = LoadIcon (NULL, IDI_APPLICATION);
  		wcx.hIconSm       = LoadIcon (NULL, IDI_APPLICATION);
  		wcx.hCursor       = LoadCursor (NULL, IDC_ARROW);
  		wcx.lpszMenuName  = NULL;
  		wcx.cbSize        = sizeof (WNDCLASSEX);
  		wcx.cbClsExtra    = 0;
  		wcx.cbWndExtra    = 0;
  		wcx.hbrBackground = GetSysColorBrush(COLOR_3DFACE) ;

  		// Register our window class with the operating system.
  		// If there is an error, exit program.
  		if ( !RegisterClassEx (&wcx) )
  		{
    		MessageBox( 0, TEXT("Failed to register window class!"),TEXT("Error!"), MB_OK|MB_ICONERROR ) ;
    		return 0;
  		}
		
		// class created.
		CLASS_GOOD = TRUE;
	}

	//	
	int child_window=1;

	if(!group){
		group = (int)HWND_DESKTOP;
		child_window=0;
	}else{
		child_window=1;
	}
	
	HWND hwnd = CreateWindowEx ( 0, szClassName, szWindowText, WS_OVERLAPPEDWINDOW|WS_VISIBLE, x, y, width, height,(HWND)group,  0, hThisInstance, 0 ); 
	
	if(child_window==1){
		SetParent(hwnd,(HWND)group);
	}
	
	if ( !IsWindow(hwnd) ) { 
		return 0;
	}
			
	return (int)hwnd;
	
}



kev