![]() ![]() a task like this should be done in the WndProc(), as the message queue could block, and your solution could temporarily stop working. i dont really know why you are transfering a flag like that, when the messages offer all the information you need. Your margin for detecting the mouse-over corner is pretty off. dragging the window by clicking anywhere in the client area, might not be the desired effect either. you cant double-click on the titlebar area, to maximize the window, because you dont have a designated titlebar area. people could have multiple monitors, and re-adjusting the window might not be the desired effect.Īlso your implementation is missing a context menu, and the possibility to minimize, maximize, and restore the window. Snapping should happen during the movement of the window, and not after. SendMessage_(hWnd, #WM_SYSCOMMAND, #SC_DnLeftsize,0) SendMessage_(hWnd, #WM_SYSCOMMAND, #SC_UpRightsize,0) SetCursor_(LoadCursor_(0, #IDC_SIZENESW)) SendMessage_(hWnd, #WM_SYSCOMMAND, #SC_DnRightsize,0) SendMessage_(hWnd, #WM_SYSCOMMAND, #SC_UpLeftsize,0) SetCursor_(LoadCursor_(0, #IDC_SIZENWSE)) SendMessage_(hWnd, #WM_SYSCOMMAND, #SC_Rightsize,0) SendMessage_(hWnd, #WM_SYSCOMMAND, #SC_Leftsize,0) SendMessage_(hWnd, #WM_SYSCOMMAND, #SC_Dnsize,0) SendMessage_(hWnd, #WM_SYSCOMMAND, #SC_Upsize,0) SendMessage_(hWnd, #WM_SYSCOMMAND, #SC_DragMove,0) If mx > r\left sww And mx r\top-sw And my r\left sww And mx r\bottom-sw And my r\left-sw And mx r\top sww And my r\right-sw And mx r\top sww And my r\left-sw And mx r\top-sw And my r\right-sw And mx r\bottom-sw And my r\right-sw And mx r\top-sw And my r\left-sw And mx r\bottom-sw And my 0 If r\top h >= (mi\rcWork\bottom - snap): r\top = mi\rcWork\bottom - h 2 : EndIf If mi\rcWork\top snap > r\top : r\top = mi\rcWork\top - 2 : EndIf If r\left w >= (mi\rcWork\right - snap): r\left = mi\rcWork\right - w 2: EndIf If mi\rcWork\left snap > r\left : r\left = mi\rcWork\left - 2: EndIf Hmon = MonitorFromWindow_(hWnd,#MONITOR_DEFAULTTONEAREST) Global hwnd,r.RECT,hmon,mi.MONITORINFO,x,y,w,h,snap MessageRequester("Info","Unicode compiler option not set",#MB_ICONINFORMATION) Shorter variable names is here recommended as the Procedure line is becoming very long, but this is up to you. PokeI(*x_retval_height, rect\bottom-rect\top) PokeI(*x_retval_width, rect\right-rect\left) *** returns coordinates and size of window exterior Global x_retval_x.i, x_retval_y.i, x_retval_width.i, x_retval_height.i Procedure x_window_exteriorsize(window_nr.i,*x_retval_x.integer,*x_retval_y.integer,*x_retval_width.integer,*x_retval_height.integer) returns exterior size for specifed window ProcedureReturn GetSystemMetrics_(#SM_CYCAPTION) note: this routine does NOT check if the dragbar exists or not, it just returns the getsystemmetrics_(#sm_cycaption) result If WindowWidth(winID)Window("clientwidth") Or WindowHeight(winID)Window("clientheight")Ĭode: Select all Procedure.i x_dragbarheight() returns default size of dragbar aka caption winID=OpenWindow(#PB_Any,0,0,400,200,"Calculate the Window Title Height - test", #PB_Window_SystemMenu| #PB_Window_SizeGadget |#PB_Window_Tool |#PB_Window_ScreenCentered) try on different window type WinID=OpenWindow(#PB_Any,0,0,400,200,"Calculate the Window Title Height - test",#PB_Window_MinimizeGadget | #PB_Window_SizeGadget |#PB_Window_ScreenCentered) ![]() Mess6.s="Window Title Height Calculation = " Str(Window("titleheight")) Mess5.s="Window Border Calculation = " Str(Window("border")) Mess4.s=" ClientWidth=" Str(Window("clientwidth")) Mess3.s="Window Data: WindowWidth=" Str(Window("width")) Mess2.s=" ClientHeight=" Str(Window("clientheight")) Mess1.s="Window Data: WindowHeight=" Str(Window("height")) ![]() Window("titleheight")=Window("height")-Window("clientheight")-Window("border") Window("border")=(Window("width")-Window("clientwidth"))/2 Window("clientheight")=Client\Bottom-Client\Top Window("clientwidth")=Client\Right-Client\Left assumption that border left= border right=border bottom. Procedure.s Window_Stats(hwnd) get window stats including calculation for title height needed for window mask usable across different window types, computers
0 Comments
Leave a Reply. |