fb:porticula NoPaste
Codierung über ASCII
Uploader: | raph ael |
Datum/Zeit: | 09.04.2008 17:56:54 |
/'
Dieses Programm fragt eine 9 Zeichen lange Zeichenkette ab und
wandelt sie in ASCII- Zeichencodes um.
'/
________________________________________________________________________________________
Resourcendatei
________________________________________________________________________________________
#define IDD_DLG1 1000
#define IDC_EDT1 1001
#define IDC_BTN1 1002
#define IDC_EDT2 1003
#define IDC_STC1 1004
#define IDC_STC2 1005
IDD_DLG1 DIALOGEX 6,6,145,44
CAPTION "ASCII Code"
FONT 8,"MS Sans Serif",0,0,0
STYLE 0x10CF0000
BEGIN
CONTROL "",IDC_EDT1,"Edit",0x50010000,32,0,110,13,0x00000200
CONTROL "OK",IDC_BTN1,"Button",0x50010000,0,31,54,13
CONTROL "",IDC_EDT2,"Edit",0x50010000,34,14,108,13,0x00000200
CONTROL "Eingabe:",IDC_STC1,"Static",0x50000000,0,1,30,10
CONTROL "Ausgabe:",IDC_STC2,"Static",0x50000000,0,16,32,9
END
________________________________________________________________________________________
Codedatei
________________________________________________________________________________________
#include once "windows.bi"
#Include Once "win/commctrl.bi"
#Include Once "win/commdlg.bi"
#Include Once "win/shellapi.bi"
#Include Once "vbcompat.bi"
Dim Shared hInstance As HMODULE
Dim Shared CommandLine As ZString Ptr
Dim Shared hWnd As HWND
#Define IDD_DLG1 1000
#Define IDC_EDT1 1001
#Define IDC_BTN1 1002
#Define IDC_EDT2 1003
#Define IDC_STC1 1004
#Define IDC_STC2 1005
#Define IDC_STC2 1005
Function getAscii(in As ZString Ptr) As String
Dim outp As ZString * Len(in) * 3 + 1
Dim i As Integer
For i = 1 To Len(*in)
outp += Trim(Str(Asc(Mid(*in, i, 1))))
Next
Return outp
End Function
Function DialogProc(ByVal hWin As HWND,ByVal uMsg As UINT,ByVal wParam As WPARAM,ByVal lParam As LPARAM) As Integer
Dim As Long id, nEvent
Select Case uMsg
Case WM_INITDIALOG
'
Case WM_COMMAND
id=LoWord(wParam)
nEvent=HiWord(wParam)
Select Case nEvent
Case BN_CLICKED
Select Case id
Case IDC_BTN1
Dim ausgabe As ZString * 31
GetDlgItemText(hWin, IDC_EDT1, ausgabe, 30)
Dim codiert As ZString * 500
Dim i As Integer
For i = 1 To Len(ausgabe)
Dim asciizeichen As Integer
Dim finale As String
asciizeichen = (Asc(Mid(ausgabe, i, 1)))
finale = Format(CDbl(asciizeichen), "000")
codiert += finale
Next
SetDlgItemText(hWin, IDC_EDT2, codiert)
End Select
'
Case EN_CHANGE
Select Case id
Case IDC_EDT1
Case IDC_EDT2
End Select
'
End Select
'
Case WM_CLOSE
DestroyWindow(hWin)
'
Case WM_DESTROY
PostQuitMessage(NULL)
'
Case WM_SIZE
'
Case Else
Return FALSE
'
End Select
Return TRUE
End Function
Function WinMain(ByVal hInst As HINSTANCE,ByVal hPrevInst As HINSTANCE,ByVal CmdLine As ZString ptr,ByVal CmdShow As Integer) As Integer
Dim msg As MSG
' Create and show the dialog
CreateDialogParam(hInstance,Cast(ZString Ptr,IDD_DLG1),0,@DialogProc,0)
ShowWindow(hWnd,SW_SHOWNORMAL)
UpdateWindow(hWnd)
' Message loop
Do While GetMessage(@msg,NULL,0,0)
TranslateMessage(@msg)
DispatchMessage(@msg)
Loop
Return msg.wParam
End Function
' Program start
hInstance=GetModuleHandle(NULL)
CommandLine=GetCommandLine
InitCommonControls
WinMain(hInstance,NULL,CommandLine,SW_SHOWDEFAULT)
ExitProcess(0)