I cant get an image to appear after I load it, but the program says that it was loaded, and drew it.
Here's my code, can anyone tell me why the image wont appear?
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include "base.h"
IMPLEMENT_APP(MainApp)
bool MainApp::OnInit()
{
wxImage::AddHandler( new wxGIFHandler );
wxImage Pic_Splash;
if (Pic_Splash.LoadFile("bitmaps\\splash.gif", wxBITMAP_TYPE_GIF)) {
new wxSplashScreen(Pic_Splash,
wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT,
6000, NULL, -1, wxDefaultPosition, wxDefaultSize,
wxSIMPLE_BORDER|wxSTAY_ON_TOP);
}
MainFrame *MainWin = new MainFrame("BlakkCount", wxPoint(1, 1),
wxSize(290, 190)); MainWin->Show(TRUE); SetTopWindow(MainWin);
return TRUE;
}
MainFrame::MainFrame(const wxString &title, const wxPoint &pos, const wxSize &size)
: wxFrame((wxFrame *) NULL, -1, title, pos, size)
{
Center(); SetSizeHints(290, 190, 290, 190, -1, -1);
CreateStatusBar();
MainMenu = new wxMenuBar(); wxMenu *FileMenu = new wxMenu(); wxMenu *OtherMenu = new wxMenu();
FileMenu->Append(MENU_Open, "&Open", "Open a file");
FileMenu->Append(MENU_Close, "&Close", "Close currently open file");
FileMenu->AppendSeparator();
FileMenu->Append(MENU_Quit, "&Quit", "Quit the program");
OtherMenu->Append(MENU_About, "&About", "About the program");
MainMenu->Append(FileMenu, "File");
MainMenu->Append(OtherMenu, "Other");
SetMenuBar(MainMenu);
if (BackgroundBMP.LoadFile("bitmaps\\background.bmp", wxBITMAP_TYPE_BMP))
{
if (DrawBackground(BackgroundDC))
{
SetStatusText("Successfully loaded and drew the background bitmap!");
}
}
else SetStatusText("FAILED!");
SetFont(wxFont(10, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE, wxEmptyString, wxFONTENCODING_DEFAULT));
NoFileLoaded = new wxStaticText(this,
STATICTEXT_NoFileLoaded,
"nnnNo File Loaded",
wxDefaultPosition,
wxDefaultSize,
wxALIGN_CENTRE,
"NoFileLoaded");
}
void MainFrame::OpenFile()
{
wxTextFile *TxtFile;
wxFileDialog *OpenDialog = new wxFileDialog(this, "Choose a file to open", "", "", "Text files (*.txt)|*.txt|", wxOPEN, wxDefaultPosition);
if (OpenDialog->ShowModal() == wxID_OK) {
CurrentDocPath = OpenDialog->GetPath();
delete NoFileLoaded;
SetFont(wxFont(10, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE, wxEmptyString, wxFONTENCODING_DEFAULT));
LinesInFile = new wxStaticText(this,
STATICTEXT_LinesInFile,
"Lines in File: ",
wxDefaultPosition,
wxSize(290,190),
wxALIGN_CENTRE,
"LinesInFile");
SetTitle(wxString("BlakKount - ") << OpenDialog->GetFilename()); }
}
void MainFrame::CloseFile()
{
LinesInFile->SetLabel("Lines in File: ");
SetTitle("BlakKount");
}
void MainFrame::Maximize()
{
SetStatusText("Yeah, just try maximizing the window again");
}
void MainFrame::Quit()
{
Close(TRUE); }
void MainFrame::About()
{
wxDialog AboutDlg(this, DLG_Main, "About",
wxDefaultPosition, wxDefaultSize,
wxTHICK_FRAME | wxCAPTION, "DIALOGBOX");
if (AboutDlg.ShowModal() == TRUE) SetStatusText("Oh yeah");
AboutDlg.Destroy();
SetStatusText("ABOUT");
}
bool MainFrame::DrawBackground(wxDC &dc)
{
dc.DrawBitmap(BackgroundBMP, 0, 20, 0);
return TRUE;
} |