Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

external Event Handler Visual C

Status
Not open for further replies.

molocas

Newbie level 3
Joined
Apr 23, 2009
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,312
external event + programming

Dear friends,

I made a PIC based USB interface, I have connected one pushbutton to the PIC and when I push it, a counter is incremented.
I did a visual C++ interface with a Form and a Label to display this counter.
The thing is, the only way y can see the numbers in the counter are incremented is clicking the mouse as an event handler. Each time I click the mouse, the loop starts again.

Well , I would like to omit clicking the mouse and increment the counter just with the push button from the PIC.
I delete the event click mouse routine and nothing happens.
I have tested a lot of combinations but the visual c++ program , stays still (I dont know where)
waiting for an event, just displaying the number one.

The loop never continue, If I stop and start again my program , Label displays number 0 if pushbutton is open and 1 if it is close, so the programs works ¡ ¡ ¡ ¡.
Please I need Help ¡ ¡

I really appreciate any.
:cry:
 

visual c++ wait for event

You have to raise your own event.
Search in the help files for event object and fire event.
You can raise the event in response to the pushbutton.
 

visual studio c++ incrementing counter

Dear btbass,

I am not shure if I can do this cause I am new in visual c, but I am going to show you part of my code , at the end of routine called getdata, variable i has just 1 or 0.
1 for increment the counter in label1 and 0 for do nothing.

//+++++++++++++++++++++++
void getdata (void)
{
DWORD BytesWritten = 0;
DWORD BytesRead = 0;
unsigned char OutputPacketBuffer[65];
unsigned char InputPacketBuffer[65];

InputPacketBuffer[0] = 0;
OutputPacketBuffer[0] = 0;

WriteFile(WriteHandle, &OutputPacketBuffer, 65, &BytesWritten, 0);
ReadFile(ReadHandle, &InputPacketBuffer, 65, &BytesRead, 0);

i=InputPacketBuffer[1]; // i= SW STATE
} //RETURN WITH VALUE IN variable i
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
public: System::Void label1_Click(System::Object^ sender, System::EventArgs^ e) { //++ CLICK EVENT HANDLER ++//

getdata(); // call getdata

if(i == 0)//if i eq 0,
{
goto a; //leave counter as is
}
else //increment it if i=1
{
tmp=tmp+1;
a: i=tmp;
label1->Text = i.ToString();//call display number in Label1

}
}
};
}
As you can see Void label1_Click controls the event.
I really appreciate if you can help me with a little code to have an idea.

THanks a lot.
 

visual c++ mouse event handlers

Hi molocas
I am using visual studio but I am programming in C#.
This would be easy in C#.

One way you could do this is to use a timer object. Set the timer up to interrupt every 50mS or so to check the usb device.
If you are using visual studio c++, you can just place a timer on your form from the toolbox and set up the properties.
Otherwise use the help file, there should be an example of using a timer.

You can download free express versions of Visual studio VB, C# and C++ from Microsoft, but you are only allowed to install one language version on a pc.
 

fire event externally c#

I am going to try timers, thanks a lot, i´ll let you know about.
:)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top