The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Nordwind64 on February 16, 2006, 11:00:32 PM

Title: Fixing a window
Post by: Nordwind64 on February 16, 2006, 11:00:32 PM
Hi,

what's the best way to fix a window agains moving by the user?

Best regards,
Nordwind64
Title: Re: Fixing a window
Post by: zooba on February 16, 2006, 11:27:03 PM
Probably to intercept WM_MOVING and return TRUE (indicating that you've handled it). Though I haven't tried this before.
Title: Re: Fixing a window
Post by: Tedd on February 17, 2006, 01:00:22 PM
Nope, that doesn't work. Neither does WM_MOVE.

The following is a bit of a hack, but it does work. It causes the titlebar to be seen as the client area, but the buttons still work. You can easily add extra checks to prevent sizing, etc - if you need to.

WndProc proc hwnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
    mov eax,uMsg
    .IF (eax==WM_NCHITTEST)
        invoke DefWindowProc, hwnd,uMsg,wParam,lParam    ;this will return the HT_ value for where the pointer currently is
        .IF (eax==HTCAPTION)
            mov eax,HTCLIENT    ;if it's on the caption, say it's on the client-area
        .ENDIF
        ret
    .
    .
    .

Title: Re: Fixing a window
Post by: Nordwind64 on February 18, 2006, 04:42:06 PM
Hi,

I tried WM_MOVE and WM_MOVING before. Don't work.
Tedd, the close button don't work with your solution. And I can open system menu and move window from there. Sorry.

What about removing "Move window" from system menu? Could that work?
Title: Re: Fixing a window
Post by: Nordwind64 on February 18, 2006, 06:12:23 PM
Hehe, found the solution:

   
.elseif uMsg==WM_MOVING
  invoke ReleaseCapture
  mov eax,FALSE
  ret


Best regards,
Nordwind64