main.cpp
#include <windows.h>
#include "Resource.h"
HWND hWnd;
LRESULT CALLBACK DlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
DialogBox(hInstance, MAKEINTRESOURCE(IDD_Main),
hWnd, reinterpret_cast<DLGPROC>(DlgProc));
return FALSE;
}
LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
HWND hwStart, hwServer, hwClient;
hwStart = GetDlgItem(hWndDlg,IDC_Start);
hwServer = GetDlgItem(hWndDlg,IDC_Server);
hwClient = GetDlgItem(hWndDlg,IDC_Client);
switch(Msg)
{
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch(wParam)
{
if(IDC_Server)
{
SendMessage(hwServer, BM_SETCHECK, 1, 0);
SendMessage(hwClient, BM_SETCHECK, 0, 0);
SetWindowText(hwStart, "Listen");
}
else if(IDC_Client)
{
SendMessage(hwClient, BM_SETCHECK, 1, 0);
SendMessage(hwServer, BM_SETCHECK, 0, 0);
SetWindowText(hwStart, "Connect");
}
else if(IDC_Quit)
{
EndDialog(hWndDlg, 0);
return TRUE;
}
}
}
return FALSE;
}
Resource.h
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by WIN32D.rc
//
#define IDD_DIALOG1 101
#define IDD_Main 101
#define IDI_ICON1 103
#define IDC_Submit 1000
#define IDC_Window 1001
#define ID_Close 1004
#define IDC_Input 1005
#define IDC_Server 1006
#define IDC_Client 1007
#define IDC_Start 1008
#define IDC_Quit 1009
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1010
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
theres a warning because no case statement but thats fine for now. I cant get the buttons to work. The reason im using if/else if is because if i use case IDC_Server: etc it does all case statements then quits instead of just doing the case statement for that button.
Any ideas what im doing wrong :(