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