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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
void ComboBox::Initialize()
{
wWindow window;
////////////////////////////////////
// //
// Combobox Informations //
// //
////////////////////////////////////
TCHAR Combobox_File[9][16] =
{
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
HWND hWndParent = window[0]; // Get the window from the Window Class
// Create the Combobox_File
HWND 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;
}
|