[译]PowerMini v1.2-在浏览器中添加新的最小化功能.
By robot-v1.0
本文链接 https://www.kyfws.com/applications/powermini-v1-2-add-a-new-minimizing-feature-with-y-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 9 分钟阅读 - 4209 个词 阅读量 0[译]PowerMini v1.2-在浏览器中添加新的最小化功能.
原文地址:https://www.codeproject.com/Articles/3462/PowerMini-v1-2-add-a-new-minimizing-feature-with-y
原文作者:JoeSox
译文由本站 robot-v1.0 翻译
前言
Opens your default browser while minimizing all other windows. A very simple Win32 application.
在最小化所有其他窗口的同时打开默认浏览器.一个非常简单的Win32应用程序.
- 下载源文件v1.2-48.4 Kb(Download source files v1.2 - 48.4 Kb)
- 下载仅安装安装程序v1.2-274 Kb(Download Install Setup Only v1.2 - 274 Kb)
介绍(Introduction)
这个想法主要是在我的旧版Fujitsu 266 Mhz(运行Windows 2000,只有64MB RAM)上出现的.互联网浏览非常缓慢.当我打开多个窗口并将其最大化/还原后,这真是太令人痛苦了!是的,我可以单击"显示桌面",然后单击我的IE快捷方式,但这是2次单击!来吧!我想要Internet Explorer上的一个选项来最小化所有其他窗口,然后打开IE的新实例.如果您问我,这应该是一个选择,但不是.如此诞生了PowerMini!(This idea mainly came to me while working on my old Fujitsu 266 Mhz, running Windows 2000, with only 64MB of RAM. Internet browsing was painfully slow. When I had multiple windows open and maximized/restored down, it was most excruciating! Yes, I could just click on “Show Desktop”, then click on my IE shortcut, but that’s 2 clicks man!! Come on! I wanted an option on Internet Explorer to minimize all other windows, then open my new instance of IE. This should be an option, if you ask me, but is not. So forth was born PowerMini!)
续介绍(Introduction cont’d)
本文没有很好的编码内容,但是有潜力成为一个出色的CP社区应用程序,或者至少可以影响浏览器开发人员,包括在启动时尽量减少其他窗口.撰写本文的另一个激励因素:我对在个人资料中看到"文章已提交0"感到厌倦.我已经发表了一篇(This article does not have great coding content but has potential to become a great CP community application or at least, influence browser developers to include minimizing other windows when starting, as an option. Another motivating factor for me to make this article: I am tired of seeing “Articles Submitted 0” in my profile. I have published one) 关于CodeGuru的文章(article on CodeGuru though) .(.)
我还想否认,这些代码都不是我编写的.该应用程序的内容是Tone Skoda撰写的,并在来源中注明.我花了很长时间才找到处理最小化窗户的功能.现在,我将应用程序组合在一起,并尽我所能对其进行了评论.我知道可以对代码进行一些改进,我相信人们会指出.这样会很好.因为我是一个独立的,自学成才的程序员,这将帮助我成为一个更好的程序员,这要感谢CP!这个功能肯定需要改进!我尝试四处搜寻,以了解如何获得默认浏览器,但是没有运气,因此放弃了更多的时间投入.随时改进这一部分! (从v1.1开始改进).(I would also like to disclaim, that none of the code was written by me. The meat of the app was by Tone Skoda and is noted in the source. It took me a long time to find a function to handle the minimizing of windows. Now I kind of threw the application together and have tried to comment it to the best I could. I know there are improvements that could be made to the code, that I am sure people will point out. This will be good. It will help me become a better programmer, since I am a stand alone, self-taught programmer, big thanks to CP! This function definitely needs improving! I tried searching around to see how I could get my hands on getting the default browser, but no luck, and scrapped investing anymore time into it. Feel free to improve this part! (Started improving in v1.1).)
视力(Vision)
我认为,如果其他人添加他们希望在此应用程序中看到的内容,而不是要求我编写代码,那将是很好的.例如,某人有一个主意,某人编写了代码,该人发布了带有添加代码的讨论消息,我将在本文中更新源代码和应用程序版本.(I think it would be great if others would add what they would like to see in this application, instead of asking me to write the code. For example, someone gets an idea, that someone writes the code, that person posts a discussion message with the added code, I will update the source and application version in the article.)
设置PowerMini以供使用(Setting up PowerMini for Use)
您有两个选择.下载上方的仅安装文件.这将为您安装它,不包括源代码.(You have two options. Download the installation only file, above. This installs it for you, with no source code included.)
要么(OR)
- 下载(Download the)*powermini.zip(powermini.zip)*文件(上面的演示项目).它包含VC6项目和一些其他资源文件.然后解压缩到所需的文件夹.(file (Demo project above). This contains the VC6 project and some extra resources files. Then extract to desired folder.)
- 找到(Locate the)*PowerMini.exe(PowerMini.exe)*文件在(file in the)*发布(Release)*子文件夹并创建桌面快捷方式(右键单击>发送到>桌面)(subfolder and create a shortcut to the desktop (right-click > Send to > Desktop))
- 将PowerMini快捷方式拖放到快速启动工具栏.注意:您可以将快捷方式图标更改为包含在其中的5个不同图标中的任何一个.(Drag and Drop the PowerMini shortcut to your QuickLaunch Toolbar. NOTE: You may change the shortcut icon to any of the 5 different icons included in the).可执行程序(.exe*)*.随意设计和添加自己的,他们可能会比我的好:)(*. Feel free to design and add your own, they will probably be better than mine :)*) 我个人在"快速启动"工具栏中有常规的IE快捷方式,旁边有PowerMini.(*I personally have the regular IE shortcut in my QuickLaunch toolbar with PowerMini right next to it.*)
代码版本1.2(The Code Version 1.2)
尝试添加后需要此1.2更新(This 1.2 update was needed after trying to add) 疯狂浏览器(Crazy Browser) 到支持的浏览器列表.我认为Crazy Browser正确(或错误地)将自己设置为默认浏览器,如上所述,我没有找到关于Windows如何找到默认Web浏览器的任何有据可查的信息.无论如何,当将Crazy Browser设置为默认浏览器时,它将注册表项写入(to the list of supported browsers. I think Crazy Browser sets itself as the default browser correctly (or incorrectly), as mentioned I have not found any well documented information about how Windows finds the default web browser. Anyway, Crazy Browser when setting itself as the default browser, writes a registry key to) HKEY_CLASSES_ROOT\htmlfile\shell
在注册表中(in the registry and)**不(NOT)**至(to) HKEY_CLASSES_ROOT\htmlfile\shell\open\command
!哪种问题在工作的Windows 98se计算机上(但不是在WinXP笔记本电脑上?!?)造成一些问题.如果"疯狂浏览器"是您的默认浏览器,并且您使用了Internet快捷方式,则它将打开(! Which kind of creates some problems, on my Windows 98se machine at work (not on my WinXP laptop though?!?). If Crazy Browser is your default browser and you use an internet shortcut, it opens whatever is in the) HKEY_CLASSES_ROOT\htmlfile\shell\open\command
路径而不是疯狂浏览器,也许这就是为什么它被称为"疯狂"的原因(path instead of Crazy Browser, maybe this is why it is called “Crazy”)
,抱歉无法抗拒. PowerMini v1.2现在具有2种支持功能,而不是1种.(, sorry couldn’t resist. The PowerMini v1.2 now has 2 supporting functions instead of 1.)
CString GetRegKey(HKEY m_Folder, CString str_Path, CString str_Name)
返回任何给定的注册表(returns any given registry)REG_SZ
数据.(data.)CString GetHomePage()
返回用户的主页URL.(returns the users' homepage URL.)
#include <span class="code-string">"stdafx.h"</span>
#include <span class="code-string">"resource.h"</span>
////by Tone Skoda
#include <span class="code-keyword"><windows.h></span>
#include <span class="code-keyword"><windowsx.h></span>
#define M_MINIMIZE //minimize all desktop windows
#undef M_RESTORE //restore all desktop windows
#undef M_CLOSE //close all desktop windows
////End of code by Tone Skoda
//Globals
HICON m_hIcon;
CString str_Browser;
//holds "iexplore.exe", "Netscp.exe", or
//"yourpath:\Crazy Browser\Crazy Browser.exe" for now
//Must get filename so ShellExecute may
//open multiple instances.
//end of Globals
//Helper Function to return REG_SZ data
CString GetRegKey(HKEY m_Folder,
CString str_Path, CString str_Name)
{
CString str_KeyOut;
extern const char *MyKeys;
#define MY_BUFSIZE2 120 // Arbitrary initial value.
HKEY hKey1;
TCHAR szData[MY_BUFSIZE2];
DWORD dwBufLen2 = MY_BUFSIZE2;
LONG lRet1;
//Find Registry Data
RegOpenKeyEx(m_Folder,
TEXT(str_Path),
0,
KEY_QUERY_VALUE,
&hKey1);
lRet1 = RegQueryValueEx(hKey1,
TEXT(str_Name),
NULL,
NULL,
(LPBYTE)szData,
&dwBufLen2);
//Turn TCHAR into CString
str_KeyOut = szData;
RegCloseKey(hKey1);
return str_KeyOut;
}
CString GetHomePage()
{
extern CString str_Browser;
CString str_BrowserName;
CString str_HomePageOut;
DWORD dwBufLen2 = MY_BUFSIZE2;
//See if Default Browser's Name is
//written and Assign to local var
str_BrowserName =
GetRegKey(HKEY_CLASSES_ROOT,"htmlfile\\shell","");
//if there is a value here navigate to corresponding regfolder
if (str_BrowserName != "")
{
if(str_BrowserName == "CrazyBrowser")
{
str_Browser = GetRegKey(HKEY_CLASSES_ROOT,
"htmlfile\\shell\\CrazyBrowser\\Command","");
//Remove it's flag
str_Browser.Replace(" \"%1\"", "");
}
else if(str_Browser != "\"iexplore.exe\"" || "\"Netscp.exe\"")
{
AfxMessageBox("Sorry, Your default browser is
not IE or Netscape.\r\
Please email me your browser's registry homepage
key so I may update this program and source.\r\
powermini@savemall.net");
}
}
else
{
str_Browser = GetRegKey(HKEY_CLASSES_ROOT,
"htmlfile\\shell\\open\\command","");
//Remove any flags on end
int int_length, int_flagstart, int_chrtoDelete;
int_length = str_Browser.GetLength();
int_flagstart = str_Browser.Find(" -");
int_chrtoDelete = int_length - int_flagstart;
str_Browser.Delete(int_flagstart, int_chrtoDelete);
//we need to get just the filename
//recount length
int_length = str_Browser.GetLength();
//find pos of "\" before file name
int_flagstart = str_Browser.ReverseFind('\\');
//get length of filename
int_chrtoDelete = int_length - int_flagstart;
//get length of char to delete
int_chrtoDelete = int_length - int_chrtoDelete;
//start deleting after the first "
str_Browser.Delete(1, int_chrtoDelete);
RegCloseKey(hKey1);
//Now we know the Default Browser, Lets get it's Homepage
if(str_Browser == "\"Netscp.exe\"")
{
//Get Netscape's homepage reg entry
str_HomePageOut = GetRegKey(HKEY_CURRENT_USER,
"Software\\Netscape\\Netscape Navigator\\Main",
"Home Page");
}
else if(str_Browser == "\"iexplore.exe\"" || "Crazy Browser.exe")
{
//Get IE's homepage reg entry
str_HomePageOut = GetRegKey(HKEY_CURRENT_USER,
"Software\\Microsoft\\Internet Explorer\\Main",
"Start Page");
}
else if(str_Browser != "\"iexplore.exe\"" || "\"Netscp.exe\"")
{
AfxMessageBox("Sorry, Your default browser
is not IE or Netscape.\r<br>Please email
me your browser's registry homepage key
so I may update this program and source.\r
<br>powermini@savemall.net");
}
//I don't have any other the other Browser's
//installed on my system, so I need help getting
//the Registry keys
}//end of else
return str_HomePageOut;
}
第二个功能:(The 2nd function:)
////by Tone Skoda
BOOL CALLBACK EnumWindowsProc( HWND hwnd, LPARAM lParam)
{
long style;
if(IsWindowVisible(hwnd))
{
style=GetWindowLong(hwnd,GWL_STYLE);
if(style & WS_OVERLAPPEDWINDOW &&
(style & WS_POPUP)== false)
{
#ifdef M_MINIMIZE
if( IsIconic(hwnd) == false )
{
ShowWindow(hwnd,SW_SHOWMINIMIZED);
}
#endif
#ifdef M_RESTORE
if( IsIconic(hwnd) == true )
{
ShowWindow(hwnd,SW_RESTORE);
}
#endif
#ifdef M_CLOSE
PostMessage(hwnd,WM_CLOSE,0,0);
#endif
}
}
return true;
}
////End of code by Tone Skoda
的(The) WinMain
:(:)
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
//call external var
extern CString GetHomePage();
extern CString str_Browser;
extern HICON m_hIcon;
//Assign Icon with the .exe
CWnd m_hWnd;
m_hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
////by Tone Skoda
ANIMATIONINFO anim;
anim.cbSize=sizeof(anim);
//turn off minimize/restore animations
anim.iMinAnimate=false;
SystemParametersInfo(SPI_SETANIMATION,0,&anim,0);
EnumWindows(EnumWindowsProc,0);
//turn on minimize/restore animations
anim.iMinAnimate=true;
SystemParametersInfo(SPI_SETANIMATION,0,&anim,0);
////End of code by Tone Skoda
//fill the url to local var
CString str_Homepage = GetHomePage();
//open the browser
ShellExecute(m_hWnd, "open", str_Browser,
str_Homepage, NULL, SW_SHOWDEFAULT);
return true;
}
兴趣点(Points of Interest)
我很惊讶没有在主要的编码站点上找到有关如何最小化和最大化打开的窗口的任何现有代码.也许是因为这是常识,但对于这个想成为程序员的人却不是.(I was surprised not to find any existing code on the major coding sites about how to minimize and maximize open windows. Maybe because it is common knowledge, but not to this wanna-be programmer.)
已知问题/限制(Known Issues/Limits)
-
仅查找Internet Explorer和Netscape主页(仅b/c是我安装的唯一页面).当我在其他浏览器上收到更多信息时,我将进行更新(无论如何,该信息可能会很好/很有用.如果在一个地方进行了记录,我尝试在网上搜索包含有关浏览器及其主页的注册表项信息的页面.这样的网站存在).(Only looks for Internet Explorer and Netscape homepages (only b/c they are the only ones I have installed). I will update as I receive more info on other browsers (this info might be good/useful to have documented in one place anyway. I tried searching the net for a page that has info on the registry keys for browsers and their homepages, but no such site exists).)
-
无法完全最小化已还原的窗口(它是最小的,但不是完全的).(Does not fully minimize restored windows (it mini’s them, but not fully).)
-
“这对试图从您的代码中学习的人们来说是不好的.“参见.S.Rod. 2007年1月4日15:16发布.抱歉,“专业人士”,我还在学习(“It’s bad for people trying to learn from your code.” see .S.Rod. 15:16 4 Jan ‘03 post. Sorry you “Professionals”, I’m still learning)
-
2个未解决的外部错误-仅调试.(2 unresolved externals error - Debug ONLY.)
-
VC7会生成错误,最好仅创建一个新项目并粘贴代码,然后导入图标.(VC7 build errors, better off just creating a new project and pasting code, and importing icons.)
所需的附件(Desired Add-ons)
- 如果用户右键单击快捷方式或(An Options popup menu if user right-clicks on shortcut or)PowerMini.exe(PowerMini.exe)(就像IE一样)(我自己尝试过执行此功能,但发现自己投入了太多时间,而没有得到我绊脚石的答案).((like IE’s) (I tried doing this feature myself but found myself investing too much time and not getting answers to my stumbling).)
- 构建中的凉爽图标,因此您有很多选择.(Cooler icons in the build, so you have plenty of options to choose from.)
- 您还能想到的其他任何东西.(Anything else you can think of.)
历史(History)
文章于1/4/03 12:10 am PT PT发布(Article posted 1/4/03 12:10am PT)
- 1/4/03 11:35 am PT:删除了(1/4/03 11:35am PT: Removed the)*安装程序(setup.exe)*来自powermini_src.zip.糟糕,为什么这么大.(from powermini_src.zip. Oops, wonder why it was so big.)
- 1/4/03 1:20 pm PT:改进(1/4/03 1:20pm PT: Improved)
GetHomePage()
通过获取实际的默认浏览器而不是猜测.(by getting actual default browser instead of guessing.) - 太平洋时间1/4/03 1:20 pm:发布v1.1 src并安装.(1/4/03 1:20pm PT: Posted v1.1 src and install.)
- 太平洋时间1/17/8 8:31 pm:发布v1.2 src并安装.添加了对"疯狂浏览器"的支持.改进了一些功能.(1/17/03 8:31pm PT: Posted v1.2 src and install. Added support for Crazy Browser. Improved some functions.)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C++ VC6 Win2K WinXP Windows .NET .NET1.0 MFC Visual-Studio Dev 新闻 翻译