Pwindowinfo

This is a discussion on Pwindowinfo within the Windows Programming forums, part of the Platform Specific Boards category; I am trying to use the GetWindowInfo() call such as follows: Code: RECT rect; PWINDOWINFO pwi; GetClientRect(hWnd, &rect); GetWindowInfo(hwndButton[0], pwi); ...

  1. #1
    Unregistered
    Guest

    Pwindowinfo

    I am trying to use the GetWindowInfo() call such as follows:
    Code:
    RECT rect;
    PWINDOWINFO pwi;
    
    GetClientRect(hWnd, &rect);
    
    GetWindowInfo(hwndButton[0], pwi);
    MoveWindow(...)
    but the VC++ 6.0 compiler complains with this:

    D:\WatchFile.cpp(650) : error C2065: 'PWINDOWINFO' : undeclared identifier
    D:\WatchFile.cpp(650) : error C2146: syntax error : missing ';' before identifier 'pwi'
    D:\WatchFile.cpp(650) : error C2065: 'pwi' : undeclared identifier

    I have included "windows.h" and am linking with User32.lib (just as MSDN says to).

    I have looked at winuser.h. PWINDOWINFO is in there. Google doesn't have any references that help.

    Does anyone have any suggestions?

    Thanks in advance

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    That API doesnt appear in the docs that come with VC++6....but it does appear in the SDK from last November......

    Your best bet is to download the new SDK....but if you really cant wait all the time needed to download it.......try include the bold code I have put in the following example at the top of your code;



    Code:
    #include <windows.h>
    
    typedef struct tagWINDOWINFO {
        DWORD cbSize;
        RECT  rcWindow;
        RECT  rcClient;
        DWORD dwStyle;
        DWORD dwExStyle;
        DWORD dwWindowStatus;
        UINT  cxWindowBorders;
        UINT  cyWindowBorders;
        ATOM  atomWindowType;
        WORD  wCreatorVersion;
    } WINDOWINFO, *PWINDOWINFO, *LPWINDOWINFO;
    
    typedef BOOL (WINAPI *GETWINDOWINFO)(
      HWND hwnd,      
      PWINDOWINFO pwi
    );
    
    
    BOOL GetWindowInfo(HWND hwnd,PWINDOWINFO pwi){
    	
    	HMODULE hMod;
    
    	hMod = LoadLibrary("User32.dll");
    	if(!hMod)return FALSE;
    	GETWINDOWINFO lpfgwi = (GETWINDOWINFO)GetProcAddress(hMod,
    		"GetWindowInfo");
    	if(!lpfgwi)return FALSE;
    	FreeLibrary(hMod);
    	return lpfgwi(hwnd,pwi);
    }
    
    int main()
    {
    	WINDOWINFO wi;
    
    
    	HWND hwnd = GetDesktopWindow();
    
    	BOOL bRes = GetWindowInfo(hwnd,&wi);//simple example
    	
    
    	return 0;
    }

  3. #3
    Unregistered
    Guest
    Thanks Fordy, that works.

    If I may, a couple more questions.

    Is this now an unsupported API, or did MS just forget to define these items for VC 6?

    When I run that example on my system, the cbSize field is 3435973836. MSDN says this value is the size, in bytes, of the structure. Surely this isn't the actual size?

    Thanks again.

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Originally posted by Unregistered
    Thanks Fordy, that works.

    If I may, a couple more questions.

    Is this now an unsupported API, or did MS just forget to define these items for VC 6?
    No they are supported...its just that they werent published in the SDK that comes with VC++6......they were included in User32.dll for versions Win98 onwards......so you can use them for those platforms...

    Its a good idea to download the new SDKs........these things do date after a while


    Originally posted by Unregistered
    When I run that example on my system, the cbSize field is 3435973836. MSDN says this value is the size, in bytes, of the structure. Surely this isn't the actual size?

    Thanks again.
    Ah...good point!....you should set the cbSize to sizeof(WINDOWINFO) before calling the function.......I forgot to warn you...

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21