注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

gmd20的个人空间

// 编程和生活

 
 
 

日志

 
 

网上有人写的gvim全屏插件  

2013-01-11 11:48:21|  分类: 程序设计 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

不过感觉窗口刷新有点问题,我加了发送刷新消息的,但是gvim的窗口刷新实现有点怪,只刷新有字符的地方。

看上去如果不修改gvim的源码的话,背景总是没法刷新了。应该和代码的gui_redraw_block(row1, col1, row2, col2, flags 

有关。不管他了。另外那个鼠标滚轮要是能放到字体就跟好了。gvim的gui的代码看上去很老了,不怎么完善。


/*
* 来自 http://www.vim.org/scripts/script.php?script_id=2596
编译 cl /LD gvimfullscreen.c user32.lib
------------------------------
切换命令 :call libcallnr("gvimfullscreen.dll", "EnableFullScreen", 1)
* 把下面这行加到vimrc里面去,把<F11>映射为全屏切换键
* map <F11> <Esc>:call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)<CR
*/
#include <windows.h>

BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam);

BOOL CALLBACK FindWindowProc(HWND hwnd, LPARAM lParam)
{
HWND* pphWnd = (HWND*)lParam;

if (GetParent(hwnd))
{
*pphWnd = NULL;
return TRUE;
}
*pphWnd = hwnd;
return FALSE;
}

LONG _declspec(dllexport) ToggleFullScreen()
{
HWND hTop = NULL;
DWORD dwThreadID;

dwThreadID = GetCurrentThreadId();
EnumThreadWindows(dwThreadID, FindWindowProc, (LPARAM)&hTop);

if (hTop)
{
/* Determine the current state of the window */

if ( GetWindowLong(hTop, GWL_STYLE) & WS_CAPTION )
{
/* Has a caption, so isn't maximised */

int cx, cy;
cx = GetSystemMetrics(SM_CXSCREEN);
cy = GetSystemMetrics(SM_CYSCREEN);

/* Remove border, caption, and edges */
SetWindowLong(hTop, GWL_STYLE, GetWindowLong(hTop, GWL_EXSTYLE) & ~WS_BORDER);
SetWindowLong(hTop, GWL_STYLE, GetWindowLong(hTop, GWL_STYLE) & ~WS_CAPTION);
SetWindowLong(hTop, GWL_EXSTYLE, GetWindowLong(hTop, GWL_STYLE) & ~WS_EX_CLIENTEDGE);
SetWindowLong(hTop, GWL_EXSTYLE, GetWindowLong(hTop, GWL_STYLE) & ~WS_EX_WINDOWEDGE);

SetWindowPos(hTop, HWND_TOP, 0, 0, cx, cy, SWP_SHOWWINDOW);

/* Now need to find the child text area window
* and set it's size accordingly
*/
EnumChildWindows(hTop, EnumChildProc, 0);

// 重绘窗口,但好像有的背景还是没有刷新
RedrawWindow(hTop,NULL,NULL,
RDW_ERASE | RDW_FRAME | RDW_INTERNALPAINT | RDW_INVALIDATE |
RDW_ERASENOW | RDW_UPDATENOW |
RDW_ALLCHILDREN);
}
else
{
/* Already full screen, so restore all the previous styles */
SetWindowLong(hTop, GWL_EXSTYLE, GetWindowLong(hTop, GWL_EXSTYLE) | WS_BORDER);
SetWindowLong(hTop, GWL_STYLE, GetWindowLong(hTop, GWL_STYLE) | WS_CAPTION);
SetWindowLong(hTop, GWL_STYLE, GetWindowLong(hTop, GWL_STYLE) | WS_SYSMENU);
SetWindowLong(hTop, GWL_STYLE, GetWindowLong(hTop, GWL_STYLE) | WS_MINIMIZEBOX);
SetWindowLong(hTop, GWL_STYLE, GetWindowLong(hTop, GWL_STYLE) | WS_MAXIMIZEBOX);
SetWindowLong(hTop, GWL_STYLE, GetWindowLong(hTop, GWL_STYLE) | WS_SYSMENU);
SetWindowLong(hTop, GWL_STYLE, GetWindowLong(hTop, GWL_STYLE) | WS_EX_CLIENTEDGE);
SetWindowLong(hTop, GWL_STYLE, GetWindowLong(hTop, GWL_STYLE) | WS_EX_WINDOWEDGE);
SetWindowLong(hTop, GWL_STYLE, GetWindowLong(hTop, GWL_STYLE) | WS_THICKFRAME);
SetWindowLong(hTop, GWL_STYLE, GetWindowLong(hTop, GWL_STYLE) | WS_DLGFRAME);

SendMessage(hTop, WM_SYSCOMMAND, SC_RESTORE, 0);
SendMessage(hTop, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
}
}
return GetLastError();
}

BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam)
{
char lpszClassName[100];
GetClassName(hwnd, lpszClassName, 100);
if ( strcmp(lpszClassName, "VimTextArea") == 0 )
{
int cx, cy;
cx = GetSystemMetrics(SM_CXSCREEN);
cy = GetSystemMetrics(SM_CYSCREEN);

SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_EX_CLIENTEDGE);
SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_EX_WINDOWEDGE);

SetWindowPos(hwnd, HWND_TOP, 0, 0, cx, cy, SWP_SHOWWINDOW);
}
return TRUE;

}



  评论这张
 
阅读(711)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017