Thread: Showing a window from inside a DLL

  1. #1
    Registered User Rare177's Avatar
    Join Date
    May 2004
    Posts
    214

    Showing a window from inside a DLL

    im trying to show a window from inside of a dll and i am doing it like this

    Code:
    int WINAPI CreateWindows(HINSTANCE , HINSTANCE , LPSTR , int);
    Global^

    Code:
    CreateWindows(GetModuleHandle(0), NULL, NULL , NULL);
    ^calling from a certain part of the dll

    Code:
    int WINAPI CreateWindows(HINSTANCE hInstance, HINSTANCE hPrevInstance , LPSTR szCmdLine, int iCmdShow)
    {
    	char szAppName[] = "tabs";
    
    	MSG msg;
    	WNDCLASSEX wc;
    
    	TCITEM tabs;
    	INITCOMMONCONTROLSEX iccx;
    
    	wc.style = CS_DBLCLKS;
    	wc.lpfnWndProc = WndProc;
    	wc.cbSize = sizeof(WNDCLASSEX);
    	wc.cbClsExtra = 0;
    	wc.cbWndExtra = 0;
    	wc.hInstance = hInstance;
    	wc.hbrBackground = CreateSolidBrush(GetSysColor(COLOR_3DFACE));
    	wc.hIcon = LoadIcon(NULL , IDI_APPLICATION);
    	wc.hCursor = LoadCursor(NULL , IDC_ARROW);
    	wc.lpszClassName = szAppName;
    	wc.lpszMenuName = NULL;
    
    	if(!RegisterClassEx(&wc)) MessageBox(0 , "Error" , "error" , 0);
    
    	iccx.dwSize = sizeof(INITCOMMONCONTROLSEX);
    	iccx.dwICC = ICC_TAB_CLASSES;
    	InitCommonControlsEx(&iccx);
    
    	hwnd = CreateWindowEx(0 , szAppName , "Logs" ,
    				WS_OVERLAPPEDWINDOW ,
    				CW_USEDEFAULT , CW_USEDEFAULT,
    				CW_USEDEFAULT , CW_USEDEFAULT,
    				NULL , NULL , hInstance , NULL);
    
    	hwndTab = CreateWindowEx(0 , WC_TABCONTROL , NULL,
    				WS_VISIBLE | WS_CHILD | TCS_FIXEDWIDTH ,
    				0 , 0 , 0 , 0 ,
    				hwnd , 
    				NULL , 
    				(HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), 
    				NULL);
    
    	UpdateWindow(hwnd);
    	ShowWindow(hwnd , SW_SHOW);
    
    	ZeroMemory(&tabs, sizeof(TCITEM));
    
    	tabs.mask=TCIF_TEXT;
    	tabs.pszText= "Log";
    	tabs.cchTextMax = strlen(tabs.pszText);
    	SendMessage(hwndTab, TCM_INSERTITEM, 0, (LPARAM)&tabs);
    
    	tabs.pszText = "Proccessed Packets";
    	tabs.cchTextMax = strlen(tabs.pszText);
    	SendMessage(hwndTab, TCM_INSERTITEM, 1, (LPARAM)&tabs);
    	SendMessage(hwndTab, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
    
    	while(GetMessage(&msg , NULL , 0 , 0)){
    		TranslateMessage(&msg);
    		DispatchMessage(&msg);
    	}
    
    	return msg.wParam;
    }
    the function to do the rest^

    the problem is it is not registering the window class, does any one know why this is, im thinking it is because i am using NULL's in the function parameters but i couldnt think of another way,

    thanks
    Last edited by Rare177; 10-08-2004 at 01:52 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 10:17 AM
  2. Adding colour & bmps to a Win 32 Window??
    By carey_sizer in forum Windows Programming
    Replies: 4
    Last Post: 09-04-2004, 05:55 PM
  3. Window not showing
    By Rare177 in forum Windows Programming
    Replies: 7
    Last Post: 06-25-2004, 05:38 AM
  4. opening a dialog window from inside a dialog window
    By uvacow in forum C++ Programming
    Replies: 1
    Last Post: 12-02-2002, 09:27 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM