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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
#include <windows.h>
#include <commctrl.h>
#define ARRAYSIZE(sel) (sizeof(sel) / sizeof(sel[0]))
#define IDC_LIST_BOX 1000
#define IDC_COMBO_BOX1 1001
// Sockets Structure
typedef struct
{
CHAR SocketsNr[4];
}SOCKETS;
SOCKETS sockets[] =
{
{TEXT("2")}, {TEXT("3")}, {TEXT("4")}, {TEXT("5")}, {TEXT("6")}, {TEXT("All")}
};
// RuneWords Structure
typedef struct
{
CHAR Name[30];
}RUNEWORDS;
RUNEWORDS runewords[] =
{
{TEXT("Leaf")}, {TEXT("Lore")}, {TEXT("Nadir")}, {TEXT("Rhyme")}, {TEXT("Smoke")}, {TEXT("Stealth")}, {TEXT("Steel")},
{TEXT("Strength")}, {TEXT("White")}, {TEXT("Zephyr")}, {TEXT("Prudence")}, {TEXT("Splendor")}, {TEXT("Wind")}
};
void createCotrols(HWND);
HWND hMainWindow, hRwList, combo1;
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
{
createCotrols(hwnd);
CHAR buff[5];
memset(&buff, 0, sizeof(buff));
for(UINT i = 0; i < ARRAYSIZE(sockets); i++)
{
strncpy(buff, sockets[i].SocketsNr, sizeof(buff)/sizeof(CHAR));
SendMessage(combo1, CB_ADDSTRING, 0, (LPARAM)buff);
}
}break;
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case IDC_COMBO_BOX1:
{
if(HIWORD(wParam == CBN_SELCHANGE))
{
combo1 = GetDlgItem(hwnd, IDC_COMBO_BOX1);
int ItemIndex = SendMessage((HWND)lParam, (UINT)CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
if(ItemIndex == 0)
{
hRwList = GetDlgItem(hwnd, IDC_LIST_BOX);
for(UINT i = 0; i < ARRAYSIZE(runewords); i++)
{
int pos = (int)SendMessage(hRwList, LB_ADDSTRING, 0, (LPARAM)runewords[i].Name);
SendMessage(hRwList, LB_SETITEMDATA, pos, (LPARAM)i);
}
SetFocus(hRwList);
}
}
}break;
return (0);
}
}break;
}break;
case WM_CLOSE:
{
DestroyWindow(hwnd);
}break;
case WM_DESTROY:
{
PostQuitMessage(0);
}break;
default:
return(DefWindowProcA(hwnd, msg, wParam, lParam));
}
return(0);
}
void createCotrols(HWND hwnd)
{
hRwList = CreateWindowA(WC_LISTBOXA, NULL, WS_VISIBLE | WS_CHILD | LBS_STANDARD | LBS_NOTIFY,
600, 40, 175, 200, hwnd, (HMENU)IDC_LIST_BOX, NULL, NULL);
combo1 = CreateWindowA(WC_COMBOBOXA, NULL, WS_VISIBLE | WS_CHILD | CBS_HASSTRINGS | CBS_DROPDOWNLIST,
30, 40, 150, 200, hwnd, (HMENU)IDC_COMBO_BOX1, NULL, NULL);
}
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR args, int nCmdShow)
{
InitCommonControls();
WNDCLASSA wc = {};
.
..
...
return (0);
}
|