Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / Printing wxTextCtrl content

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Printing wxTextCtrl content
#4140
Posted by: DaRkZeAlOt 2004-05-16 23:54:28
Hi,
I'm working on a small text editor and played around a bit with the printing functions. My problem is the if i want to print the content of a wxTextCtrl the debugger shows me the following error message :

=========================================================================
Program has received a signal-name="SIGSEGV",signal-meaning="Segmentation fault" at MyFrame::Draw(wxDC&)({name="this",value="0x0"},{name="dc",value="@0x19eb4f0"}), file f:\Programmierung\Apps\SmartEdit\main.cpp:622
=========================================================================

The line caused it is (textFenster is a wxTextCtrl...) :
=========================================================================
dc.DrawText(textFenster->GetValue(), 100, 100);
=========================================================================

There are no problems printing any other strings. Made i only a small mistake or is that the compledly wrong way trying to print a wxTextCtrl ?
Message2. Re: Printing wxTextCtrl content
#4155
Posted by: upCASE 2004-05-17 15:08:13
Hi!
{name="this",value="0x0"}
If "this" is NULL, that's pretty bad :)
Check if you deleted some pointer accidentaly or pass a NULL pointer.
upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message3. Re: Printing wxTextCtrl content
#4159
Posted by: DaRkZeAlOt 2004-05-17 19:38:45
As far i can see that i haven't. But take a look yourself ... :

============================================================================
// Funktion zum Zeichnen der Seite [Function for drawing the page]
void MyFrame::Draw(wxDC& dc)
  {
  dc.SetBackground(*wxWHITE_BRUSH);
  dc.Clear();
  dc.SetFont(wxFont(30, wxSWISS, wxNORMAL, wxNORMAL, FALSE, _T("Lucida Console")));   
  wxString egal = textFenster->GetValue();
  dc.DrawText(egal, 100, 100);
  }

// Funktion zum Drucken der Seite [Function for printing the page]
bool MyPrintout::OnPrintPage(int page)
  {
  wxDC *dc = GetDC();
  if (dc)
    {
    dc->SetDeviceOrigin(0, 0);
    dc->SetUserScale(1.0, 1.0);       
    frame->Draw(*dc);
    return TRUE;
    }
  else
    return FALSE;
  }
============================================================================

That is the core printing code. Looks right, doesn't it ?
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Thu 2024-3-28  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0