Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / Image wont show

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Image wont show
#3327
Posted by: 2004-02-08 01:51:26
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?

/*** Main.cpp ***/

#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif

#include "base.h"

IMPLEMENT_APP(MainApp) // Initializes the MainApp class and tells our program to run it

bool MainApp::OnInit()
{
wxImage::AddHandler( new wxGIFHandler );

wxImage Pic_Splash; // Create an image variable

if (Pic_Splash.LoadFile("bitmaps\\splash.gif", wxBITMAP_TYPE_GIF)) // If the bitmap loads, show the splash screen
{
      new wxSplashScreen(Pic_Splash,
          wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT,
          6000, NULL, -1, wxDefaultPosition, wxDefaultSize,
          wxSIMPLE_BORDER|wxSTAY_ON_TOP);
}
// Create the window
MainFrame *MainWin = new MainFrame("BlakkCount", wxPoint(1, 1),
wxSize(290, 190)); // Create an instance of our frame, or window
MainWin->Show(TRUE); // show the window
SetTopWindow(MainWin);// and finally, set it as the main window

return TRUE;
}


MainFrame::MainFrame(const wxString &title, const wxPoint &pos, const wxSize &size)
: wxFrame((wxFrame *) NULL, -1, title, pos, size)
{
Center(); // Center the window
SetSizeHints(290, 190, 290, 190, -1, -1); // Set the windows min and max size

CreateStatusBar();

//BackgroundBMP = new wxBitmap;
MainMenu = new wxMenuBar(); // Construct a menu bar
wxMenu *FileMenu = new wxMenu(); // Construct a menu
wxMenu *OtherMenu = new wxMenu(); // Construct a menu

// Add items to menu
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");
// Add items to menu bar
MainMenu->Append(FileMenu, "File");
MainMenu->Append(OtherMenu, "Other");

SetMenuBar(MainMenu); // Show the menu bar

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);
// Creates a "open file" dialog with 4 file types
if (OpenDialog->ShowModal() == wxID_OK) // if the user click "Open" instead of "cancel"
{
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()); // Set the Title to reflect the file open
}
}

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); // Tells the OS to quit running this process
}

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;
}
Message2. Whoops, sorry, didnt mean to post twice
#3329
Posted by: 2004-02-08 01:57:55
Sorry about that
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
¥1,390.00 ·
 
 
¥287.00 ·
 
 
¥410.00 ·
 
 
¥1,380.00 ·
 
 
¥1,080.00 ·
 
 
¥271.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0