Jump to content
alogrep

Range check error (10016) on SetWindowLong

Recommended Posts

Hi.

I get the subject error  on this line of code

SetWindowLong(thisform.Handle, GWL_STYLE,
         WS_POPUP or WS_CLIPSIBLINGS or WS_CLIPCHILDREN or WS_SYSMENU);

The peculiar thing is I get it in one application but not in another application (they both use the identical code and "thisform")

I traced it with Ctrl+F7  and this is the sequence that produces th error. Any help, please?

SetWindowLong(thisform.Handle, GWL_STYLE,
         WS_POPUP or WS_CLIPSIBLINGS or WS_CLIPCHILDREN or WS_SYSMENU);


function TWinControl.GetHandle: HWND;
begin
  HandleNeeded;
  Result := WindowHandle;
end;

procedure _BoundErr;
{$IFDEF PUREPASCAL}
begin
  ErrorAt(Byte(reRangeError), ReturnAddress);
end;
{$ELSE !PUREPASCAL}
{$IFDEF CPUX86}
asm
        MOV     AL,reRangeError
        JMP     Error
end;

procedure Error(errorCode: TRuntimeError);
begin
  ErrorAt(Byte(errorCode), ReturnAddress);
end;

 

Share this post


Link to post

Type-cast the 3rd parameter:

SetWindowLong(thisform.Handle, GWL_STYLE,
         LONG(WS_POPUP or WS_CLIPSIBLINGS or WS_CLIPCHILDREN or WS_SYSMENU));

Though, SetWindowLong() has been deprecated for a long time, as it doesn't support 64-bit apps.  You really should be using SetWindowLongPtr() instead:

SetWindowLongPtr(thisform.Handle, GWL_STYLE,
         LONG_PTR(WS_POPUP or WS_CLIPSIBLINGS or WS_CLIPCHILDREN or WS_SYSMENU));

 

 

Edited by Remy Lebeau

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×