Issues on code (radio buttons)
Posted: Wed Jul 25, 2018 5:25 pm
Hi,
I posted this topic on Support section since this is related to Win32 API, foremost ReactOS. I am trying to implement a small feature which is a dialog with radio buttons that you can either enable or disable AUTOCHK on startup. For the moment I have only implemented the visuals part and not the functionality itself yet.
Even though the visuals are rather a playground for most, I'm struggling a lot to get things done. To begin with, here's the code:
I have two problems with it. First, the visual work however the General dialog sheet is overridden by the Auto Check dialog and I have no idea whatsoever why it does do this. Here's an image link below if you do not know what I mean.
URL Image: https://imgur.com/a/5dkjgen
As you can see, it gets created a new dialog on the right after Tools dialog (which is good) but it just overrides the first dialog which is supposed to be the General dialog. And the second problem is whenever I compile the code it complains about an error like below:
The file above is the C header for autochkpage.c main code. I did a double check on the header and again, I couldn't find anything wrong so I have no idea what's happening. In fact, I had to comment #include "autochkpage.h" in order to compile the code successfully.
Here's the code both of the header and the dialog sheet:
Header
Dialog Sheet
Before you may ask, all the code you see I implemented it on msconfig_new. Hopefully someone can help me.
EDIT: If someone is looking for the whole code instead, here's the link.
https://github.com/Fraizeraust/reactos/ ... chk-dialog
Thank you
I posted this topic on Support section since this is related to Win32 API, foremost ReactOS. I am trying to implement a small feature which is a dialog with radio buttons that you can either enable or disable AUTOCHK on startup. For the moment I have only implemented the visuals part and not the functionality itself yet.
Even though the visuals are rather a playground for most, I'm struggling a lot to get things done. To begin with, here's the code:
Code: Select all
#include "autochkpage.h"
#include "resource.h"
#include "precomp.h"
HWND h1RadioButton;
HWND h2RadioButton;
BOOL bIsEnabled = TRUE;
HWND hAutoChkPage = NULL;
INT_PTR CALLBACK
AutoChkPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam);
UNREFERENCED_PARAMETER(wParam);
h1RadioButton = GetDlgItem(hDlg, IDC_AUTOCHK_ENABLE);
h2RadioButton = GetDlgItem(hDlg, IDC_AUTOCHK_DISABLE);
switch (message)
{
case WM_INITDIALOG:
{
hAutoChkPage = hDlg;
return TRUE;
}
case WM_COMMAND:
{
switch ( LOWORD(lParam) )
{
case IDC_AUTOCHK_ENABLE:
{
SendMessage(h1RadioButton, BM_SETCHECK, 1,0);
SendMessage(h2RadioButton, BM_SETCHECK, 0,0);
bIsEnabled = TRUE;
break;
}
case IDC_AUTOCHK_DISABLE:
{
SendMessage(h1RadioButton, BM_SETCHECK, 0,0);
SendMessage(h2RadioButton, BM_SETCHECK, 1,0);
bIsEnabled = FALSE;
break;
}
}
break;
}
case WM_NOTIFY:
{
switch ( ((LPNMHDR)lParam)->code )
{
case PSN_APPLY:
{
SetWindowLongPtr(hAutoChkPage, DWLP_MSGRESULT, PSNRET_NOERROR);
PropSheet_UnChanged(GetParent(hAutoChkPage), hAutoChkPage);
return TRUE;
}
case PSN_HELP:
{
MessageBoxW(hAutoChkPage, L"Help not implemented yet!", L"Help", MB_ICONINFORMATION | MB_OK);
return TRUE;
}
case PSN_KILLACTIVE: // Is going to lose activation.
{
// Changes are always valid of course.
SetWindowLongPtr(hAutoChkPage, DWLP_MSGRESULT, FALSE);
return TRUE;
}
case PSN_QUERYCANCEL:
{
// Allows cancellation.
SetWindowLongPtr(hAutoChkPage, DWLP_MSGRESULT, FALSE);
return TRUE;
}
/*
* DO NOT TOUCH THESE NEXT MESSAGES, THEY ARE OK LIKE THIS...
*/
case PSN_RESET: // Perform final cleaning, called before WM_DESTROY.
return TRUE;
case PSN_SETACTIVE: // Is going to gain activation.
{
SetWindowLongPtr(hAutoChkPage, DWLP_MSGRESULT, 0);
return TRUE;
}
}
return FALSE;
}
default:
return FALSE;
}
return FALSE;
}
URL Image: https://imgur.com/a/5dkjgen
As you can see, it gets created a new dialog on the right after Tools dialog (which is good) but it just overrides the first dialog which is supposed to be the General dialog. And the second problem is whenever I compile the code it complains about an error like below:
Code: Select all
/home/fraizeraust/ReactOS/Fork/reactos/base/applications/msconfig_new/autochkpage.h:11:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'AutoChkPageWndProc'
Here's the code both of the header and the dialog sheet:
Header
Code: Select all
#ifndef _AUTOCHKPAGE_H_
#define _AUTOCHKPAGE_H_
INT_PTR CALLBACK AutoChkPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
#endif /* _AUTOCHKPAGE_H_ */
Code: Select all
/* Auto Check page */
psp[nPages].dwSize = sizeof(PROPSHEETPAGEW);
psp[nPages].dwFlags = PSP_HASHELP;
psp[nPages].hInstance = hInstance;
psp[nPages].pszTemplate = MAKEINTRESOURCEW(IDD_GENERAL_PAGE);
psp[nPages].pfnDlgProc = AutoChkPageWndProc;
++nPages;
EDIT: If someone is looking for the whole code instead, here's the link.
https://github.com/Fraizeraust/reactos/ ... chk-dialog
Thank you