一,ALT+TAB切换时小图标的添加
Dlg类中添加变量
protected:
HICON m_hIcon; #define IDR_MAINFRAME 128
ICON IDR_MAINFRAME,IDC_STATIC,,,,
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON DISCARDABLE "res\\crtApp.ico" 构造函数中加载
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
初始化
SetIcon(m_hIcon, TRUE); // Set big icon ALT+TAB
SetIcon(m_hIcon, FALSE); // Set small icon 左上角小图标 使用
// Draw the icon
dc.DrawIcon(, , m_hIcon);
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
二 Dlg::OnInitDialog()
获取屏幕大小
int w = GetSystemMetrics(SM_CXSCREEN);
int h = GetSystemMetrics(SM_CYSCREEN);
界面透明
SetWindowPos(&wndTopMost,,,,,SWP_SHOWWINDOW); //移动界面位置
MoveWindow(,,,, TRUE); //移动界面位置
//VS2003以上版本
//SetWindowLong(GetSafeHwnd(),GWL_EXSTYLE,GetWindowLong(GetSafeHwnd (),GWL_EXSTYLE)|WS_EX_LAYERED);
//SetLayeredWindowAttributes(0,200,LWA_ALPHA);
//VS2003以下版本
SetWindowLong(GetSafeHwnd(), GWL_EXSTYLE, GetWindowLong(GetSafeHwnd(), GWL_EXSTYLE) |0x00080000);
HINSTANCE hInst = LoadLibrary(_T("User32.dll"));
if (hInst)
{
typedef BOOL (WINAPI *MyFun)(HWND,COLORREF,BYTE,DWORD);
MyFun myfun = NULL;
myfun = (MyFun)GetProcAddress(hInst, "SetLayeredWindowAttributes");
if (myfun)
myfun(GetSafeHwnd(),,,);
FreeLibrary(hInst);
}
, //竖行字体
Dlg::OnPaint()
{ CPaintDC dc(this);// device context for painting
CRect rtClient;
GetClientRect(rtClient); //获取客户区尺寸、位置信息 /////// 利用CFont::CreateFont(...)函数实现竖写汉字////////
CFont myFont; //创建字体对象
//创建逻辑字体
myFont.CreateFont(, //字体高度(旋转后的字体宽度)=56
, //字体宽度(旋转后的字体高度)=20
, //字体显示角度=270°
, //nOrientation=0
, //字体磅数=10
FALSE, //非斜体
FALSE, //无下划线
FALSE, //无删除线
DEFAULT_CHARSET, //使用缺省字符集
OUT_DEFAULT_PRECIS, //缺省输出精度
CLIP_DEFAULT_PRECIS,//缺省裁减精度
DEFAULT_QUALITY, //nQuality=缺省值
DEFAULT_PITCH, //nPitchAndFamily=缺省值
"@system"); //字体名=@system
CFont *pOldFont=dc.SelectObject(&myFont);//选入设备描述表 //在客户区适当位置输出文字
dc.TextOut(rtClient.Width()/+,, "单击返回主界面");
dc.SelectObject(pOldFont); //将myFont从设备环境中分离
myFont.DeleteObject(); //删除myFont对象
/*
/////////// 利用LOGFONT结构实现竖写汉字//////////////
LOGFONT lf; //定义字体结构
lf.lfWeight=8; //字体磅数=10
lf.lfHeight=20; //字体高度(旋转后的字体宽度)=56
lf.lfWidth=10; //字体宽度(旋转后的字体高度)=20
lf.lfUnderline=FALSE; //无下划线
lf.lfStrikeOut=FALSE; //无删除线
lf.lfItalic=FALSE; //非斜体
lf.lfEscapement=2700; //字体显示角度=270°
lf.lfCharSet=DEFAULT_CHARSET; //使用缺省字符集
strcpy(lf.lfFaceName,"@system"); //字体名=@system
CFont myLogFont; //定义字体对象
myLogFont.CreateFontIndirect(&lf); //创建逻辑字体
pOldFont=dc.SelectObject(&myLogFont);//选入设备描述表
//在客户区适当位置输出文字
// dc.TextOut(rtClient.Width()/2+5,rtClient.Height()/32, "点击返回主界面");
dc.SelectObject(pOldFont); //将myFont从设备环境中分离
myLogFont.DeleteObject(); //删除myLogFont对象
*/
...
}
三 进程信息
#include <tlhelp32.h>
long FindTargetProcess(const CString &m_strProcessName)
{
int nRet = ;
HANDLE hFind = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, );
PROCESSENTRY32 *info = new PROCESSENTRY32;
info->dwSize = sizeof(PROCESSENTRY32);
nRet = ; if (::Process32First(hFind, info) != NULL)
{
CString strName;
while (::Process32Next(hFind, info) != FALSE)
{
strName = info->szExeFile;
if (strName == m_strProcessName)
{
if (strName == "cmd.exe")
{
CString strCmd;
strCmd.Format("taskkill /f /pid %u", info- >th32ProcessID);
::system(strCmd); } HANDLE hOpenPro = OpenProcess(PROCESS_ALL_ACCESS, TRUE, info->th32ProcessID);
if (hOpenPro != NULL)
{
Sleep();
nRet = ;
::TerminateProcess(hOpenPro, );
Sleep();
}
}
}
::CloseHandle(hFind);
if (info != NULL)
{
delete info;
}
}
return nRet;
} //ExitProcess(0);
char app[] = {};
long FindTargetProcess2(const CString &m_strProcessName)
{
int nRet = ;
HANDLE hFind = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, );
PROCESSENTRY32 *info = new PROCESSENTRY32;
info->dwSize = sizeof(PROCESSENTRY32);
nRet = ;
DWORD pid = ;
if (::Process32First(hFind, info) != NULL)
{
CString strName;
while (::Process32Next(hFind, info) != FALSE)
{
strName = info->szExeFile;
if (strName == m_strProcessName)
{
pid = info->th32ProcessID;
HANDLE hOpenPro = OpenProcess(PROCESS_ALL_ACCESS, TRUE, info->th32ProcessID);
if (hOpenPro != NULL)
{
}
}
}
::CloseHandle(hFind);
if (info != NULL)
{
delete info;
}
}
return pid;
} BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
DWORD pid = ; DWORD tid = GetWindowThreadProcessId(hwnd, &pid);
if (pid == (DWORD)lParam)
{
// printf("pid:%d\n", pid, tid);
// DWORD lid = GetCurrentThreadId();
// AttachThreadInput(tid, lid, TRUE ); int w = GetSystemMetrics(SM_CXSCREEN);
int h = GetSystemMetrics(SM_CYSCREEN);
// BOOL b = SetWindowPos (hwnd,HWND_NOTOPMOST,,,,,SWP_NOMOVE|SWP_NOSIZE); // PostMessage(hwnd, WM_SHOWWINDOW, true, SW_OTHERZOOM);
HWND hw = hwnd;
while (hw != NULL)
{
hw = GetParent(hwnd);
if (hw)
{
printf("%x ", hw);
hwnd = hw;
}
printf("\n");
}
if (!GetWindowLong(hwnd, GWL_STYLE)&WS_VISIBLE)
{
return TRUE;
}
char buf[] = {}; GetWindowText(hwnd, buf, ); CString str=buf;
if (str == app )
{
printf("%s\n", buf);
ShowWindow(hwnd,SW_RESTORE);
SetForegroundWindow(hwnd);
return FALSE;
} // SetActiveWindow(hwnd);
// bool b = SetWindowPos (hwnd,HWND_TOPMOST,,,,,SWP_NOSIZE|SWP_NOMOVE|SWP_SHOWWINDOW); //AttachThreadInput(tid, lid, FALSE ); }
return TRUE;
}
char app[] = {};
long FindTargetProcess2(const CString &m_strProcessName)
{
int nRet = ;
HANDLE hFind = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, );
PROCESSENTRY32 *info = new PROCESSENTRY32;
info->dwSize = sizeof(PROCESSENTRY32);
nRet = ;
DWORD pid = ;
if (::Process32First(hFind, info) != NULL)
{
CString strName;
while (::Process32Next(hFind, info) != FALSE)
{
strName = info->szExeFile;
if (strName == m_strProcessName)
{
pid = info->th32ProcessID;
HANDLE hOpenPro = OpenProcess(PROCESS_ALL_ACCESS, TRUE, info->th32ProcessID);
if (hOpenPro != NULL)
{
}
}
}
::CloseHandle(hFind);
if (info != NULL)
{
delete info;
}
}
return pid;
} BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
DWORD pid = ; DWORD tid = GetWindowThreadProcessId(hwnd, &pid);
if (pid == (DWORD)lParam)
{
// printf("pid:%d\n", pid, tid);
// DWORD lid = GetCurrentThreadId();
// AttachThreadInput(tid, lid, TRUE ); int w = GetSystemMetrics(SM_CXSCREEN);
int h = GetSystemMetrics(SM_CYSCREEN);
// BOOL b = SetWindowPos (hwnd,HWND_NOTOPMOST,,,,,SWP_NOMOVE|SWP_NOSIZE); // PostMessage(hwnd, WM_SHOWWINDOW, true, SW_OTHERZOOM);
HWND hw = hwnd;
while (hw != NULL)
{
hw = GetParent(hwnd);
if (hw)
{
printf("%x ", hw);
hwnd = hw;
}
printf("\n");
}
if (!GetWindowLong(hwnd, GWL_STYLE)&WS_VISIBLE)
{
return TRUE;
}
char buf[] = {}; GetWindowText(hwnd, buf, ); CString str=buf;
if (str == app )
{
printf("%s\n", buf);
ShowWindow(hwnd,SW_RESTORE);
SetForegroundWindow(hwnd);
return FALSE;
} // SetActiveWindow(hwnd);
// bool b = SetWindowPos (hwnd,HWND_TOPMOST,,,,,SWP_NOSIZE|SWP_NOMOVE|SWP_SHOWWINDOW); //AttachThreadInput(tid, lid, FALSE ); }
return TRUE;
}
SetTimer(, , );

ALT+TAB切换时小图标的添加 界面透明 屏幕大小 竖行字体 进程信息的更多相关文章

  1. ubuntu 14.04 compiz的ALT + TAB切换程序

    安装完ubuntu,发现不能使用ALT + TAB切换应用程序,翻遍所有百度结果,没有可行,都是拷这个拷那个...真实无语...FQgoogle,看的第一个就完美解决.记录下来,方便国人少走弯路. 首 ...

  2. 解决微信小程序的wx-charts插件tab切换时的显示会出现位置移动问题-tab切换时,图表显示错乱-实现滑动tab

    解决Echarts在微信小程序tab切换时的显示会出现位置移动问题 tab切换时,图表显示错乱 <canvas class="kcanvas" canvas-id=" ...

  3. element--ui使用tab切换时如何获取当前对象的id或者其他属性

    1. 问题 当使用tab切换时,部分特殊场景需要获取当前元素的类名或者id. 2.解决思路,tab切换是绑定函数,函数会传递过去当前对象,通过当前对象获取对象属性 vue部分代码:本项目是在vue-c ...

  4. vue -vantUI tab切换时 list组件不触发load事件解决办法

    最近由于公司项目需要,用vue写了几个简单的页面.用到了vantUI List 列表 瀑布流滚动加载,用于控制长列表的展示 当列表即将滚动到底部时,会触发事件并加载更多列表项. (页面加载完成后默认会 ...

  5. easyui easyui-accordion的使用和在tab切换时没有样式

    1.easyui-accordion的使用 <div id="aa" class="easyui-accordion" style="width ...

  6. vue中echarts 在element-ui的tab 切换时 width 为100px 时的解决方式

    最近在项目中遇到了这种情况,需要在tab控件上渲染多个echart图标,然后切换查看时,发现图表的宽度不正确 原因:在页面进行加载时,隐藏的图表找不到对应的div大小,所以默认给了一个大小.所以要做的 ...

  7. echarts在tab切换时容器宽度设置为100%,只展示100px

    在 mychart.setOption(option); 后面加上 mychart.resize(); 即可

  8. 解决windows 1903 alt + tab 切换卡顿

    右击此电脑图标 选择管理 服务和应用程序 服务 禁用system interface foundation service

  9. AppBar 自定义顶部导航按钮 图标、颜色 以及 TabBar 定义顶部 Tab 切换

    一.Flutter AppBar 自定义顶部按钮图标.颜色 leading   在标题前面显示的一个控件,在首页通常显示应用的 logo:在其他界面通常显示为返回按钮 title  标题,通常显示为当 ...

随机推荐

  1. Bootstrap栅格系统详解,响应式布局

    Bootstrap栅格系统详解 栅格系统介绍 Bootstrap 提供了一套响应式.移动设备优先的流式栅格系统,随着屏幕或视口(viewport)尺寸的增加,系统会自动分为最多12列. 栅格系统用于通 ...

  2. Android 子线程测试

    private volatile boolean mStopped = false; private int i; TextView tv1; TextView tv2; @Override prot ...

  3. Android卸载程序之后跳转到指定的反馈页面

    一个应用被用户卸载肯定是有理由的,而开发者却未必能得知这一重要的理由,毕竟用户很少会主动反馈建议,多半就是用得不爽就卸,如果能在被卸载后获取到用户的一些反馈,那对开发者进一步改进应用是非常有利的.目前 ...

  4. C#获得类的方法和方法参数

    Type t = typeof(CommonController); StringBuilder str = new StringBuilder(); MethodInfo[] methors = t ...

  5. WebForm 控件

    一.简单控件 1.Label(作用:显示文字) Web中: <asp:Label ID="Label1" runat="server" Text=&quo ...

  6. HANA SQL

    约束 注释 你可以给你的 SQL 语句添加注释来增加可读性和可维护性. SQL 语句中注释的分隔如下: l  双连字符“--”.所有在双连字符之后直到行尾的内容都被 SQL 解析器认为是注释. l  ...

  7. 关于C#调用C++ 的DLL传送字符串显示乱码的解决

    最近在做一个程序,想把某些功能用C++写成DLL供C#调用,但是在写好DLL用C#传递字符串参数时,在DLL中显示传送过来的字符串是乱码,DLL里的代码根本无法用这些字符串进行其它的处理.为此,花了一 ...

  8. Jquery实现图片轮换效果

    最近在看jquery书时,看到一个比较有趣的东西:图片轮换.这里和大家分享下我看完后写的一个demo.实现图片轮换要完成三部分模块:html部分.css部分.jqury部分.下面分步详细说明.1.ht ...

  9. logback 配置详解(二)——appender

    1.appender <appender>是<configuration>的子节点,是负责写日志的组件. <appender>有两个必要属性name和class.n ...

  10. Markdown中插入数学公式的方法

    Markdown中插入数学公式的方法 文章来源:http://blog.csdn.net/xiahouzuoxin/article/details/26478179 自从使用Markdown以来,就开 ...