[wxWidgets] wxWidgets + linux = problem ?

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
St_W
Posts: 1492
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

[wxWidgets] wxWidgets + linux = problem ?

Postby St_W » Feb 18, 2009 20:21

When I try to run the following code, the conversion from a wxString into a ZSTRING PTR fails. The first 8 bytes contain weird characters, the remaining string is normal.

When reading the characters byte for byte the string is read correctly.

Is this a bug of the FBC, the wx-C wrapper or wxWidgets?
Why does the error appear?
Does anyone have a solution or a reason?

The example code is:

Code: Select all

#INCLUDE ONCE "wx-c/wx.bi"
#DEFINE wxCLOSE_BOX &h1000
#DEFINE FALSE 0
#DEFINE TRUE NOT(FALSE)

DECLARE SUB App_OnInit( )
DECLARE SUB App_OnExit( )
DECLARE SUB btnTest_event( BYVAL event AS wxEvent PTR, BYVAL iListener AS LONG )

DIM SHARED wx_app AS wxApp PTR, wx_frame AS wxFrame PTR, wx_panel AS wxPanel PTR
DIM SHARED AS wxTextCtrl PTR txtTest
DIM SHARED AS wxTextCtrl PTR txtTest2

SUB App_OnInit( )
   
    wx_frame = wxFrame( )
    wxFrame_Create( wx_frame, 0, -1, "Test-Application", wxSize( -1, -1 ), wxSize( 400, 400 ), wxDEFAULT_FRAME_STYLE OR wxCLOSE_BOX OR wxMAXIMIZE_BOX OR wxRESIZE_BORDER, "frame" )
    wx_panel = wxPanel_ctor2( wx_frame, -1, wxSize( -1, -1 ), wxSize( -1, -1 ), 0, 0 )
    wxWindow_CenterOnScreen(wx_frame, wxBOTH)
   
    ' lblTest
    DIM AS wxStaticText PTR lblTest
    lblTest = wxStaticText()
    wxStaticText_Create(lblTest, wx_panel, -1, "Please enter any string:", wxSize(10,10), wxsize(-1, -1),0,0)
   
    'txtTest
    'DIM AS wxTextCtrl PTR txtTest
    txtTest = wxTextCtrl()
    wxTextCtrl_Create(txtTest, wx_panel,-1,"Enter any string here", wxSize(10,30), wxsize(265,-1),0,0,0)
   
    'btnTest
    DIM AS wxButton PTR btnTest
    btnTest = wxButton()
    wxButton_Create(btnTest,wx_panel, -1,"Test", wxSize(310,29), wxsize(70,-1),0,0,0)
    wxEvtHandler_Proxy( btnTest, CPTR( ANY PTR, @btnTest_event) )
    wxEvtHandler_Connect( btnTest, wxEvent_EVT_COMMAND_BUTTON_CLICKED, -1, -1, 0 )
   
    'lblTest2
    DIM AS wxStaticText PTR lblTest2
    lblTest2 = wxStaticText()
    wxStaticText_Create(lblTest2, wx_panel, -1, "Your Input:", wxSize(10,80), wxsize(-1, -1),0,0)
   
    'txtTest2
    'DIM AS wxTextCtrl PTR txtTest2
    txtTest2 = wxTextCtrl()
    wxTextCtrl_Create(txtTest2, wx_panel,-1,"Enter any string here", wxSize(10,120), wxsize(265,-1),0,0,0)
   
    wxWindow_Show( wx_frame, 1 )
    wxApp_OnInit( wx_app )
   
END SUB

SUB App_OnExit( )
   
    CLOSE
    wxApp_OnExit( wx_app )
   
END SUB

SUB btnTest_event( BYVAL event AS wxEvent PTR, BYVAL iListener AS LONG )
   
    SELECT CASE wxEvent_GetEventType( event )
    CASE wxEvent_EVT_COMMAND_BUTTON_CLICKED
          DIM AS wxString PTR tmpwxStr
          DIM test AS STRING
          tmpwxStr = wxTextCtrl_GetValue(txtTest)
         
          ''THIS DOESN'T WORK:
          test = *wxString_mb_str(tmpwxStr)
          PRINT "User Input: "; test
         
          ''THIS WORKS:
          PRINT "User Input 2: ";
          FOR q AS INTEGER = 0 TO wxString_Length(tmpwxStr)-1
             PRINT CHR(wxString_CharAt(tmpwxStr, q));
          NEXT
          PRINT:PRINT
         
          wxTextCtrl_SetValue(txtTest2, test)
          wxString_dtor(tmpwxStr)
    END SELECT
   
END SUB


wx_app = wxApp( )
wxApp_RegisterVirtual ( wx_app, CPTR( ANY PTR, @App_OnInit ), CPTR( ANY PTR, @App_OnExit ) )
wxApp_Run(0,0)
END


Thanks for Your answers!

Return to “Libraries”

Who is online

Users browsing this forum: No registered users and 2 guests