Make wxr resources work in Unicode mode.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19093 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Mattia Barbon
2003-02-03 22:39:02 +00:00
parent 94311eef78
commit bf60426831
5 changed files with 51 additions and 25 deletions

View File

@@ -29,7 +29,7 @@
#endif
#if wxUSE_UNICODE
#error "This sample can't be compiled in Unicode mode."
// #error "This sample can't be compiled in Unicode mode."
#endif // wxUSE_UNICODE
#include "wx/resource.h"
@@ -56,7 +56,7 @@
// the TEXT resource, for some reason, so either run-time file loading
// or file inclusion should be used.
#if defined(__WXMSW__)
#if defined(__WXMSW__) && !wxUSE_UNICODE
// Under Windows, some compilers can't include
// a whole .wxr file. So we use a .rc user-defined resource
// instead. dialog1 will point to the whole .wxr 'file'.
@@ -83,8 +83,9 @@ MyApp::MyApp()
// main frame
bool MyApp::OnInit(void)
{
#if defined(__WXMSW__)
#if defined(__WXMSW__) && !wxUSE_UNICODE
// Load the .wxr 'file' from a .rc resource, under Windows.
// note that the resource really is a char*, not a wxChar*!
dialog1 = wxLoadUserResource(wxT("dialog1"), wxT("WXRDATA"));
menu1 = wxLoadUserResource(wxT("menu1"), wxT("WXRDATA"));
// All resources in the file (only one in this case) get parsed
@@ -101,20 +102,20 @@ bool MyApp::OnInit(void)
// Create the main frame window
frame = new MyFrame( (wxFrame *) NULL, -1,
(char *) "wxWindows Resource Sample",
wxT("wxWindows Resource Sample"),
wxPoint(-1, -1), wxSize(300, 250) );
// Give it a status line
frame->CreateStatusBar(2);
wxMenuBar *menu_bar = wxResourceCreateMenuBar("menu1");
wxMenuBar *menu_bar = wxResourceCreateMenuBar(wxT("menu1"));
// Associate the menu bar with the frame
frame->SetMenuBar(menu_bar);
// Make a panel
frame->panel = new MyPanel( frame, -1, wxPoint(0, 0), wxSize(400, 400),
0, "MyMainFrame" );
0, wxT("MyMainFrame") );
frame->Show(TRUE);
SetTopWindow(frame);
@@ -124,7 +125,7 @@ bool MyApp::OnInit(void)
MyApp::~MyApp()
{
#if defined(__WXMSW__)
#if defined(__WXMSW__) && !wxUSE_UNICODE
delete dialog1;
delete menu1;
#endif
@@ -169,8 +170,8 @@ MyFrame::MyFrame
void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) )
{
wxMessageBox("wxWindows resource sample.\n"
"(c) Julian Smart", "About wxWindows sample",
wxMessageBox(wxT("wxWindows resource sample.\n")
wxT("(c) Julian Smart"), wxT("About wxWindows sample"),
wxICON_INFORMATION | wxOK);
}
@@ -183,12 +184,12 @@ void MyFrame::OnTestDialog(wxCommandEvent& WXUNUSED(event) )
{
MyDialog *dialog = new MyDialog;
if (dialog->LoadFromResource(this, "dialog1"))
if (dialog->LoadFromResource(this, wxT("dialog1")))
{
wxTextCtrl *text = (wxTextCtrl *)wxFindWindowByName("multitext3", dialog);
wxTextCtrl *text = (wxTextCtrl *)wxFindWindowByName(wxT("multitext3"), dialog);
if (text)
{
text->SetValue("wxWindows resource demo");
text->SetValue(wxT("wxWindows resource demo"));
}
dialog->ShowModal();