09-19-2011 03:24 AM
Thanks very much for that, will give it a try shortly, certainly looks like it should work. Also, apologies for the delay in response, this was something I was trying to do at work towards the end of the week and only just back in the office to check this thread!
09-19-2011 04:01 AM
No luck at the moment, getting a few errors back. Can I ask what the HWND hwnd bit is? It's also not liking VK_CONTROL or WM_LBUTTONDOWN, just coming back as undeclared identifiers. Also getting about 4 missing prototype errors.
09-19-2011 09:41 AM
Cottonb,
My apologies, I forgot to mention that you need to #include <Windows.h>. Make sure this is at the top of the list of includes to avoid conflicts.
09-19-2011 10:13 AM
Ah yes, sorry thanks, I appreciate the help. That gets rid of the errors anyway however it's still not playing ball at the mo! No errors or anything, just not working as intended.
This is what I have, with all the variable declared as you have in the sample code:
int CVICALLBACK Zoom (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
HWND hwnd;
int zoomonoff = 0;
switch (event)
{
case EVENT_LEFT_CLICK:
GetKeyboardState(oldKeyState);
GetCtrlVal(panelHandle, PANEL_ZOOM, &zoomonoff);
if (zoomonoff)
{
memcpy(newKeyState, oldKeyState, 1);
newKeyState[VK_CONTROL] = 128;
SetKeyboardState(newKeyState);
SetActiveCtrl(panelHandle, PANEL_OUTPUT);
GetPanelAttribute(panelHandle, ATTR_SYSTEM_WINDOW_HANDLE, (intptr_t*)&hwnd);
isFakeDouble = 1;
SendMessage(hwnd, WM_LBUTTONDOWN, 0, 0);
isFakeDouble = 0;
}
break;
case EVENT_LEFT_DOUBLE_CLICK:
if (isFakeDouble)
SetKeyboardState(oldKeyState);
break;
}
return 0;
}
Zoom is the callback function for the toggle button.
09-19-2011 10:18 AM
Switch Zoom to be the callback function of the graph and I think this should work. We don't need to have a callback function for the toggle button because we can use getCtrlVal to get it's current state. We want this code in the callback for the graph so that whenever the user clicks on the graph, we can handle that in the EVENT_LEFT_CLICK.
09-19-2011 10:23 AM
Eacellent, thanks very much! Works like a charm. Thank you for all of the help, it's greatly appreciated, you can tell I'm new to this!