【已经解决】如何使用GDI+的双缓冲解决GDI文字锯齿和闪烁等问题?
本帖最后由 Windows8 于 2012-6-24 18:32 编辑如何使用GDI+的双缓冲解决GDI文字锯齿和闪烁等问题呢?先看看效果:看看微软的,没有锯齿,不闪烁,还发光,我的呢,只能说恶心
#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#Include <APIConstants.au3>
#Include <GUITab.au3>
#Include <WinAPIEx.au3>
#include <GUIConstantsEx.au3>
Opt('MustDeclareVars', 1)
;Const $tMARGINS
;Const $tagMARGINS
_Main()
Func _Main()
Global $From1, $hBrush, $hFormat, $hFamily, $hFont, $tLayout;,$tMARGINS,$tagMARGINS
; Create GUI
$From1 = GUICreate("GDI+", 400, 300)
GUISetBkColor(0x0)
Const $tMARGINS = DllStructCreate("int;int;int;int")
DllStructSetData($tMARGINS, 1, -1)
_WinAPI_DwmExtendFrameIntoClientArea($From1, $tMARGINS)
GUISetState()
; Draw a string
_GDIPlus_Startup ()
Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($From1)
$hBrush = _GDIPlus_BrushCreateSolid (0xFF000000)
$hFormat = _GDIPlus_StringFormatCreate ()
$hFamily = _GDIPlus_FontFamilyCreate ("微软雅黑")
$hFont = _GDIPlus_FontCreate ($hFamily, 30, 0,2)
$tLayout = _GDIPlus_RectFCreate (140, 110, 600, 70)
_GDIPlus_GraphicsDrawStringEx ($hGraphic, "系统版本:Windows 7", $hFont, $tLayout, $hFormat, $hBrush)
; GUIRegisterMsg(0x0f, "WM_PAINT")
GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT")
; Loop until user exits
Do
Until GUIGetMsg() = -3
; Clean up resources
_GDIPlus_FontDispose ($hFont)
_GDIPlus_FontFamilyDispose ($hFamily)
_GDIPlus_StringFormatDispose ($hFormat)
_GDIPlus_BrushDispose ($hBrush)
_GDIPlus_GraphicsDispose ($hGraphic)
_GDIPlus_Shutdown ()
EndFunc ;==>_Main
Func MY_WM_PAINT($hWnd, $Msg, $wParam, $lParam)
;$hGraphic = _GDIPlus_GraphicsCreateFromHWND($From1)
_GDIPlus_GraphicsDrawStringEx ($hGraphic, "系统版本:Windows 7", $hFont, $tLayout, $hFormat, $hBrush)
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_PAINT
由于困难较多,折腾了一小时才弄出来,有很多没用的费代码,大虾们见谅 去看下_WinAPI_DrawThemeTextEx的帮助 去看下_WinAPI_DrawThemeTextEx的帮助
asionwu 发表于 2012-6-24 10:11 http://www.autoitx.com/images/common/back.gif
对,谢谢,它真的可以实现在Aero上写发光黑字。 不懂什么叫双缓冲.... 不懂什么叫双缓冲.... 友情提示,将“已经解决”改为“已解决” 正需要这个,我的程序开了很多子窗口,切换时候闪烁很厉害,研究研究. 很不错,谢谢分享 很不错,谢谢分享
页:
[1]