Buchempfehlung
Mikrocomputertechnik mit Controllern der Atmel AVR-RISC-Familie
Mikrocomputertechnik mit Controllern der Atmel AVR-RISC-Familie
Umfassend, aber leicht verständlich führt dieses Buch in die Programmierung von ATMEL AVR Mikrocontrollern ein. [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

fb:porticula NoPaste

Info
Info / Hilfe
Liste
Übersicht / Liste
Neu
Datei hochladen
Suche
Quellcode suchen
Download
Dateidownload

wx-c Beispiel für nemored 2

Uploader:RedakteurMOD
Datum/Zeit:21.08.2011 01:00:19

#Include "wx-c 0.9.2/wx.bi"

Declare Function App_OnInit WXCALL ( ) As wxBool
Declare Function App_OnExit WXCALL ( ) As wxInt

Declare Sub textctrl0_event WXCALL ( ByVal event As wxEvent Ptr, ByVal iListener As wxInt )

Dim Shared As wxApp Ptr wx_app
Dim Shared As wxFrame Ptr wx_frame
Dim Shared As wxPanel Ptr wx_panel

Function wxString_to_fbstring( ByVal wxstr As wxString Ptr ) As String

    Dim As String ret
    Dim As Integer i

    For i = 0 To wxString_GetLength( wxstr )
        If wxString_CharAtUTF16( wxstr, i ) <> 0 Then
            ret += Chr( wxString_CharAtUTF16( wxstr, i ) )
        EndIf
    Next

    Return ret

End Function

Function fbstring_to_wxString( ByVal fbstr As String ) As wxString Ptr

    Dim As wxString Ptr ret
    Dim As WString Ptr temp = Callocate( Len(fbstr) + 1, SizeOf(WString) )

    *temp = WStr( fbstr )
    ret = wxString_ctorUTF16( temp )

    DeAllocate temp
    Return ret

End Function


Function App_OnInit WXCALL ( ) As wxBool

    wx_frame = wxFrame_ctor( )
    wxFrame_Create( wx_frame, WX_NULL, -1, wxString_ctorUTF8("TextCtrl Sample"), 536, 373, 350, 71, wxFRAME_DEFAULT_STYLE Or wxCLOSE_BOX Xor wxMAXIMIZE_BOX Xor wxRESIZE_BORDER, WX_NULL )
    wx_panel = wxPanel_ctor2( wx_frame, -1, -1, -1, -1, -1, 0, WX_NULL )

    ''
    '' create widget textctrl0
    ''
    Dim As wxTextCtrl Ptr textctrl0
    textctrl0 = wxTextCtrl_ctor( )
    wxTextCtrl_Create( textctrl0, wx_panel, -1, wxString_ctorUTF8(""), 10, 10, 320, 20, 0, 0, 0 )

    wxEvtHandler_Proxy( textctrl0, Cast(EventListener, @textctrl0_event) )
    'Es gibt noch andere Events, die man hernehmen könnte...
    wxEvtHandler_Connect( textctrl0, wxEvent_EVT_COMMAND_TEXT_UPDATED( ), -1, -1, 0 )

    wxWindow_Show( wx_frame, 1 )
    wxApp_OnInit( wx_app )
    Return 1

End Function

Function App_OnExit WXCALL ( ) As wxInt

    Return wxApp_OnExit( wx_app )

End Function

Sub textctrl0_event WXCALL ( ByVal event As wxEvent Ptr, ByVal iListener As wxInt )

    Select Case wxEvent_GetEventType( event )
        Case wxEvent_EVT_COMMAND_TEXT_UPDATED
            Dim As Integer position = wxTextCtrl_GetInsertionPoint( wxEvent_GetEventObject( event ) )
            Dim As String temp = wxString_to_fbstring( wxTextCtrl_GetValue( wxEvent_GetEventObject( event ) ) )

            Select Case temp[position-1]
                Case 97 To 122
                    temp[position-1] -= 32 'no lowercase
                    wxTextCtrl_SetValue( wxEvent_GetEventObject( event ), fbstring_to_wxString( temp ) )
                    wxTextCtrl_SetInsertionPoint( wxEvent_GetEventObject( event ), position )
            End Select

            ''oder mit wxEvent_EVT_KEY_UP
            'For i As Integer = 0 To wxTextCtrl_GetLastPosition( wxEvent_GetEventObject( event ) ) - 1
            '   Select Case temp[i]
            '       Case 97 To 122
            '           temp[i] -= 32
            '   End Select
            '   wxTextCtrl_SetValue( wxEvent_GetEventObject( event ), fbstring_to_wxString( temp ) )
            '   wxTextCtrl_SetInsertionPoint( wxEvent_GetEventObject( event ), position )
            'Next

    End Select

End Sub


''main
wx_app = wxApp_ctor( )
wxApp_RegisterVirtual ( wx_app, @App_OnInit, @App_OnExit )
wxApp_Run( 0, 0 )