我想在我的程序中再创建一个小的窗口显示在屏幕的右下角,就像迅雷每次打开后弹出的那个透明窗口的广告一样,请问我要让哪个类作为这个小窗口的基类,具体如何实现啊,各位帮帮忙

解决方案 »

  1.   

    CDialog做为基类,在OnInitDialog中添加使窗口透明的代码 主要是SetLayeredWindowAttributes函数的调用。
    www.vckbase.com上的代码:SetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE,
    GetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE)^0x80000);
    HINSTANCE hInst = LoadLibrary("User32.DLL"); 
    if(hInst) 
    {            
    typedef BOOL (WINAPI *MYFUNC)(HWND,COLORREF,BYTE,DWORD);          
    MYFUNC fun = NULL;
    //取得SetLayeredWindowAttributes函数指针     
    fun=(MYFUNC)GetProcAddress(hInst, "SetLayeredWindowAttributes");
    if(fun)fun(this->GetSafeHwnd(),0,128,2);     
    FreeLibrary(hInst); 
    }
      

  2.   

    楼上的正确,你就在if(fun)fun(this->GetSafeHwnd(),0,128,2); 这里调节他的透明度
      

  3.   


    ::SetWindowPos(m_hWnd,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE);
    SetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE,
    GetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE)^0x80000);
    HINSTANCE hinstance = LoadLibrary("User32.dll");
    if(NULL != hinstance)
    {
    typedef BOOL (WINAPI*MyFunc)(HWND,COLORREF,BYTE,DWORD);
    MyFunc pFunc = NULL;
    pFunc = (MyFunc)GetProcAddress(hinstance,"SetLayeredWindowAttributes");
    if(pFunc != NULL)
    {
    pFunc(this->GetSafeHwnd(),0,128/*透明度0-255*/,2);
    }
    FreeLibrary(hinstance);
    }VC6.0下测试没问题
      

  4.   

    好像不用那个GetProcAddress得到函数入口地址哦,MFC头文件里面好像已经定义了,我怎么直接调用也可以
      

  5.   

    http://www.vckbase.com/code/findcode.asp?keyword=%CD%B8%C3%F7%B4%B0%BF%DA
      

  6.   

    2楼的没错。
    不过注意,你不能直接使用MFC头文件中定义的那个,因为在win2000(好像就是这个是分界线)之前的系统中没有这个接口,就不能调用
    另外,需要注意窗口的样式,必需为OVERLAP类型
      

  7.   

    HINSTANCE hInst = LoadLibrary("User32.DLL"); 
    if(hInst) 
    {            
    typedef BOOL (WINAPI *MYFUNC)(HWND,COLORREF,BYTE,DWORD);          
    MYFUNC fun = NULL; 
    //取得SetLayeredWindowAttributes函数指针    
    fun=(MYFUNC)GetProcAddress(hInst, "SetLayeredWindowAttributes"); 
    if(fun)fun(this->GetSafeHwnd(),0,128,2);    
    FreeLibrary(hInst); 
    }
    如果是在VC.NET中的话,上面的代码可以简化为
    SetLayeredWindowAttributes(0,128,2);
      

  8.   

    标题栏透明只要在属性里stles里把title bar的钩去掉就看不见了
      

  9.   

    HINSTANCE hInst = LoadLibrary("User32.DLL");  
    if(hInst)  
    {   
    typedef BOOL (WINAPI *MYFUNC)(HWND,COLORREF,BYTE,DWORD);   
    MYFUNC fun = NULL;  
    //取得SetLayeredWindowAttributes函数指针   
    fun=(MYFUNC)GetProcAddress(hInst, "SetLayeredWindowAttributes");  
    if(fun)fun(this->GetSafeHwnd(),0,128,2);   
    FreeLibrary(hInst);  
    }
    这个方法是可以,但有限于Dialog。