MystikReasons

Members
  • Content count

    11
  • Joined

  • Last visited

Community Reputation

122 Neutral

About MystikReasons

  • Rank
    Member

Personal Information

  • Interests
    |programmer|
  1. Hello I get many errors from wxWidget classes and I don't know why. They don't make the program crash. Does somebody know, why wxWidget creates so many errors? Im using the newest stable version of wxWidget and I build the solution at my own. ..\..\src\msw\control.cpp(149): 'CreateWindowEx("ToolbarWindow32", flags=52008900, ex=00000000)' failed with error 0x0000057e (Subordinate window can not be created at the top level.). H:\WxWidgets\include\wx/msw/private.h(406): 'GetClientRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). ..\..\src\msw\window.cpp(1962): 'MoveWindow' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(406): 'GetClientRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). ..\..\src\msw\window.cpp(1962): 'MoveWindow' failed with error 0x00000578 (Invalid window handle). ..\..\src\msw\toolbar.cpp(1112): 'TB_ADDBUTTONS' failed with error 0x00000578 (Invalid window handle). ..\..\src\msw\toolbar.cpp(290): 'TB_GETITEMRECT' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). H:\WxWidgets\include\wx/msw/private.h(394): 'GetWindowRect' failed with error 0x00000578 (Invalid window handle). ..\..\src\msw\window.cpp(1962): 'MoveWindow' failed with error 0x00000578 (Invalid window handle)
  2. WinAPI Combo Box wont show

    You are absolutly right, it works now but not how as I wanted but anyways thank you  :D  I'll try to fix the other problem tomorrow  :)
  3. WinAPI Combo Box wont show

    Thank you for that useful information.   The debugger says, that the hWndComboBox_File NULL is. Yes I'm creating a wWindow instance, which I used to get the hWnd but the instance is also deleting itself, because its on the stack. hWndParent = wWindow.getHwnd(); // Get the window from the Window Class Could this be the error?
  4. WinAPI Combo Box wont show

    I get an error from GetLastError, saved it in an txt. file What does this error mean to my problem? ERROR_ALREADY_EXISTS Cannot create a file when that file already exists. 183 (0xB7)  
  5. WinAPI Combo Box wont show

    @Fredericvo   I move the instantiate now after I register and create the main window, but it still doesn't work. Heres the code for the core functions. HRESULT wWindow::Initialize() { HRESULT hr; // Create the window class. WNDCLASSEX wcex = { sizeof(WNDCLASSEX) }; wcex.style = CS_HREDRAW | CS_VREDRAW; // The class styles - CS_HREDRAW: Redraws the window if a movement changes the width of the client area. // CS_VREDRAW: Redraws the window if a movement changes the height of the client area. wcex.lpfnWndProc = wWindow::WndProc; // A pointer to the windows procedure. wcex.cbClsExtra = 0; // The number of extra bytes to allocate the window-class structure. wcex.cbWndExtra = sizeof(LONG_PTR); // The number of extra bytes to allocate following the window instance. wcex.hInstance = HINST_THISCOMPONENT; // A handle to the instance that contains the window procedure for the class. wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); // A handle to the class background brush. wcex.lpszMenuName = NULL; // Pointer to a null-terminated character string that specifies the resource name of the class menu. wcex.hCursor = LoadCursor(NULL, IDC_ARROW); // A handle to the class cursor, contains the cursor for the window. wcex.lpszClassName = TEXT("DemoApp"); // The name of the class // Register the window class. RegisterClassEx(&wcex); // Create the application window. // // Because the CreateWindow function takes its size in pixels, we // obtain the system DPI and use it to scale the window size. int dpiX = 0; int dpiY = 0; HDC hdc = GetDC(NULL); if (hdc) { dpiX = GetDeviceCaps(hdc, LOGPIXELSX); // Get the pixels from width dpiY = GetDeviceCaps(hdc, LOGPIXELSY); // Get the pixels from height ReleaseDC(NULL, hdc); } // Create the window m_hwnd = CreateWindow(TEXT("DemoApp"), // Class name. TEXT("CircuitSim"), // Window name. WS_OVERLAPPEDWINDOW |WS_HSCROLL | WS_VSCROLL, // Window style - WS_OVERLAPPEDWINDOW: The window is an overlapped window. CW_USEDEFAULT, // Use the default x position. CW_USEDEFAULT, // Use the default y position. static_cast<UINT>(ceil(640.f * dpiX / 96.f)), // Use the width, which we calculated with the pixels. static_cast<UINT>(ceil(480.f * dpiY / 96.f)), // Use the height, which we calculated with the pixels. NULL, // A handle to the parent window NULL, // A handle to a menu HINST_THISCOMPONENT, // A handle to the instance of the module this); // A pointer to a value to be passed to the window through the CREATESTRUCT structure ComboBox m_comboBox; // Create a instance for ComboBox // Initialize all the combo boxes here // Check if the window passed the following checks - S_OK: Operation sucessful // E_FAIL: Unspecified failure hr = m_hwnd ? S_OK : E_FAIL; if (SUCCEEDED(hr)) { ShowWindow(m_hwnd, SW_MAXIMIZE); // Show the window - SW_MAXIMIZE: set the window to fullscreen UpdateWindow(m_hwnd); } return hr; } LRESULT CALLBACK wWindow::WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { LRESULT result = 0; if (message == WM_CREATE) { LPCREATESTRUCT pcs = (LPCREATESTRUCT)lParam; wWindow *pWindow = (wWindow *)pcs->lpCreateParams; ::SetWindowLongPtrW( hwnd, GWLP_USERDATA, PtrToUlong(pWindow) ); result = 1; } else { wWindow *pWindow = reinterpret_cast<wWindow *>(static_cast<LONG_PTR>( ::GetWindowLongPtrW( hwnd, GWLP_USERDATA))); bool wasHandled = false; if (pWindow) { switch (message) { case WM_COMMAND: { // If the user makes a selection from the list: // Send CB_GETCURSEL message to get the index of the selected list item. // Send CB_GETLBTEXT message to get the item. // Display the item in a messagebox. if (HIWORD(wParam) == CBN_SELCHANGE) { int ItemIndex = SendMessage((HWND)lParam, (UINT)CB_GETCURSEL, (WPARAM)0, (LPARAM)0); TCHAR ListItem[256]; (TCHAR)SendMessage((HWND)lParam, (UINT)CB_GETLBTEXT, (WPARAM)ItemIndex, (LPARAM)ListItem); // TODO: // Do something after that } wasHandled = true; result = 0; } break; // The WM_DISPLAYCHANGE message is sent to all windows when the display resolution has changed. case WM_DISPLAYCHANGE: { InvalidateRect(hwnd, NULL, FALSE); } wasHandled = true; result = 0; break; // Destroy the window case WM_DESTROY: { PostQuitMessage(0); } wasHandled = true; result = 1; break; } } if (!wasHandled) { result = DefWindowProc(hwnd, message, wParam, lParam); } } return result; } void ComboBox::Initialize() { wWindow wWindow; // Create a instance of wWindow class //////////////////////////////////// // // // Combobox Informations // // // //////////////////////////////////// TCHAR Combobox_File[7][13] = { TEXT("New"), TEXT("Open"), TEXT("Add"), TEXT("Save Ctrl+S"), TEXT("Save As..."), TEXT("Save All"), TEXT("Exit Alt+F4") }; // Create the parameters for FILE Combobox // // Uses the CreateWindow function to create a child window of // the application window. The WC_COMBOBOX window style specifies // that it is a combobox. int xPos = 100; // Horizontal position of the window int yPos = 100; // Vertical position of the window int nWidth = 200; // Width of the window int nHeight = 200; // Height of the window hWndParent = wWindow.getHwnd(); // Get the window from the Window Class // Create the Combobox_File hWndComboBox_File = CreateWindow(WC_COMBOBOX, TEXT(""), CBS_DROPDOWN | CBS_HASSTRINGS | WS_CHILD | WS_VISIBLE, xPos, yPos, nWidth, nHeight, hWndParent, NULL, HINST_THISCOMPONENT, NULL); TCHAR A[17]; int k = 0; memset(&A, 0, sizeof(A)); // Go trough every TEXT in the string for (k = 0; k <= 8; k += 1) { // Copies a string _tcscpy_s(A, sizeof(A) / sizeof(TCHAR), (TCHAR*)Combobox_File[k]); // Add string to combobox SendMessage(hWndComboBox_File, (UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)A); } // Send the CB_SETCURSEL message to display an initial item // in the selection field SendMessage(hWndComboBox_File, CB_SETCURSEL, (WPARAM)2, (LPARAM)0); return; } int WINAPI WinMain( HINSTANCE /* hInstance */, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int) /* nCmdShow */ { HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); if (SUCCEEDED(CoInitialize(NULL))) { { wWindow app; if (SUCCEEDED(app.Initialize())) { app.RunMessageLoop(); } } CoUninitialize(); } return 0; }
  6. WinAPI Combo Box wont show

    @Amr0   How do I call the InitCommonControlsEx? I only find this https://msdn.microsoft.com/en-us/library/windows/desktop/bb775507(v=vs.85).aspx but I dont know how to use it  :rolleyes:   Can I make it this way? Because I get an error.   Severity Code Description Project File Line Suppression State Error LNK2019 Reference to non-resolved external symbol "__imp_InitCommonControlsEx" in function "WinMain". INITCOMMONCONTROLSEX InitCtrlEx; InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX); InitCtrlEx.dwICC = ICC_LINK_CLASS, ICC_PROGRESS_CLASS; InitCommonControlsEx(&InitCtrlEx); if (!InitCommonControlsEx(&InitCtrlEx)) { int nResult = GetLastError(); MessageBox(NULL, L"Could not initialize common controls class!", L"Initialization failure", MB_ICONERROR); } EDIT: I call it in the WinMain function
  7. WinAPI Combo Box wont show

      No the combo box doesn't show at all even if I call it in the Init function of the window.   Thats my WndProc. LRESULT CALLBACK wWindow::WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { LRESULT result = 0; if (message == WM_CREATE) { LPCREATESTRUCT pcs = (LPCREATESTRUCT)lParam; wWindow *pWindow = (wWindow *)pcs->lpCreateParams; ::SetWindowLongPtrW( hwnd, GWLP_USERDATA, PtrToUlong(pWindow) ); result = 1; } else { wWindow *pWindow = reinterpret_cast<wWindow *>(static_cast<LONG_PTR>( ::GetWindowLongPtrW( hwnd, GWLP_USERDATA))); bool wasHandled = false; if (pWindow) { switch (message) { case WM_COMMAND: { // If the user makes a selection from the list: // Send CB_GETCURSEL message to get the index of the selected list item. // Send CB_GETLBTEXT message to get the item. // Display the item in a messagebox. if (HIWORD(wParam) == CBN_SELCHANGE) { int ItemIndex = SendMessage((HWND)lParam, (UINT)CB_GETCURSEL, (WPARAM)0, (LPARAM)0); TCHAR ListItem[256]; (TCHAR)SendMessage((HWND)lParam, (UINT)CB_GETLBTEXT, (WPARAM)ItemIndex, (LPARAM)ListItem); // TODO: // Do something after that } wasHandled = true; result = 0; } break; // The WM_DISPLAYCHANGE message is sent to all windows when the display resolution has changed. case WM_DISPLAYCHANGE: { InvalidateRect(hwnd, NULL, FALSE); } wasHandled = true; result = 0; break; // Destroy the window case WM_DESTROY: { PostQuitMessage(0); } wasHandled = true; result = 1; break; } } if (!wasHandled) { result = DefWindowProc(hwnd, message, wParam, lParam); } } return result; } Yes I found Spy++, now I only have to find out how it works  :rolleyes:
  8. WinAPI Combo Box wont show

    Hello Prototype   No im passing a handle for the parentwindow hWndParent = wWindow.getHwnd(); // Get the window from the Window Class // Create the Combobox_File hWndComboBox_File = CreateWindow(WC_COMBOBOX, TEXT(""), CBS_DROPDOWN | CBS_HASSTRINGS | WS_CHILD | WS_OVERLAPPED | WS_VISIBLE, xPos, yPos, nWidth, nHeight, hWndParent, // HERE NULL, HINST_THISCOMPONENT, NULL); I dont get an error, it starts the program correct and it also shows the main window with my settings for it. It seems like it doesn't get the message from the combo box but I dont know why.   EDIT: Also used the debugger to find the problem, but it works normally. The program copies the strings and then sends via the function SendMessage.
  9. WinAPI Combo Box wont show

    Thank you for your reply, I've changed it.   ^_^
  10. Hello   I have a problem with my combo box that  I've created. I've already asked in another forum, but they didn't knew the error.   Thats where I create the Combo Box and I call this Init function in the constructor. void ComboBox::Initialize() { wWindow wWindow; //////////////////////////////////// // // // Combobox Informations // // // //////////////////////////////////// TCHAR Combobox_File[7][13] = { TEXT("New"), TEXT("Open"), TEXT("Add"), TEXT("Save Ctrl+S"), TEXT("Save As..."), TEXT("Save All"), TEXT("Exit Alt+F4") }; // Create the parameters for FILE Combobox // // Uses the CreateWindow function to create a child window of // the application window. The WC_COMBOBOX window style specifies // that it is a combobox. int xPos = 100; // Horizontal position of the window int yPos = 100; // Vertical position of the window int nWidth = 200; // Width of the window int nHeight = 200; // Height of the window hWndParent = wWindow.getHwnd(); // Get the window from the Window Class // Create the Combobox_File hWndComboBox_File = CreateWindow(WC_COMBOBOX, TEXT(""), CBS_DROPDOWN | CBS_HASSTRINGS | WS_CHILD | WS_OVERLAPPED | WS_VISIBLE, xPos, yPos, nWidth, nHeight, hWndParent, NULL, HINST_THISCOMPONENT, NULL); TCHAR A[16]; int k = 0; memset(&A, 0, sizeof(A)); // Go trough every TEXT in the string for (k = 0; k <= 8; k += 1) { // Copies a string wcscpy_s(A, sizeof(A) / sizeof(TCHAR), (TCHAR*)Combobox_File[k]); // Add string to combobox SendMessage(hWndComboBox_File, (UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)A); } // Send the CB_SETCURSEL message to display an initial item // in the selection field SendMessage(hWndComboBox_File, CB_SETCURSEL, (WPARAM)2, (LPARAM)0); return; } And here I create a instance of the Combo Box. HRESULT wWindow::Initialize() { HRESULT hr; ComboBox m_comboBox; // Create a instance for ComboBox // Initialize all the combo boxes here // Create the window class. WNDCLASSEX wcex = { sizeof(WNDCLASSEX) }; wcex.style = CS_HREDRAW | CS_VREDRAW; // The class styles - CS_HREDRAW: Redraws the window if a movement changes the width of the client area. // CS_VREDRAW: Redraws the window if a movement changes the height of the client area. wcex.lpfnWndProc = wWindow::WndProc; // A pointer to the windows procedure. wcex.cbClsExtra = 0; // The number of extra bytes to allocate the window-class structure. wcex.cbWndExtra = sizeof(LONG_PTR); // The number of extra bytes to allocate following the window instance. wcex.hInstance = HINST_THISCOMPONENT; // A handle to the instance that contains the window procedure for the class. wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); // A handle to the class background brush. wcex.lpszMenuName = NULL; // Pointer to a null-terminated character string that specifies the resource name of the class menu. wcex.hCursor = LoadCursor(NULL, IDC_ARROW); // A handle to the class cursor, contains the cursor for the window. wcex.lpszClassName = TEXT("DemoApp"); // The name of the class // Register the window class. RegisterClassEx(&wcex); // Create the application window. // // Because the CreateWindow function takes its size in pixels, we // obtain the system DPI and use it to scale the window size. int dpiX = 0; int dpiY = 0; HDC hdc = GetDC(NULL); if (hdc) { dpiX = GetDeviceCaps(hdc, LOGPIXELSX); // Get the pixels from width dpiY = GetDeviceCaps(hdc, LOGPIXELSY); // Get the pixels from height ReleaseDC(NULL, hdc); } // Create the window m_hwnd = CreateWindow(TEXT("DemoApp"), // Class name. TEXT("CircuitSim"), // Window name. WS_OVERLAPPEDWINDOW |WS_HSCROLL | WS_VSCROLL, // Window style - WS_OVERLAPPEDWINDOW: The window is an overlapped window. CW_USEDEFAULT, // Use the default x position. CW_USEDEFAULT, // Use the default y position. static_cast<UINT>(ceil(640.f * dpiX / 96.f)), // Use the width, which we calculated with the pixels. static_cast<UINT>(ceil(480.f * dpiY / 96.f)), // Use the height, which we calculated with the pixels. NULL, // A handle to the parent window NULL, // A handle to a menu HINST_THISCOMPONENT, // A handle to the instance of the module this); // A pointer to a value to be passed to the window through the CREATESTRUCT structure // Check if the window passed the following checks - S_OK: Operation sucessful // E_FAIL: Unspecified failure hr = m_hwnd ? S_OK : E_FAIL; if (SUCCEEDED(hr)) { ShowWindow(m_hwnd, SW_MAXIMIZE); // Show the window - SW_MAXIMIZE: set the window to fullscreen UpdateWindow(m_hwnd); } return hr; }   Does anyone know the problem?  :huh:   Best regards MystikReasons