Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
bool CCombobox::Create(int x, int y, int width, int height, HWND parent, HINSTANCE hInstance, int id) { m_id = id; m_type = WINGUI_COMBOBOX; m_hParent = parent; m_hElement = CreateWindow( "COMBOBOX", NULL, WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP, x, y, width, height, m_hParent, reinterpret_cast<HMENU>(m_id), hInstance, NULL); if(m_hElement == 0) return false; else return true; } void CCombobox::AddEntry(char* entry) { SendMessage(m_hElement, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(entry)); } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
CWindow window; window.Create("test window", 800, 600, hInstance); window.AddButton("beenden", 50, 100, 100, 40, 0); window.AddCombobox(200, 100, 100, 40, 1); reinterpret_cast<CCombobox*>(window.GetElementById(1))->AddEntry("entry 1"); reinterpret_cast<CCombobox*>(window.GetElementById(1))->AddEntry("entry 2"); while(true) { window.DoMessageLoop(); if(reinterpret_cast<CButton*>(window.GetElementById(0))->Pressed()) break; Sleep(1); } window.Destroy(); |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_COMMAND: { std::list<CWindow*>::iterator it; for(it=CWindow::m_windows.begin(); it!=CWindow::m_windows.end();it++) { if((*it)->GetHandle() == hWnd) { for((*it)->m_element_iterator=(*it)->m_elements.begin(); (*it)->m_element_iterator!=(*it)->m_elements.end(); ++(*it)->m_element_iterator) { if(reinterpret_cast<HWND>(lParam) == (*(*it)->m_element_iterator)->GetHandle()) { switch((*(*it)->m_element_iterator)->m_type) { case WINGUI_BUTTON: reinterpret_cast<CButton*>((*(*it)->m_element_iterator))->m_buttonpressed = true; return true; case WINGUI_COMBOBOX: MessageBox(0, "test", "test", MB_OK); return DefWindowProc(hWnd, msg, wParam, lParam); } } } } } } default: return DefWindowProc(hWnd, msg, wParam, lParam); } } |
Werbeanzeige