Original Post
I''m was going to use MFC, but I decided to use Win32 for now, although I''d like to learn how to hand-code MFC, I don''t like using the appwizard much. I have a new problem now. I''ve done lots of opengl apps, but I never used controls other than buttons and such. With this source code:
How would I go about adding options to my listbox, and getting the output when it returns what they picked. Thank you in advance.
#include <windows.h>
#define WINWIDTH 500
#define WINHEIGHT 700
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
HWND hMainWnd, IdentStatic, IdentEdit, CanStatic, CanList;
WNDCLASSEX wcex;
MSG msg;
wcex.cbClsExtra = 0;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.cbWndExtra = 0;
wcex.hbrBackground = (HBRUSH)COLOR_BACKGROUND;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wcex.hIconSm = NULL;
wcex.hInstance = hInstance;
wcex.lpfnWndProc = WndProc;
wcex.lpszClassName = "InlandMainWnd";
wcex.lpszMenuName = NULL;
wcex.style = CS_VREDRAW|CS_HREDRAW;
RegisterClassEx(&wcex);
hMainWnd = CreateWindow("InlandMainWnd", "Inland Services - Main Viewer", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, WINWIDTH, WINHEIGHT, NULL, NULL, hInstance, NULL);
IdentStatic = CreateWindow("STATIC", "Indentifier:", WS_CHILD|WS_VISIBLE, 30, 30, 75, 18,
hMainWnd, NULL, hInstance, NULL);
IdentEdit = CreateWindow("EDIT", " ", WS_CHILD|WS_VISIBLE, 110, 30, 350, 18,
hMainWnd, NULL, hInstance, NULL);
CanStatic = CreateWindow("STATIC", "Can Size:", WS_CHILD|WS_VISIBLE, 30, 50, 75, 18, hMainWnd,
NULL, hInstance, NULL);
CanList = CreateWindow("LISTBOX", "60 Gallon", WS_CHILD|WS_VISIBLE, 110, 50, 100, 18, hMainWnd,
NULL, hInstance, NULL);
if(!hMainWnd)
MessageBox(NULL, "Create Window Failed", "ERROR", MB_OK);
ShowWindow(hMainWnd, nShowCmd);
UpdateWindow(hMainWnd);
while(true)
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if(msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return EXIT_SUCCESS;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_QUIT:
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_KEYDOWN:
switch(wParam)
{
case VK_ESCAPE:
PostQuitMessage(0);
}
break;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}