Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » Using value from EditInt
Using value from EditInt [message #2931] Sun, 30 April 2006 21:15 Go to next message
BenP is currently offline  BenP
Messages: 2
Registered: April 2006
Junior Member
Hi,

I am creating a helpdesk with U++ and I have a dialog box where I will enter a ticket ID to lookup(below)
http://img270.imageshack.us/img270/2040/lookupticket8up.jpg

I then have a function EditTicket(int ticket_id) which retrieves the ticket info and allows me to edit it but I have a problem with passing what is in the edit box to my function.

I have tried the following but with no success
d.TicketLookupBtn <<= THISBACK1(EditTicket, d.TicketLookupBox);


How do I use what is in the edit box and pass it to my function?
Re: Using value from EditInt [message #2932 is a reply to message #2931] Sun, 30 April 2006 22:27 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
void MyApp::EditTicket()
{
    int q = ~ticketLookupBox;
}

MyApp::MyApp()
{
    TicketLookupButton <<= THISBACK(EditTicket);
}


Hope that helps..

Mirek
Re: Using value from EditInt [message #2935 is a reply to message #2931] Sun, 30 April 2006 23:52 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1189
Registered: March 2006
Location: Italy
Senior Contributor
BenP wrote on Sun, 30 April 2006 21:15

Hi,
I have tried the following but with no success
d.TicketLookupBtn <<= THISBACK1(EditTicket, d.TicketLookupBox);


How do I use what is in the edit box and pass it to my function?


To get the data associated with the widget myWidget you can use the operator '~'. For example a = ~myWidget as showed above.
When you need to set some value use the operator '<<='. For example:
myWidget <<= data;
In your case I think you can use
d.TicketLookupBtn <<= THISBACK1(EditTicket,  ~d.TicketLookupBox);

Let us know if you resolved the problem.
Luigi

[Updated on: Sun, 30 April 2006 23:55]

Report message to a moderator

Re: Using value from EditInt [message #2936 is a reply to message #2935] Mon, 01 May 2006 00:05 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
forlano wrote on Sun, 30 April 2006 17:52

BenP wrote on Sun, 30 April 2006 21:15

Hi,
I have tried the following but with no success
d.TicketLookupBtn <<= THISBACK1(EditTicket, d.TicketLookupBox);


How do I use what is in the edit box and pass it to my function?


To get the data associated with the widget myWidget you can use the operator '~'. For example a = ~myWidget as showed above.
When you need to set some value use the operator '<<='. For example:
myWidget <<= data;
In your case I think you can use
d.TicketLookupBtn <<= THISBACK1(EditTicket,  ~d.TicketLookupBox);

Let us know if you resolved the problem.
Luigi


No, this is wrong - you would call EditTicket with TicketLookupBox value extracted at the moment of THISBACK1 creation, not the current value!

Mirek
Re: Using value from EditInt [message #2954 is a reply to message #2931] Mon, 01 May 2006 12:19 Go to previous messageGo to next message
BenP is currently offline  BenP
Messages: 2
Registered: April 2006
Junior Member
Neither of the above examples worked Sad I will give snippets of my code in the hope it may help.
LookupTicket() is the function which shows the lookup dialog(see first post) and EditTicket(int ticket_id) will give me a dialog to update the ticket. The ticket_id parameter must be passed to the EditTicket function so it can get data for the correct ticket.
void Helpdesk::LookupTicket()
{
	WithLookupTicket<TopWindow> d;
	CtrlLayout(d, "Lookup Ticket");
	
	//This is the problem code
	d.TicketLookupBtn <<= THISBACK1(EditTicket, d.TicketLookupBox);
	//========================
	
	d.Run();
}

void Helpdesk::EditTicket(int ticket_id)
{
	WithEditTicket<TopWindow> d;
	CtrlLayout(d, "Edit Ticket");
	
	//Edit Ticket Code
	
	d.Run();
}
Re: Using value from EditInt [message #2957 is a reply to message #2954] Mon, 01 May 2006 13:55 Go to previous message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
BenP wrote on Mon, 01 May 2006 06:19

Neither of the above examples worked Sad I will give snippets of my code in the hope it may help.
LookupTicket() is the function which shows the lookup dialog(see first post) and EditTicket(int ticket_id) will give me a dialog to update the ticket. The ticket_id parameter must be passed to the EditTicket function so it can get data for the correct ticket.
void Helpdesk::LookupTicket()
{
	WithLookupTicket<TopWindow> d;
	CtrlLayout(d, "Lookup Ticket");
	
	//This is the problem code
	d.TicketLookupBtn <<= THISBACK1(EditTicket, d.TicketLookupBox);
	//========================
	
	d.Run();
}

void Helpdesk::EditTicket(int ticket_id)
{
	WithEditTicket<TopWindow> d;
	CtrlLayout(d, "Edit Ticket");
	
	//Edit Ticket Code
	
	d.Run();
}




Ah, I see. This is not typical solution, the problem is that still that "THISBACK1" used this way simply stores current value for EditTicket.

There are several ways how to solve this:

- use class for LookupTicket, then the EditTicker, parameterless, will be its member and you will be able to read the value of LookupTicket's LookupTicketBox as it will be the member. This is what I proposed in recent reply.

- use breaker - if you press that button, "d.Run" will be breaked and you will be able to read the value of d.TicketLookupBox and call EditTicket.

d.Breaker(d.TicketLookupBtn, 111);
for(;;) {
   int c = d.Run();
   if(c == 111)
      EditTicket(~d.TicketLookupBox);
   if(c == IDCANCEL) // close button will send this
      break;
}



- you could also make EditTicket to accept a pointer to EditInt and pass that pointer using THISBACK1. This is the worst solution IMHO.

Mirek
Previous Topic: Batch processing images using U++ (new Image code)
Next Topic: mechatronic transmission project [was -Please, help me!]
Goto Forum:
  


Current Time: Sat Jun 15 15:26:52 CEST 2024

Total time taken to generate the page: 0.02165 seconds