Fenster transparent setzen



  • void Cfader::OnBnClickedButton2()
    {
    	HWND parentyy = ::FindWindow(NULL, "Rechner");
    	SetWindowTransparency(parentyy,40);
    }
    
    BOOL SetWindowTransparency(HWND hWnd, int nPercentage)
    {
        int nTrans = ((nPercentage*255) / 100);
    	BOOL bSet = ::SetLayeredWindowAttributes(hWnd, NULL, nTrans, LWA_ALPHA);
        if(bSet == 0) return FALSE;
    
    	BOOL bSetPos = SetWindowPos(hWnd, hWnd, NULL, NULL, NULL, NULL, SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER);
        if(bSetPos == 0) return FALSE;
        return TRUE;
    }
    

    Ich will ein Fenster transparent darstellen, aber erhalte immer vom Compiler
    ein "nicht aufgelöstes externes Symbol".

    User32.lib ist gelinkt und windows.h included. Ich weiss wirklich nicht was
    da jetzt noch fehlen kann 😕


  • Mod

    Und welches Symbol fehlt?



  • Ähh ja 😃

    Nicht aufgelöstes externes Symbol '"public: int __thiscall Cfader::SetWindowTransparencyx(struct HWND__ *,unsigned long,unsigned char,char *)" (?SetWindowTransparencyx@CfaderDlg@@QAEHPAUHWND__@@KEPAD@Z)', verwiesen in Funktion '"public: void __thiscall Cfader::OnBnClickedButton2(void)" (?OnBnClickedButton2@CfaderDlg@@QAEXXZ)'

    Und das sagt, zumindest mir, nichts 🙄



  • Soll das SetWindowTransparency evtl ne Methode deiner Klasse sein? Falls, ja, dann fehlt das Cfader:: vor der Definition.


  • Mod

    Wenn SetWindowTransparency zu Deiner Klasse gehört, müsste es so heißen:

    BOOL Cfader::SetWindowTransparency(HWND hWnd, int nPercentage)
    ...
    


  • bzw. wenn du die Funktion ohne klasse nutzen willst muss sie über der Funktione stehn in der sie das erste mal aufgerufen wird.

    BOOL SetWindowTransparency(HWND hWnd, int nPercentage)
    {
        int nTrans = ((nPercentage*255) / 100);
        BOOL bSet = ::SetLayeredWindowAttributes(hWnd, NULL, nTrans, LWA_ALPHA);
        if(bSet == 0) return FALSE;
    
        BOOL bSetPos = SetWindowPos(hWnd, hWnd, NULL, NULL, NULL, NULL, SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER);
        if(bSetPos == 0) return FALSE;
        return TRUE;
    }
    void Cfader::OnBnClickedButton2()
    {
        HWND parentyy = ::FindWindow(NULL, "Rechner");
        SetWindowTransparency(parentyy,40);
    }
    

Anmelden zum Antworten