Thread: CreateWindowEx and last parameter..

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    132

    CreateWindowEx and last parameter..

    Can someone explain the use of the last parameter in the CreateWindowEx, called void* pParam or something like that?
    I believe it is used to pass a pointer to be used with the WndProcedure, but im not sure. And if thats the case, I really need it.. But how do we use it?
    Y3K Network http://www.y3knetwork.com
    Bringing the software of the future on the net.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Check the docs: CreateWindow()

    gg

  3. #3
    Registered User
    Join Date
    Jun 2002
    Posts
    132
    Very.. informative.. I've been there many times, thanks. Anything else?
    Y3K Network http://www.y3knetwork.com
    Bringing the software of the future on the net.

  4. #4
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Quote Originally Posted by aker_y3k
    Can someone explain the use of the last parameter in the CreateWindowEx, called void* pParam or something like that?
    I believe it is used to pass a pointer to be used with the WndProcedure, but im not sure. And if thats the case, I really need it.. But how do we use it?
    Quote Originally Posted by Codeplug
    Check the docs: CreateWindow()

    gg
    Quote Originally Posted by msdn, CreateWindow, last parameter
    pParam
    [in] Pointer to a value to be passed to the window through the CREATESTRUCT structure passed in the lpParam parameter the WM_CREATE message. If an application calls CreateWindow to create a multiple-document interface (MDI) client window, lpParam must point to a CLIENTCREATESTRUCT structure.
    Quote Originally Posted by msdn,CREATESTRUCT,lpCreateParam
    Contains additional data which may be used to create the window. If the window is being created as a result of a call to the CreateWindow or CreateWindowEx function, this member contains the value of the lpParam parameter specified in the function call.
    Quote Originally Posted by aker_y3k
    Very.. informative
    Indeed it is.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  5. #5
    Registered User r1ck0r's Avatar
    Join Date
    Apr 2005
    Location
    UK
    Posts
    30
    Here's a quick example of how to use the last parameter,

    Code:
    #include <windows.h>
    
    LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
        switch(msg)
        {
    	case WM_CREATE:
    		{
    			CREATESTRUCT *cs = (CREATESTRUCT*)lParam;
    			MessageBox(0,(char*)cs->lpCreateParams,"",0);
    			delete[] cs->lpCreateParams;
    			return 0;
    		}
    	case WM_CLOSE:
    		DestroyWindow(hwnd); break;
    	case WM_DESTROY:
    		PostQuitMessage(0);  break;
    	default:
                return DefWindowProc(hwnd, msg, wParam, lParam);
        }
        return 0;
    }
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
        LPSTR lpCmdLine, int nCmdShow)
    {
        WNDCLASSEX wc;
        HWND hwnd;
        MSG Msg;
    
        wc.cbSize        = sizeof(WNDCLASSEX);
        wc.style         = 0;
        wc.lpfnWndProc   = WndProc;
        wc.cbClsExtra    = 0;
        wc.cbWndExtra    = 0;
        wc.hInstance     = hInstance;
        wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
        wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
        wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
        wc.lpszMenuName  = NULL;
        wc.lpszClassName = "WindowCls";
        wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
    
        if(!RegisterClassEx(&wc))
            return 0;
    
    	char * passValue = new char[10];
    	strcpy(passValue,"hello...");
    
        hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, "WindowCls", "Window", WS_OVERLAPPEDWINDOW,
            CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, NULL, NULL, hInstance, passValue);
    
        if(hwnd == NULL)
            return 0;
    
        ShowWindow(hwnd, nCmdShow);
        UpdateWindow(hwnd);
    
        while(GetMessage(&Msg, NULL, 0, 0) > 0)
        {
            TranslateMessage(&Msg);
            DispatchMessage(&Msg);
        }
        return Msg.wParam;
    }
    Seriously though, the information was right there, all you had to do was read it.

    -r1ck0r

  6. #6
    Registered User
    Join Date
    Jun 2002
    Posts
    132
    Ah, thanks.
    I read it, but didn't understand it.
    Y3K Network http://www.y3knetwork.com
    Bringing the software of the future on the net.

Popular pages Recent additions subscribe to a feed