//重写WndProc()方法,通过监视系统消息,来调用过程 protected override void WndProc(ref Message m)//监视Windows消息 { const int WM_HOTKEY = 0x0312; //按快捷键 switch (m.Msg) { case WM_HOTKEY: RECT currentRect = new RECT(); int id = m.WParam.ToInt32(); operateMode op = keyList.Find(k => k.id == id) == null ? operateMode.notExist : keyList.Find(k => k.id == id).op; switch (op) { case operateMode.notExist: break; //调试 case operateMode.debugMode: browser.ShowDevTools(); break; //关闭 case operateMode.close: FormClose(); break; //URL case operateMode.search: if (FormUrl == null || FormUrl.IsDisposed) { FormUrl = new FormURL(); //重定向 FormUrl.RedirectEvent += FormUrl_RedirectEvent; if (FormUrl.ShowDialog() == DialogResult.OK) { } } else { FormUrl.Dispose(); FormUrl.Close(); //已打开,关闭 } break; //减透明度 case operateMode.reduceOpacity: if (Opacity > 0.01f) { Opacity -= 0.01; } break; //加透明度 case operateMode.addOpacity: if (Opacity < 0.99f) { Opacity += 0.01; } break; //窗体移动 case operateMode.formUp: DllImport.GetWindowRect(Handle, ref currentRect); Top--; break; case operateMode.formDown: currentRect = new RECT(); DllImport.GetWindowRect(Handle, ref currentRect); Top++; break; case operateMode.formLeft: currentRect = new RECT(); DllImport.GetWindowRect(Handle, ref currentRect); Left--; break; case operateMode.formRight: currentRect = new RECT(); DllImport.GetWindowRect(Handle, ref currentRect); Left++; break; //前进后退 case operateMode.nextPage: webView.GoForward(); break; case operateMode.prePage: webView.GoBack(); break; //刷新页面 case operateMode.refresh: webView.Reload(); break; } break; } base.WndProc(ref m); }
//重写WndProc()方法,通过监视系统消息,来调用过程 protected override void WndProc(ref Message m)//监视Windows消息 { const int WM_HOTKEY = 0x0312; const int WM_MBUTTONDOWN = 0x0207; //按快捷键 switch (m.Msg) { case WM_HOTKEY: int id = m.WParam.ToInt32(); operateMode op = keyList.Find(k => k.id == id) == null ? operateMode.notExist : keyList.Find(k => k.id == id).op; switch (op) { case operateMode.notExist: break; //上一页 case operateMode.prePage: if (CurIndex != 0) { CurIndex--; textEdit1.Text = StoryText[CurIndex]; } break; //下一页 case operateMode.nextPage: CurIndex++; textEdit1.Text = StoryText[CurIndex]; break; //关闭 case operateMode.close: FormClose(); break; //搜索 case operateMode.search: if (form1 == null || form1.IsDisposed) { form1 = new FormSearch2(); form1.StoryText = StoryText.ToList(); if (form1.ShowDialog() == DialogResult.OK) { CurIndex = form1.ChoosedIndex; textEdit1.Text = StoryText[CurIndex]; } } else { form1.Dispose(); form1.Close(); //已打开,关闭 } break; //减透明度 case operateMode.reduceOpacity: if (Opacity > 0.01f) { Opacity -= 0.01; } break; //加透明度 case operateMode.addOpacity: if (Opacity < 0.99f) { Opacity += 0.01; } break; //窗体移动 case operateMode.formUp: checkIncrease(0, false); break; case operateMode.formDown: checkIncrease(0, true); break; case operateMode.formLeft: checkIncrease(1, false); break; case operateMode.formRight: checkIncrease(1, true); break; } break; case WM_MBUTTONDOWN: if (CurIndex != 0) { CurIndex--; textEdit1.Text = StoryText[CurIndex]; } break; } base.WndProc(ref m); }