Search code examples
createwindow

CreateWindow coordinates are limited to 32767?


How I can create child window with coordinates that are larger than 32767? For example:

HWND tmp = 
CreateWindow(
    _T( "BUTTON" ), _T( "Test" ),
    WS_CHILD | WS_VISIBLE,
    10, 45000, 80, 25,
    hWnd, (HMENU)1, (HINSTANCE)GetModuleHandle( NULL ), NULL );

This code creates button with coordinates 10;32767. Using of MoveWindow or SetWindowPos functions give same result.

I need to create window with scroll and child controls on it (simple form).


Solution

  • HWND CreateWindowExPatched( DWORD exStyle, LPCTSTR className, LPCTSTR title, DWORD style, int x, int y, int width, int height, HWND parent, HMENU menu, HINSTANCE instance, LPVOID param )
    {
        HWND hWnd = NULL;
    
        ScrollWindow( parent, -x, -y, NULL, NULL );
        hWnd = CreateWindowEx( exStyle, className, title, style, 0, 0, width, height, parent, menu, instance, param );
        ScrollWindow( parent, x, y, NULL, NULL );
    
        return hWnd;
    }
    
    HWND CreateWindowPatched( LPCTSTR className, LPCTSTR title, DWORD style, int x, int y, int width, int height, HWND parent, HMENU menu, HINSTANCE instance, LPVOID param )
    {
        return CreateWindowExPatched( 0, className, title, style, x, y, width, height, parent, menu, instance, param );
    }