|
Sliders and Text in GUI |
moon_rabbits
Member #8,469
March 2007
|
I'm fooling around with the Allegro GUI. I quickly wrote up a program that was supposed to show a slider, and beside the slider it should show the value of the slider. It works fine, except the d_text_proc value remains at 0 no matter where the slider is positioned. Here's the source:
What am I doing wrong? |
ImLeftFooted
Member #3,935
October 2003
|
That code looks perfect to me. Maybe see what printf("%d\n", d2); outputs inside of change_value? |
moon_rabbits
Member #8,469
March 2007
|
I placed a call to printf() inside change_value() and on the console the slider's current value displayed fine, however the graphical representation did not change from 0. Also, whenever I click and drag the slider, the instant I release the program exits despite the fact that D_EXIT is not a flag. Help? |
ImLeftFooted
Member #3,935
October 2003
|
What compiler / IDE are you using? Are you comfortable with gdb? As for the not updating problem, maybe the d_text_proc needs to receive a new draw message? |
moon_rabbits
Member #8,469
March 2007
|
I'm using Dev-Cpp, and I've never touched gdb in my life. Also, how do I send another draw message to d_text_proc? |
Rampage
Member #3,035
December 2002
|
Looks like yours isn't a new problem, try reading here. -R |
ImLeftFooted
Member #3,935
October 2003
|
Rampage said: Looks like yours isn't a new problem, try reading here. We've established the function is getting called via printf, maybe this problem is a different one? You said: Also, how do I send another draw message to d_text_proc?
object_message(&the_dialog[2], MSG_DRAW, 0);
You said: I'm using Dev-Cpp, and I've never touched gdb in my life. You'll have to get mighty comfortable with it eventually.. Its a tool that helps you answer questions like this one: You said: Also, whenever I click and drag the slider, the instant I release the program exits despite the fact that D_EXIT is not a flag.
|
moon_rabbits
Member #8,469
March 2007
|
No, I removed the (void*) before change_value in the_dialog, but now I get this error: Quote: 22 invalid conversion from `int (*)(void*, int)' to `void*' And so I added the (void*) back to the callback to change_value. I tried to send a message to redraw the d_text_proc like this: d_text_proc(D_REDRAW, the_dialog, 2); But, if I call that inside change_value, it does not work because the_dialog is declared and defined after change_value is defined. If I place the_dialog's definition before change_value, I cannot compile because change_value is not defined before the_dialog, where it is called. EDIT: The problem is fixed, I declared change_value and defined it after the_dialog, and used the object_message() function that Dustin suggested. It works perfectly now. |
ImLeftFooted
Member #3,935
October 2003
|
Quote: It works perfectly now. Awesome8-) |
|