Take Edit Control Value and apply it on a button? Topic is solved

If you are using wxDev-C++ for your wxWidgets design, please ask your questions here instead of in IDE Related.
Post Reply
WxNoob
Earned a small fee
Earned a small fee
Posts: 15
Joined: Mon Jan 28, 2008 7:03 pm

Take Edit Control Value and apply it on a button?

Post by WxNoob » Mon Jan 28, 2008 7:13 pm

Hello, first of all, im just discovered this forum, and i have been taking a look for a while and i think this forum is quite complete hehe congratulations to their creators :D

Hummm....other thing i have to say is that im spanish and maybe i will do some gramatical mistakes on my posts, but i have a quite high level of english, so i will try to explain myself as well as i will can...

Well..here we go with my question now...

I started to use WxDevC++ recently and i did some basic programmes, but now i`m trying to do a simple programe for open websites...

I have the interface of my programme done, but the problem is the next...

Im trying to do a programme where you write a web page, into a textbox, and there are other button and when you click on it, the web page that you have written into the textbox gets open....

The problem is that i dont know how can i link the editcontrol and the button, because i want that when i push the button the programme will open my explorer and bring me to the web i have written into the textbox...

I mean...catch the webpage into a variable or something like that and apply it to the button...

Can someone give me a little help please? Explain me the things as slow and clear as possible, remember i`m a begginer in WxDevC++ stuff :roll:

Thanx!!

Sof_T
Can't get richer than this
Can't get richer than this
Posts: 864
Joined: Thu Jul 28, 2005 9:48 pm
Location: New Forest, United Kingdom
Contact:

Post by Sof_T » Mon Jan 28, 2008 7:55 pm

Hola

Bienvenida a wxForum.

To make the program you describe.

1. Double Click on the button on your frame and it will take you to the code for your button.

2. Add this code into your function
// insert your code here
wxLaunchDefaultBrowser(WxTextCtrl1->GetValue(), int flags = 0);
Change the name WxTextCtrl1 for the name of your text control. The function GetValue() returns a wxString which contains the web address that the person has typed in.

See http://www.wxwidgets.org/manuals/stable ... rlgetvalue
and
http://www.wxwidgets.org/manuals/stable ... ultbrowser

I hope this helps.

Sof.T
The home of Sof.T http://www.sof-t.site88.net/
Author of Programming with wxDevC++
http://sourceforge.net/projects/wxdevcpp-book/

WxNoob
Earned a small fee
Earned a small fee
Posts: 15
Joined: Mon Jan 28, 2008 7:03 pm

Post by WxNoob » Tue Jan 29, 2008 6:34 pm

Image

Thanx for the given help, but, as you can see in the screenshot, i put the code you gave me in the button and it says that there are serveral errors...

The code i put into the button was
wxLaunchDefaultBrowser(WxTextCtrl1->GetValue(), int flags = 0);
After erasing the "Insert your code here" thing of course...

So...what can i have been doing bad?
Last edited by WxNoob on Tue Jan 29, 2008 6:39 pm, edited 1 time in total.

Sof_T
Can't get richer than this
Can't get richer than this
Posts: 864
Joined: Thu Jul 28, 2005 9:48 pm
Location: New Forest, United Kingdom
Contact:

Post by Sof_T » Tue Jan 29, 2008 6:36 pm

The image is not showing, can you post a list of the errors?
The home of Sof.T http://www.sof-t.site88.net/
Author of Programming with wxDevC++
http://sourceforge.net/projects/wxdevcpp-book/

WxNoob
Earned a small fee
Earned a small fee
Posts: 15
Joined: Mon Jan 28, 2008 7:03 pm

Post by WxNoob » Tue Jan 29, 2008 6:40 pm

Sorry, i was bringing up the image just when you post an ansew here hehe can you see the image now? :)

Sof_T
Can't get richer than this
Can't get richer than this
Posts: 864
Joined: Thu Jul 28, 2005 9:48 pm
Location: New Forest, United Kingdom
Contact:

Post by Sof_T » Tue Jan 29, 2008 8:49 pm

Sorry my mistake :oops:

Try this:

Code: Select all

wxLaunchDefaultBrowser(WxTextCtrl1->GetValue()); 
Sof.T
The home of Sof.T http://www.sof-t.site88.net/
Author of Programming with wxDevC++
http://sourceforge.net/projects/wxdevcpp-book/

WxNoob
Earned a small fee
Earned a small fee
Posts: 15
Joined: Mon Jan 28, 2008 7:03 pm

Post by WxNoob » Wed Jan 30, 2008 7:16 pm

C:\Documents and Settings\****\Escritorio\Makefile.win [Build Error] exe: *** [Objects/MingW/GeoforceDlg.o] Error 1

C:\Documents and Settings\***\Escritorio\GeoforceDlg.cpp In member function `void GeoforceDlg::WxButton1Click(wxCommandEvent&)':

74 C:\Documents and Settings\***\Escritorio\GeoforceDlg.cpp `WxTextCtrl1' undeclared (first use this function)

(Each undeclared identifier is reported only once for each function it appears in.)

I tried with your new code and here you have the errors it shows me when i try to compile...

I tried a lot of ways, but i can

Sof_T
Can't get richer than this
Can't get richer than this
Posts: 864
Joined: Thu Jul 28, 2005 9:48 pm
Location: New Forest, United Kingdom
Contact:

Post by Sof_T » Wed Jan 30, 2008 7:34 pm

You need to change the part of the code that reads WxTextCtrl1 to be the same as the name of your text ctrl that the user types the url into. (My code was just an example). To find the name of the text ctrl look in the properties panel under Name when you select it.

Sof.T
The home of Sof.T http://www.sof-t.site88.net/
Author of Programming with wxDevC++
http://sourceforge.net/projects/wxdevcpp-book/

WxNoob
Earned a small fee
Earned a small fee
Posts: 15
Joined: Mon Jan 28, 2008 7:03 pm

Post by WxNoob » Thu Jan 31, 2008 7:29 pm

You need to change the part of the code that reads WxTextCtrl1 to be the same as the name of your text ctrl that the user types the url into.
You mean that i have to change the name of the Name Propiety of the button?

Image

I have to change the propiety that i have underlined in the picture?

I called the button WxButton1 and then i tried with this code

wxLaunchDefaultBrowser(WxButton1->GetValue());
But it still doesnt works...

WxNoob
Earned a small fee
Earned a small fee
Posts: 15
Joined: Mon Jan 28, 2008 7:03 pm

Post by WxNoob » Sun Feb 03, 2008 6:19 pm

Finally i did it !! :D :D

Thanks everybody really!! :P :P

buildere
Super wx Problem Solver
Super wx Problem Solver
Posts: 358
Joined: Thu Oct 28, 2004 3:45 pm
Location: Costa Rica

Post by buildere » Tue Feb 05, 2008 1:58 am

Please, mark the post as solved by sofT. That makes it easier for other to find answers.

Sof_T
Can't get richer than this
Can't get richer than this
Posts: 864
Joined: Thu Jul 28, 2005 9:48 pm
Location: New Forest, United Kingdom
Contact:

Post by Sof_T » Thu Feb 07, 2008 7:54 pm

I'm glad you solved the problem. I'm sorry I didn't answer your last question, but I have been on holiday in Spain for a week.

Sof.T
The home of Sof.T http://www.sof-t.site88.net/
Author of Programming with wxDevC++
http://sourceforge.net/projects/wxdevcpp-book/

WxNoob
Earned a small fee
Earned a small fee
Posts: 15
Joined: Mon Jan 28, 2008 7:03 pm

Post by WxNoob » Fri Feb 08, 2008 7:47 pm

Dont worry Soft hehe, it is a really nice forum, one of the best i have ever seen, and the best thing is that there are a lot of people that gives help to noobs like me hehe, thanks a lot, i had added this site to my favourites sites, :P

See ya !!

Post Reply