English
Source / code snippets

Nativ Nsubclass Subclassing Xpse

 

Nico
Madysa
have me time the Subclassing with XPSEs NProcs something bequemer gestaltet; Perhaps gefällts Yes jemandem.
CompileMarkSeparation
 {$iq}
usermem&: frei verwendbarer Speicher, auf den man in der Subclassprozedur zugreifen kann
Zugriff über Adresse GetWindowLong(sWnd&,~WK_USERDATA)
wnd&: Handle des subzuclassenden Controls
paddr&: Adresse der Subclassprozedur; über ProcAddr(meineProzedur,4) zu erhalten
Um das Subclassing abzuschalten einfach für paddr&=0 aufrufen; siehe Beispiel

{nproc nSubclass

    nproc nSubclass

        parameters usermem&,wnd&,paddr&
        declare owp&,al&

        if paddr& Anschalten

            eigentliches Subclassing; Neue WindowProc wird eingeschoben
            owp& = SetWindowLong(wnd&,gwl_wndProc,paddr&)
            Bereich wird angelegt
            al& = dim(4 + usermem&)
            Am Offset 0 wird in jedem Falle die Adresse der alten WindowProc gemerkt
            Long al&,0 = owp&
            Adresse des Bereiches wird gemerkt
            SetWindowLong(wnd&,gwl_userData,al&)
            else Ausschalten
            Bereichsadresse zurückholen
            al& = GetWindowLong(wnd&,gwl_userData)
            Alte WindowProc wieder einsetzen
            SetWindowLong(wnd&,gwl_wndProc,Long(al&,0))
            Bereich freigeben
            Dispose(al&)

        endif

        return 1

    endproc

    ---BEISPIEL-----------
    Subclassprozedur für das Hauptfenster

    {nproc hWnd.Sub

        nproc hWnd.Sub

            parameters wnd&,msg&,wParam&,lParam&

            if msg& = WM_CLOSE

                Hauptprogramm mit einer Usermessage benachrichtigen, dass das Programm beendet werden soll
                SendMessage(%hWnd,WM_USER+1,0,0)
                return 0

            else

                in allen anderen Fällen die normale Windowproc aufrufen
                Am Offset 0 legt nSubclass die Adresse der alten WindowProc ab
                return CallWindowProc(Long(GetWindowLong(wnd&,gwl_userData),0),wnd&,msg&,wParam&,lParam&)

            endif

        endproc

        Window 0,0 - %MaxX,%MaxY
        nSubclass(0,%hWnd,ProcAddr(hWnd.Sub,4)) Subclassing anschalten
        Usermessage, über die die Subclassproc mit dem Hauptprogramm kommuniziert
        Usermessages WM_USER+1
        Hauptschleife

        while 1

            waitinput
            Wenn nachricht von der Subclassproc kommt, ist Schicht im Schacht.

            if %UMessage = WM_USER+1

                MessageBox("Ende im Gelände!","Aus die Maus!",0)
                break

            endif

        wend

        Subclassing abschalten, um den Bereich hinter gwl_userData zu disposen
        nSubclass(0,%hWnd,0)
        end

so can the native Subclassing almost just as How the xprofane use. additionally is one not any more on a Subclassproc limited.
I hope, there are no Error drin and its tidy comments.
 
Nico Madysa
02/23/10  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

3.349 Views

Untitledvor 0 min.
Andre Rohland06/13/19
rquindt08/27/16
Ernst05/06/16
Rc12/24/15
More...

Themeninformationen

this Topic has 1 subscriber:

Nico Madysa (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie