protected override void WndProc(ref Message m) { // Listen for device driver messages switch (m.Msg) { case WM_DEVICECHANGE: { switch (m.WParam.ToInt32()) { case DBT_CUSTOMEVENT: { DEV_BROADCAST_DEVICEHANDLE vol; vol = (DEV_BROADCAST_DEVICEHANDLE)Marshal.PtrToStructure(m.LParam, typeof(DEV_BROADCAST_DEVICEHANDLE)); int key = (int)vol.dbch_data[0]; if (DX1UtilityActive & key > 0) { //IF Utility is active then Highlight DX1 Key that was pressed in G_KeyMap to make //finding and programming keys easier. Don't play the macro. DebugLog.Instance.writeLog("Detected DX1 Key Press Key Number: " + key.ToString() + "was pressed."); G_KeyMap.CurrentCell = G_KeyMap.Rows[key - 1].Cells[0]; if (mKeyProgrammer.DX1KeyDown(key)) { MacroList.ClearSelected(); if (mKeyProgrammer.Active) { //Currently Quick Programming B_QuickPrg.Text = "Key - " + mKeyProgrammer.KeyToProgram; } } } else { DoSomethingWithMacroKeys(vol.dbch_data); } break; } } break; } } base.WndProc(ref m); }