flat assembler
Message board for the users of flat assembler.

Index > Windows > Moving window

Author
Thread Post new topic Reply to topic
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY
Hi!
I'm building a custom GUI with bitmaps.
I already got the minimize and close bitmaps to act as buttons and minimize and close the dialog.
How can move the window when user drag a bitmap (a custom tittle bar)?
I know about MoveWindow() API, but how to actually get the current position, and then when user drag the dialog, it move?
Post 19 May 2006, 19:53
View user's profile Send private message Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost
the first thing that i can think of is GetWindowRect( ), there is also the WM_MOVE message and the low word of lParam is the x, the high word of lParam is the y, but i am not sure if this can move with SendMessage( ) or is simply a notification

_________________
redghost.ca
Post 19 May 2006, 20:20
View user's profile Send private message AIM Address MSN Messenger Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY
Thanks, I think it will work!
WM_MOVE must be the notification message. If x and y are in lParam, I can then use MoveWindow() API to move the window.
Although I have no idea on how to implement this, it seems that it's the way...
Post 19 May 2006, 21:09
View user's profile Send private message Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav
try this (masm):

Code:
...

        cmp             ax,WM_MOUSEMOVE
        jz              @@wmmousemove

...

  @@wmmousemove:
        invoke  _domove,[hWnd]  
        jmp             @@processed     

...

_domove proc hWnd:dword
        local   pt:POINT
        local   rct:RECT
        
        lea             esi,[pt]
        invoke  GetCursorPos,esi
        lea             edi,[rct]
        invoke  GetWindowRect,[hWnd],edi
        
        mov             eax,[pt.x]
        sub             eax,[ptmove.x]
        add             eax,[rct.left]
        
        mov             edx,[pt.y]
        sub             edx,[ptmove.y]
        add             edx,[rct.top]
        
        m2m             [ptmove.x],[pt.x]
        m2m             [ptmove.y],[pt.y]
        
        mov             ecx,[rct.right]
        sub             ecx,[rct.left]
        
        mov             ebx,[rct.bottom]
        sub             ebx,[rct.top]
        
        invoke  MoveWindow,[hWnd],eax,edx,ecx,ebx,TRUE
        ret
_domove endp
    
Post 20 May 2006, 06:09
View user's profile Send private message Reply with quote
WytRaven



Joined: 08 Sep 2004
Posts: 45
Location: Canberra, Australia
WytRaven
In your message handling loop catch mouse down events (WM_LBUTTONDOWN) and check if the pointer is within the area of your 'title bar' if it is then post a WM_NCLBUTTONDOWN event to the window specifiying that the button is down on the real (and nonexistant) title bar (HTCAPTION) using SendMessage API. the OS will do the rest.

eg. SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, NULL)

I hope that made sense Smile

_________________
All your opcodes are belong to us
Post 01 Jun 2006, 03:51
View user's profile Send private message Reply with quote
OzzY



Joined: 19 Sep 2003
Posts: 1029
Location: Everywhere
OzzY
Thanks WytRaven!
Your way is the easiest and works!


Description: Here is a simple GUI I made using this method
Filesize: 12.64 KB
Viewed: 873 Time(s)

simple_gui.jpg


Post 01 Jun 2006, 18:52
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.