fb:porticula NoPaste
Listbox fehlerhaft
Uploader: | Elektronix |
Datum/Zeit: | 01.12.2009 17:55:10 |
#include "windows.bi"
'IDs der Buttons
#Define ButtonNums 3
#Define ID_EDIT 1
#Define ID_LIST 2
#Define ID_COMBO 3
#Define ID_EDITFELD 30
Type ButtonParam
iStyle As Integer
szText As String
End Type
Data BS_PUSHBUTTON, "Editfeld", BS_PUSHBUTTON, "ListBox", BS_PUSHBUTTON, "ComboBox"
const ProgrammName = "Edit-List-Combobox"
'Funktionsdeklaration
declare function MainProc(byval hWnd as HWND, byval message as UINTEGER,_
byval wParam as WPARAM, byval lParam as LPARAM) as LRESULT
'Erstellen und Registrieren der Fensterklasse
dim as WNDCLASS windowclass
with windowclass
.style = CS_HREDRAW or CS_VREDRAW
.lpfnWndProc = ProcPtr(MainProc)
.cbClsExtra = 0
.cbWndExtra = 0
.hInstance = GetModuleHandle(NULL)
.hCursor = LoadCursor(NULL, IDC_ARROW)
.hIcon = LoadIcon(NULL, IDI_APPLICATION)
.hbrBackground = GetStockObject(WHITE_BRUSH)
.lpszClassName = StrPtr(ProgrammName)
.lpszMenuName = NULL
end with
RegisterClass @windowclass
'Erstellen des Fensters
dim as HWND MeinFenster = CreateWindow(_
ProgrammName, "Buttons", WS_OVERLAPPEDWINDOW,_
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,_
NULL, NULL, GetModuleHandle(NULL), NULL)
ShowWindow MeinFenster, SW_NORMAL
UpdateWindow MeinFenster
'Nachrichtenschleife
dim as MSG Nachricht
do while GetMessage(@Nachricht, NULL, 0, 0)
TranslateMessage(@Nachricht)
DispatchMessage @Nachricht
loop
end Nachricht.wParam
function MainProc(byval hWnd as HWND, byval message as UINTEGER,_
byval wParam as WPARAM, byval lParam as LPARAM) as LRESULT
Dim Buttoncounter As Integer = 0
Static hButton(ButtonNums) As HWND
Static Buttons(ButtonNums) As ButtonParam
Static rect As RECT
Static cxString As Integer, cyString As Integer
Static As hWnd hEdit, hList, hCombo
Const As String EditText = "Editfeld"
Select Case message
Case WM_CREATE
cxString = LOWORD(GetDialogBaseUnits)
cyString = HiWord(GetDialogBaseUnits)
For ButtonCounter = 1 To ButtonNums
Read Buttons(ButtonCounter).iStyle, Buttons(ButtonCounter).szText
hButton(ButtonCounter) = CreateWindow("button", _
Buttons(ButtonCounter).szText, _
WS_CHILD Or WS_VISIBLE Or _
Buttons(ButtonCounter).iStyle, _
3, cyString*(2*ButtonCounter), _
10*cxString, 7*cyString/4, _
hWnd, Cast(HMENU, ButtonCounter), _
Cast(LPCREATESTRUCT, lParam)->hInstance, NULL)
Next
Return 0
Case WM_COMMAND
Select Case LoWord (wParam)
Case ID_EDIT
hEdit = CreateWindow("edit", _
"Editfeld", _
WS_CHILD Or WS_VISIBLE Or WS_BORDER Or _
DS_MODALFRAME Or WS_CAPTION Or WS_SYSMENU Or _
WS_HSCROLL Or WS_VSCROLL Or _
ES_LEFT Or ES_MULTILINE Or ES_AUTOHSCROLL Or ES_AUTOVSCROLL, _
100, _
50, _
200, _
200, _
hWnd, _
Cast(HMENU, ID_EDITFELD), _
Cast(HINSTANCE, GetWindowLong(hwnd, GWL_HINSTANCE)), _
NULL)
SendMessage(hEdit, EM_LIMITTEXT, 200, 0)
SetFocus(hEdit)
Case ID_EDITFELD
If HiWord(wParam) = EN_KILLFOCUS Then
Print "Editfenster hat den Focus verloren"
ElseIf HiWord(wParam) = EN_SETFOCUS Then
Print "Edifenster hat den Focus erhalten"
EndIf
Case ID_LIST
Print "List
Case ID_COMBO
Print "Combo"
End Select
/'Case WM_LBUTTONUP
If LoWord(lParem) >='/
Case WM_DESTROY
PostQuitMessage (0)
return 0
Case Else
return DefWindowProc(hWnd, message, wParam, lParam)
End Select
End Function