Fenster in der Taskleiste ablegen



  • ? Nöö... hmm hab das auch mal gemacht... dahab ich da alle möglichen Controls einfach in die Taskleiste gehauen 😉 Hab mich damals meine ich an http://www.codeproject.com/statusbar/taskbarctrl.asp gehalten...



  • Hmm...kann man dann nicht ein Fenster plazieren, was dann sozusagen als Parent fungiert, ...darauf setz ich dann andere Controls (Childs von Parent und 'abgeleitetes' Child vonner Taskleiste) wenn ihr versteht ?

    Hey, hab ich mal ne Frage gefunden, wo sogar Jochen überfragt ist ?! 😃





  • Wow, gibts dazu n Tut...oder kann mir vllt. einer die ersten paar Zeilen tippen...ich hab ehrlich gar kein Plan wie ich da anfangen sollte 😕 🙄 😮 🙄 😕



  • Das "Tut" ist doch bereits in Swordfish's Link enthalten. Du brauchst dafür aber scheinbar gute COM-Kenntnisse. Also such mal nach einem COM-Tut.



  • Kennt ihr vllt. n gutes...ich hab mich nämlich noch nicht mit COM beschäftigt 😞



  • Nunja, ein COM Component zu schreiben sind nicht ein paar zeilen, sondern normalerweise schon für die Implementation der IClassFactory und IUnknown schon 4 Source-Files:

    component.def

    LIBRARY	COM_dll_sample
    EXPORTS
    DllGetClassObject PRIVATE
    

    main.cpp

    #include <windows.h>
    #include "CClassFactory.h"
    
    int __stdcall DllMain( HINSTANCE instance, unsigned long reason, void *reserved )
    {
        switch( reason ) {
            case DLL_PROCESS_ATTACH:
                return 1;
    
            case DLL_THREAD_ATTACH:
                break;
    
            case DLL_THREAD_DETACH:
                break;
    
            case DLL_PROCESS_DETACH:
                break;
        }
        return 0;
    }
    
    extern "C" long __stdcall DllGetClassObject( const CLSID &clsid, const GUID &iid, void **dest )
    {
        if( clsid != CLSID_Component )
            return CLASS_E_CLASSNOTAVAILABLE;
    
        CClassFactory *factory = new CClassFactory;
    
        if( !factory )
            return E_OUTOFMEMORY;
    
        long result = factory->QueryInterface( iid, dest );
            factory->Release(); 
    
        return result;
    }
    

    CClassFactory.h

    #include <windows.h>
    #include <unknwn.h>
    #include <objbase.h>
    #include "CComponent.h"
    
    extern "C" {
        extern const GUID CLSID_Component;
    }
    
    class CClassFactory : public IClassFactory
    {
        private:
            long ref_count;				
    
        public:
            CClassFactory( );
            ~CClassFactory( );
    
            virtual long __stdcall QueryInterface( const GUID &guid, void **dest );
    	virtual unsigned long __stdcall AddRef( );
            virtual unsigned long __stdcall Release( );
    
    	virtual	long __stdcall CreateInstance( IUnknown *outer_unknown, const GUID &guid, void **dest );
    	virtual long __stdcall LockServer( int lock ); 
    };
    

    CClassFactory.cpp

    #include "CClassFactory.h"
    
    extern "C" {
        // {E04DF83F-B9AB-4614-B3BF-E8AAC40E2BD9}
        static const GUID CLSID_Component = { 0xe04df83f, 0xb9ab, 0x4614,
            { 0xb3, 0xbf, 0xe8, 0xaa, 0xc4, 0xe, 0x2b, 0xd9 }
        };
    }
    
    CClassFactory::CClassFactory( )
    : ref_count( 1 )
    {
    }
    
    CClassFactory::~CClassFactory( )
    {
    }
    
    long __stdcall CClassFactory::QueryInterface( const GUID &guid, void **dest )
    {
        if( ( guid == IID_IUnknown ) || ( guid == IID_IComponent ) ) {
    
        *dest = static_cast< IClassFactory* >( this );
    
        } else {
    
            *dest = 0;
            return E_NOINTERFACE;
        }
    
        reinterpret_cast< IUnknown* >( *dest )->AddRef( );
        return S_OK;
    }
    
    unsigned long __stdcall CClassFactory::AddRef( )
    {
        return InterlockedIncrement( &ref_count );
    }
    
    unsigned long __stdcall CClassFactory::Release( )
    {
        if( InterlockedDecrement( &ref_count ) == 0 ) {
    
            delete this;
            return 0;
        }
    
        return ref_count;
    }
    
    long __stdcall CClassFactory::CreateInstance( IUnknown *outer_unknown, const GUID &guid, void **dest )
    {
        long result;
    
        if( outer_unknown )
            return CLASS_E_NOAGGREGATION;
    
        CComponent *component = new CComponent;
    
        if( !component )
            return E_OUTOFMEMORY;
    
        result = component->QueryInterface( guid, reinterpret_cast< void** >( dest ) );
    
        if( FAILED( result ) )
            component->Release( );
    
        return result;
    }
    
    long __stdcall CClassFactory::LockServer( int lock )
    {
        return CoLockObjectExternal( static_cast< IUnknown* >( this ), lock, 1 );
    }
    

    CComponent.h

    #include "IComponent.h"
    
    class CComponent : public IComponent
    {
        private:
            long ref_count;				
    
        public:
            CComponent( );
            ~CComponent( );
    
            virtual long __stdcall QueryInterface( const GUID &guid, void **dest );
            virtual unsigned long __stdcall AddRef( );
            virtual unsigned long __stdcall Release( );
    };
    

    CComponent.cpp

    #include "CComponent.h"
    
    extern "C" {
        // {C9D11C4E-005D-4009-A676-769D25DA43BA}
        static const GUID IID_IComponent = {
                0xC9D11C4E, 0x005D, 0x4009,
                { 0xA6, 0x76, 0x76, 0x9D, 0x25, 0xDA, 0x43, 0xBA }
        };
    }
    
    CComponent::CComponent( ) : ref_count( 0 )
    {
    }
    
    CComponent::~CComponent( )
    {
    }
    
    long __stdcall CComponent::QueryInterface( const GUID &guid, void **dest )
    {
        if( guid == IID_IUnknown ) {
    
            *dest = static_cast< IUnknown* >( this );
    
        } else if( guid == IID_IComponent ) {
    
            *dest = static_cast< IComponent* >( this );
    
        } else {
    
            *dest = 0;
            return E_NOINTERFACE;
        }
    
        reinterpret_cast< IUnknown* >( *dest )->AddRef( );
        return S_OK;
    }
    
    unsigned long __stdcall CComponent::AddRef( )
    {
    	return InterlockedIncrement( &ref_count );
    }
    
    unsigned long __stdcall CComponent::Release( ) {
        if( InterlockedDecrement( &ref_count ) == 0 ) {
    
            delete this;
            return 0;
        }
    
        return ref_count;
    }
    

    Dann könntest du anfangen, IDeskBand, IObjectWithSite und IPersistStream zu implementieren. Überlege dir bitte nochmal, ob es dir der aufwand wert ist.

    Greetz, Swordfish



  • Könnt ihr mir kurz einmal erklären was COM ist? Das habe ich schon öfters gehört aber nie verstanden was es damit auf sich hat? Was kann man damit machen? 😕





  • AHso ich muss für jedes Interface ne eigene Implementation schreiben....und das ist jetzt schonmal Basics...oder wie ?

    Das müsste ich dann noch fürs IDeskBand-Interface schreiben ?



  • Swordfish also dort versteht man ja nur Krautsalad. Kannst du es mir kurz in 3-4 einfach verständlichen Sätzen erläutern?

    MfG,
    Ranner



  • PS: Wer komm "von Hand" macht ist selber schuld. Dafür gibt es z.B. ATL/MFC.



  • Kann ich ATL denn in Verbindung mit WinAPI nutzen...wenn ja ...Header?Libs? etc. ?



  • Kauf Dir Visual Studio da ist es dabei (Nein: nicht die Exprss-Version).



  • Jochen Kalmbach schrieb:

    Kauf Dir Visual Studio da ist es dabei (Nein: nicht die Exprss-Version).

    LOL?!, bin ich Ingvar Kamprad ? ...die ist doch unbezahlbar... 😡 👎





  • @Jochen: Als ich das erste Mal versucht hab' COM zu machen hab ich ATL verwendet, ne Menge zustande gebracht, jedoch nix von den Interna verstanden. Also hab' ich mich hingesetzt, es "von Hand" gemacht und kappiert.

    @Ranner:

    MSDN schrieb:

    The Microsoft Component Object Model (COM) is a platform-independent, distributed, object-oriented system for creating binary software components that can interact. COM is the foundation technology for Microsoft's OLE (compound documents), ActiveX® (Internet-enabled components), as well as others.
    [...]
    COM specifies an object model and programming requirements that enable COM objects (also called COM components, or sometimes simply objects) to interact with other objects. These objects can be within a single process, in other processes, and can even be on remote machines. They can have been written in other languages, and they may be structurally quite dissimilar, which is why COM is referred to as a binary standard—a standard that applies after a program has been translated to binary machine code.

    PS: registrier dich endlich 🙂

    Greetz, Swordfish


Anmelden zum Antworten