CMyMenu.cpp
上传用户:hyb6888
上传日期:2016-01-24
资源大小:5186k
文件大小:8k
- #include "stdafx.h"
- #include "stdio.h"
- #include "CMyMenu.h"
- #include "windows.h"
- #include "string.h"
- int EDIT1_NUM;
- char EDIT1_txt[200];
- char EDIT2_txt[200];
- BOOL WINAPI About(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam )
- {
- switch (message)
- {
- case WM_INITDIALOG:
- SetDlgItemText(hDlg,IDC_EDIT1,EDIT1_txt);
- SetDlgItemText(hDlg,IDC_EDIT2,EDIT2_txt);
- SetWindowPos(hDlg, 0, 400,300,0, 0, 21); //SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER //16/1/4
- return TRUE;
- case WM_COMMAND:
- switch(wParam) {
- case IDOK:
- GetDlgItemText(hDlg,IDC_EDIT1,EDIT1_txt,2);
- EDIT1_NUM=GetDlgItemInt(hDlg,IDC_EDIT1,0,FALSE);
- EndDialog(hDlg,IDOK);
- break;
- case IDCANCEL:
- EndDialog(hDlg,IDCANCEL);
- break;
- default:
- break;
- }
- break;
- }
- return FALSE;
- }
- //链接到目标地址
- HINSTANCE GotoURL(LPCTSTR url, int showcmd)
- {
- // 调用函数ShellExecute()
- // HINSTANCE result = (HINSTANCE)ShellExecute(NULL, "open", url, NULL,NULL, showcmd);
- return 0;
- }
- CMyMenu::CMyMenu(CMyWnd *mcmyWnd){
- char subMenuName[100][256];
- long iMenu,nMenus,subnMenus,i,flag;
- char MenuName[20][256]={"词语管理","-----","输入模式","选择背景","透 明 度","窗体边框","跟踪灵敏"
- ,"滚动显示","锁定背景","自动造词","窗 花"," 帮 助 ","关于极速"};
- char fpath[256],cur_dic_lib[256],*pp[100];
- cmyWnd=mcmyWnd;
- hInst=cmyWnd->hInst;
- hMenu = CreatePopupMenu();
- subhMenu = CreatePopupMenu();
- mode_subhMenu = cmyWnd->ConWind->createModlePopup(cmyWnd->myResM.CurModleNum,21);
- /////////////////////////////////////////////////////////////
- //生成库子菜单
- GetModuleFileName(hInst,fpath,255);
- for(i=0;i<100;i++)
- pp[i]=subMenuName[i];
- subnMenus=getallfile("c:\jsime\lib",pp);
- subMenuID_start=100;
- subMenuID_end=subMenuID_start;
- RegReadString("cur_dic_lib",cur_dic_lib);
- //MessageBox(0,cur_dic_lib,"功能暂时未编码",0);
- for(i = 0 ;i<subnMenus;i++){
- flag=MF_ENABLED;
- if(strcmp(cur_dic_lib,subMenuName[i])==0)
- flag|=MF_CHECKED;
- AppendMenu (subhMenu, flag, subMenuID_end, subMenuName[i]);
- subMenuID_end++;
- //MessageBox(0,MenuName[0],"功能暂时未编码",0);
- }
- /////////////////////////////////////////////////////////////
- //主菜单部分
- nMenus = 13;
- for(iMenu = 1 ;iMenu<=nMenus;iMenu++){
- flag=MF_ENABLED;
- if(9==iMenu){
- char dd[500];
- cmyWnd->RegReadString("backpic",dd);
- //MessageBox(0,"ddd",dd,0);
- if(dd[0]!=0)
- flag|=MF_CHECKED;
- }
- switch (iMenu)
- {
- case 6:
- if(cmyWnd->myResM.frameflage[0]=='1')
- flag|=MF_CHECKED;
- break;
- case 8:
- if(cmyWnd->myResM.scrollflage[0]=='1'){
- SetTimer(cmyWnd->m_hWnd,1,20,NULL);
- flag|=MF_CHECKED;
- }
- break;
- case 10:
- if(cmyWnd->myResM.autoword[0]=='1')
- flag|=MF_CHECKED;
- break;
- case 11:
- if(cmyWnd->myResM.flowerflage[0]=='1')
- flag|=MF_CHECKED;
- break;
- default:
- //flag=MF_GRAYED|MF_DISABLED;
- break;
- }
- if(iMenu==8)
- flag|=MF_MENUBREAK|MF_MENUBARBREAK;
- AppendMenu (hMenu, flag, iMenu, MenuName[iMenu-1]);
- // wIDNewItem ----- Long,指定菜单条目的新命令ID。如果在wFlags参数中指定了MF_POPUP字段,那么这应该是指向一个弹出式菜单的句柄
- if(iMenu!=7)
- AppendMenu (hMenu, MF_SEPARATOR, iMenu, "");
- }//for
- ModifyMenu (hMenu, 2,MF_POPUP, (UINT)subhMenu, "编码库选择");
- ModifyMenu (hMenu, 3,MF_POPUP, (UINT)mode_subhMenu, "输入模式");
- }
- CMyMenu::~CMyMenu(){
- //DestroyMenu(mode_subhMenu);
- //DestroyMenu(subhMenu);
- DestroyMenu(hMenu);
- }
- //返回所选菜单项
- long CMyMenu::Popup(){
- long iMenu,result,retabout,flag;
- POINT p ;
- char buffer [256];
- int CurentKbdNum=0;
- GetCursorPos(&p);
- flag=TPM_RIGHTBUTTON + TPM_LEFTALIGN + TPM_NONOTIFY + TPM_RETURNCMD;
- iMenu = TrackPopupMenu(hMenu, flag, p.x, p.y, 0, GetForegroundWindow(), 0);
- //得到菜单的选择字符串
- result = GetMenuString(hMenu, (iMenu-1), buffer, 255, MF_BYPOSITION);
-
- if(iMenu>0){
- switch (iMenu)
- {
- case 1:
- {
- char AppPath[500];
- int i;
- GetModuleFileName(hInst,AppPath,256);
- for(i=strlen(AppPath)-1;i>=0;i--){
- if(AppPath[i]=='\'){
- AppPath[i]=0;
- strcat(AppPath,"\词语管理.exe ShowMessageBox");
- break;
- }
- }
- WinExec(AppPath,1);
- break;
- }
- case 2:
- break;
- case 3:
- GotoURL("www.cctv.com",1);
- //cmyWnd->ConWind->createModlePopup(cmyWnd->myResM.CurModleNum,20);
- break;
- case 4:
- cmyWnd->selectback();
- break;
- case 5:
- {
- char tem[20];
- sprintf(tem,"%d",cmyWnd->myResM.clarityflage);
- strcpy(EDIT1_txt,tem);
- strcpy(EDIT2_txt," 透明度设置,值越小透明度越高,可以是1-255中的一个值。当前的值为:");
- retabout=DialogBox(cmyWnd->hInst,MAKEINTRESOURCE(IDD_DIALOG1),0,About);
- if(retabout==IDOK){
- cmyWnd->myResM.clarityflage=EDIT1_NUM;
- if(cmyWnd->myResM.clarityflage==0||cmyWnd->myResM.clarityflage>255)
- cmyWnd->myResM.clarityflage=200;
- WriteReg("clarityflage",(DWORD)cmyWnd->myResM.clarityflage);
- cmyWnd->SetAllWinAttrib(cmyWnd->myResM.clarityflage);
- }
- }
- break;
- case 6:
- if(cmyWnd->myResM.frameflage[0]=='1')
- {
- RegSaveString("frameflage","0");
- cmyWnd->myResM.frameflage[0]='0';
- }else{
- cmyWnd->myResM.RegSaveString("frameflage","1");
- cmyWnd->myResM.frameflage[0]='1';
- }
- cmyWnd->DrawFrame();
- break;
- case 7:
- if(cmyWnd->myResM.traceflage[0]>'0' && cmyWnd->myResM.traceflage[0]<='9')
- EDIT1_txt[0]=cmyWnd->myResM.traceflage[0];
- else
- EDIT1_txt[0]='0';
- EDIT1_txt[1]=0;
- strcpy(EDIT2_txt," 跟踪灵敏度设10个级别:0立即移动,1为20个单位,……,8为160个单位,9锁定,默认为3。以下为当前灵敏度");
- retabout=DialogBox(cmyWnd->hInst,MAKEINTRESOURCE(IDD_DIALOG1),0,About);
- if(retabout==IDOK){
- cmyWnd->myResM.traceflage[0]=EDIT1_txt[0];
- cmyWnd->myResM.traceflage[1]=0;
- if(cmyWnd->myResM.traceflage[0]>'0' && cmyWnd->myResM.traceflage[0]<='9')
- RegSaveString("traceflage",cmyWnd->myResM.traceflage);
- else
- RegSaveString("traceflage","0");
- }
- break;
- case 8:
- if(cmyWnd->myResM.scrollflage[0]=='1')
- {
- cmyWnd->RegSaveString("scrollflage","0");
- cmyWnd->myResM.scrollflage[0]='0';
- }
- else
- {
- cmyWnd->myResM.RegSaveString("scrollflage","1");
- cmyWnd->myResM.scrollflage[0]='1';
- }
- break;
- case 9:
- cmyWnd->myResM.FixBackPic();
- {
- char dd[500]="";
- //RegReadString("backpic",dd);
- //MessageBox(0,"dd",dd,0);
- }
- break;
- case 10:
- if(cmyWnd->myResM.autoword[0]=='1')
- {
- cmyWnd->RegSaveString("autoword","0");
- cmyWnd->myResM.autoword[0]='0';
- }else{
- cmyWnd->myResM.RegSaveString("autoword","1");
- cmyWnd->myResM.autoword[0]='1';
- }
- break;
- case 11:
- if(cmyWnd->myResM.flowerflage[0]=='1')
- {
- cmyWnd->RegSaveString("flowerflage","0");
- cmyWnd->myResM.flowerflage[0]='0';
- }else{
- cmyWnd->myResM.RegSaveString("flowerflage","1");
- cmyWnd->myResM.flowerflage[0]='1';
- }
- cmyWnd->DrawFrame();
- break;
- case 12:
- WinExec("hh c:\jsime\jsime.CHM",1);
- //WinHelp(NULL,"c:\jsime\jsime.hlp",HELP_CONTENTS,0);
- break;
- case 13:
- strcpy(EDIT1_txt,"E-MAIL:whln669@sohu.com ");
- strcpy(EDIT2_txt," 首先感谢各位用户使用《极速五笔》,本软件是由王华设计开发,如对本软件有意见和建议,或需要得到帮助,请发电子邮件与本人联系。谢谢!");
- DialogBox(cmyWnd->hInst,MAKEINTRESOURCE(IDD_DIALOG1),0,About);
-
- break;
- default:
- if(subMenuID_start<=iMenu && iMenu<=subMenuID_end){
- iMenu=iMenu-subMenuID_start;
- result = GetMenuString(subhMenu, (iMenu), buffer, 255, MF_BYPOSITION);
- //if(strlen(buffer)>0)
- // MessageBox(0,buffer,"功能暂时未编码",0);
- RegSaveString("cur_dic_lib",buffer);
- WriteReg("jsime",1);
- }
- if(20<=iMenu && iMenu<=30){
- iMenu=iMenu-20;
- cmyWnd->ConWind->setModle(iMenu);
- buffer[0]=0;
- result = GetMenuString(mode_subhMenu, (iMenu), buffer, 255, MF_BYPOSITION);
- //if(strlen(buffer)>0)
- // MessageBox(0,buffer,"功能暂时未编码",0);
- }
- //MessageBox(0,"过两天补上","功能暂时未编码",0);
- break;
- }
- }
- return 0;
- }