1. Artikel
  2. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  3. Forum
  • Anmelden
  • Registrieren
  • Suche
Dieses Thema
  • Alles
  • Dieses Thema
  • Dieses Forum
  • Artikel
  • Seiten
  • Forum
  • Erweiterte Suche
  1. Paules-PC-Forum.de
  2. Forum
  3. Programmierung
  4. XProfan

Control verschieben

  • Ralph Theobald
  • 30. April 2011 um 20:24
  • Ralph Theobald
    Weiß worum´s geht
    Beiträge
    103
    • 30. April 2011 um 20:24
    • #1

    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 :):?:

  • Ralph Theobald
    Weiß worum´s geht
    Beiträge
    103
    • 30. April 2011 um 21:32
    • #2
    Code
    DEF &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
    Alles anzeigen

    :D

  • Frank A.
    Premium-Mitglied
    Reaktionen
    160
    Beiträge
    6.451
    • 30. April 2011 um 22:36
    • #3

    Mir fehlen die PrfFellows, konnte nicht testen. Aber die HTCAPTION-Lösung funktioniert fast überall. :)

    Gruß, Frank

    Brandneue Games von mir

  • Andreas Miethe
    Forenmaskottchen
    Beiträge
    493
    • 1. Mai 2011 um 07:33
    • #4

    Statics müssen den richtigen Stil haben, damit sie Meldungen weitergeben.

    Code
    $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
    Alles anzeigen

    Gruss
    Andreas

    ______________________
    http://www.ampsoft.eu

    Profan 3.3 - XProfanX2
    Windows 95,98,ME,2000,XP
    Vista - Windows 7 32 / 64 Bit

    ASUS X93S - Intel Core I7 - NVIDIA GForce GT540M - 8GB Arbeitsspeicher

  • Ralph Theobald
    Weiß worum´s geht
    Beiträge
    103
    • 2. Mai 2011 um 18:10
    • #5

    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.

  • Ralph Theobald
    Weiß worum´s geht
    Beiträge
    103
    • 2. Mai 2011 um 18:21
    • #6

    Static Funktioniert .

    Groupbox geht nicht.

  • Andreas Miethe
    Forenmaskottchen
    Beiträge
    493
    • 2. Mai 2011 um 19:37
    • #7
    Zitat von Ralph Theobald;854236

    Static Funktioniert .

    Groupbox geht nicht.

    Eine Groupbox ist ja auch kein Static sondern ein Button

    Code
    $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
    Alles anzeigen

    Gruss
    Andreas

    ______________________
    http://www.ampsoft.eu

    Profan 3.3 - XProfanX2
    Windows 95,98,ME,2000,XP
    Vista - Windows 7 32 / 64 Bit

    ASUS X93S - Intel Core I7 - NVIDIA GForce GT540M - 8GB Arbeitsspeicher

  • Andreas Miethe
    Forenmaskottchen
    Beiträge
    493
    • 2. Mai 2011 um 20:01
    • #8

    Und so geht es mit jedem Control im Fenster, egal welcher Stil gesetzt ist.:-)

    Code
    $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
    Alles anzeigen

    Gruss
    Andreas

    ______________________
    http://www.ampsoft.eu

    Profan 3.3 - XProfanX2
    Windows 95,98,ME,2000,XP
    Vista - Windows 7 32 / 64 Bit

    ASUS X93S - Intel Core I7 - NVIDIA GForce GT540M - 8GB Arbeitsspeicher

  • Ralph Theobald
    Weiß worum´s geht
    Beiträge
    103
    • 2. Mai 2011 um 22:25
    • #9

    Hscroll und Vscroll funktionieren nicht.;)


    Spinedit "spinnt". Beide Bestandteile lassen sich unabhängig voneinander
    verschieben. Das Auf und Ab - zählen funktioniert aber.:D

    Prima , daß dafür mal ein allgemeingültiger Code da ist :-):-)

  • H.Brill
    Dauergast
    Reaktionen
    456
    Beiträge
    1.158
    • 8. Januar 2025 um 11:54
    • #10

    Damit lassen sich auch Icons und Bitmaps verschieben.

    Code
    $H windows.ph
    $H messages.ph
    Declare Long x, appexit, Handle icon1, bmp1, hpic
    STRUCT RECT = Left&, Right&, Top&, Bottom&
    WindowTitle "Anklicken und verschieben "
    Window 800, 600
    x = 0
    Mcls 200, 100 , RGB(255, 0, 255)
    StartPaint  - 1
     DrawText 100, 30, "verschieb mich !", 6
    EndPaint
    icon1 = Create("Icon", %HWnd, "A", 450, 50, 1)
    bmp1 = Create("Bitmap", %HWnd, Create("hPic", 0, "&MEMBMP"), 450, 120)
    
    Var Text& = Create("Text",%hwnd,"veschieb mich",10,10,100,24)
    Var Group& = Create("Groupbox",%hwnd,"veschieb mich",10,60,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))
     SetText %HWnd, "X1 : " + Str$(R#.Left&) + "  Y 1 : " + Str$(R#.Right&) + "  X2 " + Str$(R#.Top&) + "  Y2 : "+ Str$(R#.Bottom&)
     If %key = 2
       Dispose hdr#
       Dispose R#
       DeleteObject icon1, bmp1
       appexit = 1
     Endif
    EndWhile
    End
    
    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
    Alles anzeigen

    Wir sind die XProfaner.

    Sie werden von uns assimiliert.

    Widerstand ist zwecklos!

    Wir werden alle ihre Funktionen und Algorithmen

    den unseren hinzufügen.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!

Benutzerkonto erstellen Anmelden

Windows 11

  1. Datenschutzerklärung
  2. Impressum
Community-Software: WoltLab Suite™