If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
wunekky
In need of some credit
Posts: 8 Joined: Wed May 13, 2009 12:30 am
Post
by wunekky » Wed May 13, 2009 4:01 am
MouseEvent:
Code: Select all
void CalculateDlg::OnMouse(wxMouseEvent &event)
{
wxPoint pt(event.GetPosition());
if((pt.x>0)&&(pt.x<68)&&(pt.y>165)&&(pt.y<165+60)&&(event.LeftDown()))
{
ButtonSel = num1;
}
if(event.LeftDown())
ButtonSel = num1;
}
paint:
Code: Select all
if(ButtonSel==num1)
{
wxBufferedPaintDC mydc(this);
mydc.SetPen(*wxBLACK_PEN);
mydc.SetBrush(wxColour(255,155,0)/**wxRED_BRUSH*/);
DrawTextString(mydc,wxT("test"),wxPoint(50,50) );
}
why "test" cann't paint in dialog?
come form china;
van_user
Experienced Solver
Posts: 55 Joined: Wed Jun 11, 2008 9:28 pm
Location: UA
Post
by van_user » Wed May 13, 2009 5:51 am
Try to call "Invalidate" or "Refresh" methods. Also for test set if statement to "true".
wunekky
In need of some credit
Posts: 8 Joined: Wed May 13, 2009 12:30 am
Post
by wunekky » Wed May 13, 2009 6:10 am
thinks,then like this:
MouseEvent:
Code: Select all
void CalculateDlg::OnMouse(wxMouseEvent &event)
{
wxPoint pt(event.GetPosition());
if(event.LeftDown())
ButtonSel = 1;
}
Paint:
Code: Select all
if(ButtonSel==1)
{
wxBufferedPaintDC mydc(this);
wxFont font(30,wxFONTFAMILY_SCRIPT ,wxNORMAL,wxBOLD);
mydc.SetFont(font);
mydc.SetTextForeground(*wxRED);
mydc.DrawText(wxT("test"),wxPoint(50,50));
}
if the segment set 1,it can paint,so why the segment not equ 1?
come form china;
van_user
Experienced Solver
Posts: 55 Joined: Wed Jun 11, 2008 9:28 pm
Location: UA
Post
by van_user » Wed May 13, 2009 6:30 am
Do you hit left button on the mouse?
Do you clear "ButtonSel" when not event.LeftDown()?
"LeftDown - Returns true if the left mouse button changed to down." Maybe if button state is already down then method return false?
wunekky
In need of some credit
Posts: 8 Joined: Wed May 13, 2009 12:30 am
Post
by wunekky » Wed May 13, 2009 6:47 am
Do you hit left button on the mouse?
of course.
Do you clear "ButtonSel" when not event.LeftDown()?
the ButtonSel is a global variable ,just used in this place.
"LeftDown - Returns true if the left mouse button changed to down." Maybe if button state is already down then method return false?
if button state is already down,the ButtonSel will be set to 1,then it will keep 1.
Mouse up,the if segment will be false ,but the ButtonSel's value still is 1.why it cann't paint?
come form china;
van_user
Experienced Solver
Posts: 55 Joined: Wed Jun 11, 2008 9:28 pm
Location: UA
Post
by van_user » Wed May 13, 2009 7:03 am
wunekky wrote:
if button state is already down,the ButtonSel will be set to 1,then it will keep 1.
Mouse up,the if segment will be false ,but the ButtonSel's value still is 1.why it cann't paint?
I have only 2 versions:
1 - ButtonSel never set to 1
2 - ButtonSel somewhere set to not 1.
Without code I can`t say more.
Try debugger - stop on
and inspect value of ButtonSel or output message with its value using cout/printf or MessageBox.
wunekky
In need of some credit
Posts: 8 Joined: Wed May 13, 2009 12:30 am
Post
by wunekky » Wed May 13, 2009 7:17 am
debugger:the value if ButtonSel set to 1.
just like the string will be paint,but then it will be cover with something.
come form china;
van_user
Experienced Solver
Posts: 55 Joined: Wed Jun 11, 2008 9:28 pm
Location: UA
Post
by van_user » Wed May 13, 2009 7:53 am
wunekky wrote: just like the string will be paint,but then it will be cover with something.
I don`t think so: you said that if statement of
Code: Select all
if(ButtonSel==1)
{ wxBufferedPaintDC mydc(this);
...
mydc.DrawText(wxT("test"),wxPoint(50,50));}
set to true programme work well - why something don`t cover your text in that case? But maybe I am wrong. Need code to test.
wunekky
In need of some credit
Posts: 8 Joined: Wed May 13, 2009 12:30 am
Post
by wunekky » Wed May 13, 2009 8:29 am
add Refresh,it work on.
Code: Select all
void CalculateDlg::OnMouse(wxMouseEvent &event)
{
wxPoint pt(event.GetPosition());
if(event.LeftDown())
{
ButtonSel = 1;
Refresh();
}
}
but when the mouse down,i have a flicker.
come form china;
van_user
Experienced Solver
Posts: 55 Joined: Wed Jun 11, 2008 9:28 pm
Location: UA
Post
by van_user » Wed May 13, 2009 10:51 am
wunekky wrote:
but when the mouse down,i have a flicker.
Try this:
Code: Select all
void CalculateDlg::OnMouse(wxMouseEvent &event)
{
wxPoint pt(event.GetPosition());
if( ButtonSel != 1 && event.LeftDown())
{
ButtonSel = 1;
Refresh();
}
}
wunekky
In need of some credit
Posts: 8 Joined: Wed May 13, 2009 12:30 am
Post
by wunekky » Wed May 13, 2009 11:12 am
maybe casuse of PNG image...
come form china;