[C++] wxWidgets fading

Questions about programming languages and debugging
Post Reply
User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

[C++] wxWidgets fading

Post by ayu »

A little "effect" that I'm working on for an application that I'm building. The Window is suposed to fade in slowly, which it does, but the objects in the window stay all black until the fading is done, then they appear.

I want them to fade in with the window, so I'm wondering if anyone here has a suggestion for a solution. I will contact wxWidget dev team as well and ask them, and if I get a decent answer, then I will post it here ^^

Anyway, here is the code.....simple test code for this purpose

base.h

Code: Select all

#ifndef BASE_H
#define BASE_H

class MyApp: public wxApp
{
    virtual bool OnInit();
};

class MainFrame: public wxFrame
{
public:

    MainFrame(const wxString &titel, const wxPoint &pos, const wxSize &size);

    wxButton *button1;
    wxButton *button2;

};



#endif
base.cpp

Code: Select all

#include <wx/wx.h>
#include "base.h"
#include <windows.h>

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
{

    MainFrame *frame = new MainFrame("Popup", wxPoint(500,500), wxSize(300,300));
    frame->SetTransparent(0);
    frame->Show(true);
    SetTopWindow(frame);

    for(int i=0; i<255; ++i)
    {
        Sleep(1);
        frame->SetTransparent(i);
    }



    return true;
}

MainFrame::MainFrame(const wxString &title, const wxPoint &pos, const wxSize &size): wxFrame((wxFrame *)NULL, -1, title, pos, size)
{
    button1 = new wxButton(this, NULL, "test", wxPoint(10,10), wxDefaultSize);
    button2 = new wxButton(this, NULL, "test2", wxPoint(100,10), wxDefaultSize);
}
"The best place to hide a tree, is in a forest"

Post Reply