Can someone please tell me why when I check one of my boxes, and click the button I get no message box
in accordance to which checkbox I checked.
#include <windows.h>
#include <dos.h>
#include <stdlib.h>
#include <fstream>
using namespace std;
#define IDC_MAIN_BUTTON 101 // Button identifier
#define IDC_MAIN_EDIT 102 // Edit box identifier
HWND hEdit;
HWND *ptbox2;
HWND hwnd2;
HWND hwnd1;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
static char *title = TEXT("MVMG NT RESET by: Cody Oebel");
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
MSG msg ;
WNDCLASS wc = {0};
wc.lpszClassName = TEXT( "PasswordResetTool" );
wc.hInstance = hInstance ;
wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
wc.lpfnWndProc = WndProc ;
wc.hCursor = LoadCursor(0, IDC_ARROW);
RegisterClass(&wc);
CreateWindow( wc.lpszClassName, title,
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
150, 350, 430, 190, 0, 0, hInstance, 0);
while( GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch(msg)
{
case WM_CREATE:
{
// Create an edit box
hEdit=CreateWindowEx(WS_EX_CLIENTEDGE,
"EDIT",
"",
WS_CHILD|WS_VISIBLE|
ES_MULTILINE|ES_AUTOVSCROLL|ES_AUTOHSCROLL,
10,
100,
300,
50,
hwnd,
(HMENU)IDC_MAIN_EDIT,
GetModuleHandle(NULL),
NULL);
HGDIOBJ hfDefault=GetStockObject(DEFAULT_GUI_FONT);
SendMessage(hEdit,
WM_SETFONT,
(WPARAM)hfDefault,
MAKELPARAM(FALSE,0));
SendMessage(hEdit,
WM_SETTEXT,
NULL,
(LPARAM)"Enter users name");
// Create a push button
HWND hWndButton=CreateWindowEx(NULL,
"BUTTON",
"Reset Password",
WS_TABSTOP|WS_VISIBLE|
WS_CHILD|BS_DEFPUSHBUTTON,
40,
60,
290,
24,
hwnd,
(HMENU)IDC_MAIN_BUTTON,
GetModuleHandle(NULL),
NULL);
SendMessage(hWndButton,
WM_SETFONT,
(WPARAM)hfDefault,
MAKELPARAM(FALSE,0));
HWND hwnd1 = CreateWindow(TEXT("button"), TEXT("Reset Password"),
WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX,
20, 20, 200, 35,
hwnd, (HMENU) 1, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
CheckDlgButton(hwnd1, 1, BST_CHECKED);
HWND hwnd2 = CreateWindow(TEXT("button"), TEXT("Unlock"),
WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX,
225, 20, 100, 35,
hwnd, (HMENU) 1, ((LPCREATESTRUCT)lParam)->hInstance, NULL);
//ptbox2 = &hwnd2;
CheckDlgButton(hwnd2, 1, BST_CHECKED);
break;
}
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_MAIN_BUTTON:
{
BOOL checked = IsDlgButtonChecked(hwnd1, 1);
BOOL checked2 = IsDlgButtonChecked(hwnd2, 1);
if(checked)
{
MessageBox(0,
"CHECKBOX 1 ",
"OOPS",
MB_ICONINFORMATION);
};
if(checked2)
{
MessageBox(0,
"CHECKBOX 2 ",
"OOPS",
MB_ICONINFORMATION);
};
};
};
break;
case WM_DESTROY:
{
PostQuitMessage(0);
break;
}
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}