Trotz intensiver Suche ist es mir nicht gelungen ein
Beispiel zu finden, indem ein Static Control mit der
Maus verschoben wird. Allgemein funktioniert die
Releasecapture - Methode nur für Controls, die den Focus haben.
Controls ohne Focus (Static, Groupbox etc) lassen sich so nicht
verschieben.:( Wer kann mir ein Beispiel machen
Control verschieben
-
-
-
Code
Alles anzeigenDEF &WM_DESTROY $2 DEF &WM_NCHITTEST $84 Def &WM_NCLBUTTONDOWN $0A1 Def &HTCAPTION $02 Def ReleaseCapture(0) !"USER32","ReleaseCapture" Def SetCapture(1) !"USER32","SetCapture" $P+ SetErrorLevel 0 $I C:\PRFEllow\lib\Profalt.inc $I C:\PRFELLOW\LIB\WFFORMS7.INC $I C:\PRFELLOW\LIB\WFEVENTS.INC $I C:\PRFELLOW\LIB\WFUPDOWN.INC ' *** GlobalStatements der Form $H windows.ph $H messages.ph proc Moveobject Parameters Ohwnd& setcapture(Ohwnd&) while 1 ReleaseCapture() SendMessage (Ohwnd&,~WM_NCLButtonDown,&HTCAPTION,0) Break wend endproc Declare appexit% SetTrueColor 1 WindowStyle $003F WindowTitle "Spinedit anklicken und verschieben " Window Add(%maxX,5),114 - 771,611 Cls GetSysColor(15) UseFont "MS Sans Serif",13,0,0,0,0 SetDialogFont 1 SetFormIcon "",0 Var editspin1&=CreateEdit(%hwnd,"",110,330,121,22) var SpinEdit1&=CreateSpinEdit($54000026,0,0,0,0,%hwnd,2004,%hinstance,editspin1&,100,0,10) var BuddySpinEdit1&=UDM_GetBuddy(SpinEdit1&) Var spin2&=Create("SpinEdit",%HWnd,"0;-100;100",110,380,121,22) SetWindowPos %hwnd = 207,114 - 771,611;0 WhileNot appexit% WaitInput WMNotifyHandler If Equ(%key,2) Let appexit%=1 ElseIf Getfocus(EditSpin1&) Moveobject SpinEdit1& ElseIf Getfocus(SpinEdit1&) Moveobject Editspin1& ElseIf Getfocus(spin2&) Moveobject spin2& ElseIf Equ(%key,4) ElseIf Equ(%key,5) ' Hilfe EndIf Wend
-
Mir fehlen die PrfFellows, konnte nicht testen. Aber die HTCAPTION-Lösung funktioniert fast überall.
-
Statics müssen den richtigen Stil haben, damit sie Meldungen weitergeben.
Code
Alles anzeigen$H windows.ph $H messages.ph Declare appexit% WindowStyle $003F WindowTitle "anklicken und verschieben " Window 207,114 - 771,611 Cls ~GetSysColor(15) UseFont "MS Sans Serif",13,0,0,0,0 SetDialogFont 1 Var Text& = Create("Text",%hwnd,"veschieb mich",10,10,100,24) '################################# 'STATIC MUSS ~SS_NOTIFY STIL HABEN '################################# SetStyle Text&,GetStyle(Text&) | ~SS_NOTIFY '################################# WhileNot appexit% WaitInput If %key = 2 Dispose hdr# appexit%=1 Endif If (%message = ~WM_COMMAND) AND (&lParam = Text&) UseCursor 5 ~ReleaseCapture() SendMessage(&lParam,~WM_SYSCOMMAND,~SC_MOVE+1,0) UseCursor 0 EndIf EndWhile
-
Danke Andreas !
Wer lesen kann ist echt im Vorteil
Ausschnitt aus Platform SDK:
Zitat
Applications often use static controls to label other controls or to separate a group of controls. Although static controls are child windows, they cannot be selected. Therefore, they cannot receive the keyboard focus and cannot have a keyboard interface. A static control that has the SS_NOTIFY style receives mouse input, notifying the parent window when the user clicks or double clicks the control. -
Static Funktioniert .
Groupbox geht nicht.
-
Zitat von Ralph Theobald;854236
Static Funktioniert .
Groupbox geht nicht.
Eine Groupbox ist ja auch kein Static sondern ein Button
Code
Alles anzeigen$H windows.ph $H messages.ph STRUCT RECT = Left&,Righ&,Top&,Bottom& Declare appexit% WindowStyle $003F WindowTitle "anklicken und verschieben " Window 207,114 - 771,611 Cls ~GetSysColor(15) UseFont "MS Sans Serif",13,0,0,0,0 SetDialogFont 1 Var Text& = Create("Text",%hwnd,"veschieb mich",10,10,100,24) Var Group& = Create("Groupbox",%hwnd,"veschieb mich",10,40,300,300) '################################# 'STATIC MUSS ~SS_NOTIFY STIL HABEN '################################# SetStyle Text&,GetStyle(Text&) | ~SS_NOTIFY '################################# Var R# = New(RECT) WhileNot appexit% WaitInput If %key = 2 Dispose hdr# Dispose R# appexit%=1 Endif If (%message = ~WM_COMMAND) AND (&lParam = Text&) UseCursor 5 ~ReleaseCapture() SendMessage(&lParam,~WM_SYSCOMMAND,~SC_MOVE+1,0) UseCursor 0 ElseIf %message = ~WM_LBUTTONDOWN ~GetClientRect(Group&,R#) ~MapWindowPoints(Group&,%hwnd,R#,2) If ~PtInRect(R#,LoWord(&lParam),HiWord(&lParam)) UseCursor 5 ~ReleaseCapture() SendMessage(Group&,~WM_SYSCOMMAND,~SC_MOVE+1,0) UseCursor 0 endif EndIf EndWhile
-
Und so geht es mit jedem Control im Fenster, egal welcher Stil gesetzt ist.:-)
Code
Alles anzeigen$H windows.ph $H messages.ph STRUCT RECT = Left&,Righ&,Top&,Bottom& Declare appexit% WindowStyle $003F WindowTitle "anklicken und verschieben " Window 207,114 - 771,611 Cls ~GetSysColor(15) UseFont "MS Sans Serif",13,0,0,0,0 SetDialogFont 1 Var Text& = Create("Text",%hwnd,"veschieb mich",10,10,100,24) Var Group& = Create("Groupbox",%hwnd,"veschieb mich",10,40,300,300) Var Button& = Create("Button",%hwnd,"veschieb mich",140,10,100,24) Var R# = New(RECT) WhileNot appexit% WaitInput ~EnumChildWindows(%hwnd,ProcAddr("MoveIt",2),MakeLong(%mousex,%mousey)) If %key = 2 Dispose hdr# Dispose R# appexit%=1 Endif EndWhile Proc MoveIt Parameters wnd&,lParam& ~GetClientRect(wnd&,R#) ~MapWindowPoints(wnd&,%hwnd,R#,2) If ~PtInRect(R#,LoWord(lParam&),HiWord(lParam&)) ~ReleaseCapture() UseCursor 5 SendMessage(wnd&,~WM_SYSCOMMAND,~SC_MOVE+1,0) UseCursor 0 Return 0 endif Return 1 EndProc
-
Hscroll und Vscroll funktionieren nicht.;)
Spinedit "spinnt". Beide Bestandteile lassen sich unabhängig voneinander
verschieben. Das Auf und Ab - zählen funktioniert aber.:DPrima , daß dafür mal ein allgemeingültiger Code da ist :-):-)
Jetzt mitmachen!
Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!