Skip to content

Commit

Permalink
Fixed printer enable at startup
Browse files Browse the repository at this point in the history
See #144
  • Loading branch information
chrisn committed Dec 27, 2024
1 parent 811f209 commit 6443aa9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
12 changes: 3 additions & 9 deletions Src/BeebWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,14 +586,7 @@ void BeebWin::ApplyPrefs()
InitTextView();

// Initialise printer
if (PrinterEnabled)
{
PrinterEnable(m_PrinterDevice.c_str());
}
else
{
PrinterDisable();
}
EnablePrinter(PrinterEnabled);

// Joysticks can only be initialised after the window is created (needs hwnd)
if (m_JoystickOption == JoystickOption::Joystick)
Expand Down Expand Up @@ -1284,6 +1277,7 @@ void BeebWin::FlashWindow()
}

/****************************************************************************/

void BeebWin::ShowMenu(bool on)
{
if (m_DisableMenu)
Expand Down Expand Up @@ -3807,7 +3801,7 @@ void BeebWin::HandleCommand(UINT MenuID)
break;

case IDM_PRINTERONOFF:
TogglePrinter();
EnablePrinter(!PrinterEnabled);
break;

case IDM_SERIAL:
Expand Down
2 changes: 1 addition & 1 deletion Src/BeebWin.h
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ class BeebWin
void SetPrinterPort(PrinterPortType PrinterPort);
void UpdatePrinterPortMenu();
bool GetPrinterFileName();
bool TogglePrinter();
bool EnablePrinter(bool Enable);
void TranslatePrinterPort();

// AVI recording
Expand Down
23 changes: 12 additions & 11 deletions Src/BeebWinIo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ void BeebWin::SetPrinterPort(PrinterPortType PrinterPort)
// disable it before changing file
if (PrinterEnabled)
{
TogglePrinter();
EnablePrinter(false);
}

// Add file name to menu
Expand All @@ -759,7 +759,7 @@ void BeebWin::SetPrinterPort(PrinterPortType PrinterPort)
{
if (PrinterEnabled)
{
TogglePrinter();
EnablePrinter(false);
}

m_PrinterPort = PrinterPort;
Expand All @@ -774,7 +774,7 @@ void BeebWin::SetPrinterPort(PrinterPortType PrinterPort)
// disable it before changing file
if (PrinterEnabled)
{
TogglePrinter();
EnablePrinter(false);
}

m_PrinterPort = PrinterPort;
Expand Down Expand Up @@ -861,15 +861,11 @@ bool BeebWin::GetPrinterFileName()

/****************************************************************************/

bool BeebWin::TogglePrinter()
bool BeebWin::EnablePrinter(bool Enable)
{
bool Success = true;

if (PrinterEnabled)
{
PrinterDisable();
}
else
if (Enable)
{
m_PrinterBuffer.clear();
KillTimer(m_hWnd, TIMER_PRINTER);
Expand All @@ -895,9 +891,14 @@ bool BeebWin::TogglePrinter()
Success = PrinterEnable(m_PrinterDevice.c_str());
}
}
else
{
PrinterDisable();
}

if (Success)
{
PrinterEnabled = Enable;
CheckMenuItem(IDM_PRINTERONOFF, PrinterEnabled);
}

Expand Down Expand Up @@ -1581,13 +1582,13 @@ void BeebWin::OnCopy()
{
if (PrinterEnabled)
{
TogglePrinter();
EnablePrinter(false);
}

m_PrinterPort = PrinterPortType::Clipboard;

TranslatePrinterPort();
TogglePrinter(); // Turn printer back on
EnablePrinter(true); // Turn printer back on
UpdatePrinterPortMenu();

m_PrinterBuffer.clear();
Expand Down

0 comments on commit 6443aa9

Please sign in to comment.