WriteLog contest module development – Part 6: Contest Parameter Dialog Box

In the last part, I posted a link to the source code of the module up to this point. The code compiles and creates a working module. Have a look.

The contest module needs some information from the op, namely their SKCC number and QTH. This dialog box is in the resources for the project. Edit the dialog box so that it has two fields, one for QTH and one for SKCC number. Change the style of the input boxes for uppercase entry.

Create an identifier for the input field IDC_SKCC. Leave the ID for the QTH as IDC_MYMULT. Please be diligent and set the tab order for the inputs and buttons. Search for m_MyMult in all files and in the class implementation, create the new property for SKCC everywhere m_MyMult is found (just going down the list of what was found). Duplicate the action taken with m_MyMult for m_MySKCC. For example, in the ScoreDlg() method, add the lines for the contest parameters.

int
CSKCC_WES::ScoreDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
int Command;

switch(message)
{
case WM_INITDIALOG:
SetDlgItemText(hDlg, IDC_MYMULT, m_MyMult);
SetDlgItemText(hDlg, IDC_MYSKCC, m_MySKCC);
Edit_LimitText(GetDlgItem(hDlg, IDC_MYMULT),
sizeof(m_MyMult) - 1);
Edit_LimitText(GetDlgItem(hDlg, IDC_MYSKCC),
sizeof(m_MySKCC) - 1);
return TRUE;

case WM_COMMAND:
Command = GET_WM_COMMAND_ID(wParam, lParam);
switch (Command)
{
case IDOK:
GetDlgItemText(hDlg, IDC_MYMULT, m_MyMult, sizeof(m_MyMult));
GetDlgItemText(hDlg, IDC_MYSKCC, m_MySKCC, sizeof(m_MySKCC));
case IDCANCEL:
EndDialog(hDlg, Command);
return TRUE;
}
break;
}
return FALSE;
}

Change the UserWrite() and UserRead() methods to save the new property when the contest is saved to a file.

HRESULT
CSKCC_WESPersistStore::UserWrite(IStream FAR *s)
{
HRESULT hres = S_OK;
CSKCC_WES FAR *Mmd;
Mmd = (CSKCC_WES FAR *) UnkOuter;
hres = s->Write(Mmd->m_MyMult, sizeof(Mmd->m_MyMult), NULL);
hres = s->Write(Mmd->m_MySKCC, sizeof(Mmd->m_MySKCC), NULL);
return hres;
}
HRESULT
CSKCC_WESPersistStore::UserRead(IStream FAR *s)
{
HRESULT hres = S_OK;
CSKCC_WES FAR *Mmd;
Mmd = (CSKCC_WES FAR *) UnkOuter;
hres = s->Read(Mmd->m_MyMult, sizeof(Mmd->m_MyMult), NULL);
hres = s->Read(Mmd->m_MySKCC, sizeof(Mmd->m_MySKCC), NULL);
return hres;
}

The secret to prompting for contest parameters on opening a new contest

Call the Score(Configuration_Entry_t *, HWND, int, const char *) method with null parameters. The InitQsoData() method seems to be a safe place because the contest log has been initialized. If you do this in InitQsoData(), you can check to see if the contest parameters have been set because either the op read in a saved log or they started a new one. Use a global flag to make sure you don’t repeat the prompt when InitQsoData() is called again. I created a class property called m_ParamPromptDone and initialized it to 0 in the constructor and flipped it to 1 after I prompted for parameters. That way the prompt only comes up when blank and hasn’t been presented to the op yet when the log is first created or opened. Just don’t save that property in the UserWrite() method of the persistant storage class. Here’s the code I put in IniQsoData():

if (((strlen(m_MyMult) < 2) || (strlen(m_MySKCC) < 3)) && !(m_ParamPromptDone)) { Score(0, 0, 0, "") m_ParamPromptDone = 1; }

Found a little secret on this leg of the journey that makes the contest module all that much more practical to use. Next, we’ll explore how to calculate the running score as Q’s are logged.

SKCC WES Contest Module as of 2006-06-15

WriteLog is Copyright © 1992-2009 by Wayne E. Wright, W5XD.

Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.

Leave a Reply