jennico Posted September 5, 2010 Posted September 5, 2010 hi there i wonder why this has not been asked before: i want to add a size grip to a sizable GUI ($WS_SIZEBOX) without statusbar. can anyone give me an example ? all i can do is just guess: i need a WM_PAINT event or is it WM_NCHITTEST ? the function should be: Func DrawFrameControl($hDC, $nLeft, $nTop, $nRight, $nBottom, $nType, $nState) Local Const $DFC_SCROLL = 3,$DFCS_SCROLLSIZEGRIP = 8 Local $stRect = DllStructCreate("int;int;int;int") DllStructSetData($stRect, 1, $nLeft) DllStructSetData($stRect, 2, $nTop) DllStructSetData($stRect, 3, $nRight) DllStructSetData($stRect, 4, $nBottom) DllCall("user32.dll", "int", "DrawFrameControl", "hwnd", $hDC, "ptr", DllStructGetPtr($stRect), "int", $DFC_SCROLL, "int", $DFCS_SCROLLSIZEGRIP) $stRect = 0 EndFunc ;==>DrawFrameControl so the size grip is originally a scrollbar element. but what would be the device context (the window ?), and what is the rectangle (client size bottom right 16 x 16 ?)in this case ? (btw: on the other hand, one could simply place an icon, but where to find it ?) can anyone provide a working example using DrawFrameControl ? thx j. Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96
fireryblaze Posted September 6, 2010 Posted September 6, 2010 (edited) #include <WindowsConstants.au3> #Include <WinAPI.au3> Opt("TrayIconDebug", 1) $Gui = GUICreate("", default, default, default, default, $WS_SIZEBOX) $DC = _WinAPI_GetDC($Gui) GUISetState() DrawFrameControl($DC, 10,10,100,100) while 1 WEnd Func DrawFrameControl($hDC, $nLeft, $nTop, $nRight, $nBottom) Local Const $DFC_SCROLL = 3,$DFCS_SCROLLSIZEGRIP = 8 Local $stRect = DllStructCreate("int;int;int;int") DllStructSetData($stRect, 1, $nLeft) DllStructSetData($stRect, 2, $nTop) DllStructSetData($stRect, 3, $nRight) DllStructSetData($stRect, 4, $nBottom) DllCall("user32.dll", "int", "DrawFrameControl", "hwnd", $hDC, "ptr", DllStructGetPtr($stRect), "int", $DFC_SCROLL, "int", $DFCS_SCROLLSIZEGRIP) MsgBox(0, "", @error) $stRect = 0 EndFunc ;==>DrawFrameControlI leave the rest to you...PS ALOT of icons can be found within various dll's...Also you can make your own.http://www.glennslayden.com/code/win32/shell32-dll-iconsor go here and get a 30 day free trial of an excellent toolhttp://www.gdgsoft.com/download/gconvert.aspx Edited September 6, 2010 by fireryblaze
jennico Posted September 6, 2010 Author Posted September 6, 2010 $DC = _WinAPI_GetDC($Gui) ....so easy, can't believe it, thanx j. Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96
ProgAndy Posted September 6, 2010 Posted September 6, 2010 (edited) You really should put the drawing in WM_PAINT. Then it won't disappear expandcollapse popup#include<WindowsConstants.au3> #include<GUIConstantsEx.au3> Global $hGUI = GUICreate("Sizetest", default, default, default, default, $WS_SIZEBOX) GUIRegisterMsg($WM_PAINT, "_MY_WM_PAINT") GUISetState() While GUIGetMsg()<>-3 WEnd Func _MY_WM_PAINT($hWnd, $uMsg, $wParam, $lParam) ; Init paint Local $tPS = DllStructCreate("ptr hdc; BOOL fErase;long rcPaint[4]; BOOL fRestore; BOOL fIncUpdate; BYTE rgbReserved[32];") Local $aPaint = DllCall("user32.dll", "handle", "BeginPaint", "hwnd", $hWnd, "ptr", DllStructGetPtr($tPS)) If @error Then Return $GUI_RUNDEFMSG Local $hDC = $aPaint[0] ; Draw Local $pos = WinGetClientSize($hWnd) DrawFrameControl($hDC, $pos[0]-10, $pos[1]-10, $pos[0], $pos[1]) ; Finish Paint DllCall("user32.dll", "bool", "EndPaint", "hwnd", $hWnd, "ptr", $aPaint[2]) Return $GUI_RUNDEFMSG EndFunc Func DrawFrameControl($hDC, $nLeft, $nTop, $nRight, $nBottom) Local Const $DFC_SCROLL = 3,$DFCS_SCROLLSIZEGRIP = 8 Local $stRect = DllStructCreate("int;int;int;int") DllStructSetData($stRect, 1, $nLeft) DllStructSetData($stRect, 2, $nTop) DllStructSetData($stRect, 3, $nRight) DllStructSetData($stRect, 4, $nBottom) DllCall("user32.dll", "int", "DrawFrameControl", "hwnd", $hDC, "ptr", DllStructGetPtr($stRect), "int", $DFC_SCROLL, "int", $DFCS_SCROLLSIZEGRIP) $stRect = 0 EndFunc ;==>DrawFrameControl Edited September 6, 2010 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
jennico Posted September 6, 2010 Author Posted September 6, 2010 (edited) hmm i made it with WM_NCHITTEST . #include <WindowsConstants.au3> ;#Include <WinAPI.au3> Global Const $DFC_SCROLL = 3,$DFCS_SCROLLSIZEGRIP = 8 $Gui = GUICreate(" Size Grip Window", 400, 300, default, default, $WS_SIZEBOX) GUIRegisterMsg($WM_NCHITTEST , "DrawFrameControl") GUISetState() Do Sleep(20) Until GUIGetMsg() = -3 Func DrawFrameControl($hWndGUI, $MsgID, $WParam, $LParam) Local $stRect = DllStructCreate("int;int;int;int") Local $stSize = WinGetClientSize($hWndGUI) Local $hDC = DllCall("User32.dll", "hwnd", "GetDC", "hwnd", $hWndGUI) DllStructSetData($stRect, 1, $stSize[0] - 16) DllStructSetData($stRect, 2, $stSize[1] - 16) DllStructSetData($stRect, 3, $stSize[0]) DllStructSetData($stRect, 4, $stSize[1]) DllCall("user32.dll", "int", "DrawFrameControl", "hwnd", $hDC[0], "ptr", DllStructGetPtr($stRect), "int", $DFC_SCROLL, "int", $DFCS_SCROLLSIZEGRIP) DllCall("User32.dll", "int", "ReleaseDC", "hwnd", $hWndGUI, "hwnd", $hDC[0]) $stRect = 0 EndFunc ;==>DrawFrameControl seems the same. j edit: @progandy: _MY_WM_PAINT does not work for me (xpsp3) Edited September 6, 2010 by jennico Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96
ProgAndy Posted September 6, 2010 Posted September 6, 2010 You need the current version of AutoIt. Do you have it? *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
jennico Posted September 6, 2010 Author Posted September 6, 2010 (edited) i admit, no. does this matter ? wm_paint was working before, didn't it ? Edited September 6, 2010 by jennico Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96
ProgAndy Posted September 6, 2010 Posted September 6, 2010 DLLCall and DLLStructCreate have got new types wich I'm using. You have to change them to the old ones (bool -> int, handle -> ptr, ...) *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
jennico Posted September 6, 2010 Author Posted September 6, 2010 (edited) ok, this is a sizing window with custom status bar (much easier than the system statusbar) and custom size grip. expandcollapse popup#include <WindowsConstants.au3> ;#Include <WinAPI.au3> Global Const $DFC_SCROLL = 3,$DFCS_SCROLLSIZEGRIP = 8 $Gui = GUICreate(" Size Grip Window", 400, 300, default, default, $WS_SIZEBOX) $size=WinGetClientSize($Gui) GUICtrlCreateLabel("", 0, $size[1] - 18, $size[0], 18, -1, $WS_EX_STATICEDGE) GUICtrlSetResizing(-1, 582) GUIRegisterMsg($WM_NCHITTEST , "DrawFrameControl") GUISetState() DrawFrameControl($Gui, 0, 0, 0) Do Sleep(20) Until GUIGetMsg() = -3 Func DrawFrameControl($hWndGUI, $MsgID, $WParam, $LParam) Local $stRect = DllStructCreate("int;int;int;int") Local $stSize = WinGetClientSize($hWndGUI) Local $hDC = DllCall("User32.dll", "hwnd", "GetDC", "hwnd", $hWndGUI) DllStructSetData($stRect, 1, $stSize[0] - 17) DllStructSetData($stRect, 2, $stSize[1] - 17) DllStructSetData($stRect, 3, $stSize[0] - 1) DllStructSetData($stRect, 4, $stSize[1] - 1) DllCall("user32.dll", "int", "DrawFrameControl", "hwnd", $hDC[0], "ptr", DllStructGetPtr($stRect), "int", $DFC_SCROLL, "int", $DFCS_SCROLLSIZEGRIP) DllCall("User32.dll", "int", "ReleaseDC", "hwnd", $hWndGUI, "hwnd", $hDC[0]) $stRect = 0 EndFunc ;==>DrawFrameControl very nice, looks just like explorer. now this has been done with AutoIt thx again, j. edit: $WM_EXITSIZEMOVE = 0x0232 would probably be the most correct event. Edited September 6, 2010 by jennico Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now