Pelles C forum Pelles C forum
News: Version 6.00 released!
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
September 06, 2010, 08:49:39 PM


Login with username, password and session length


Pages: [1]   Go Down
  Print  
Author Topic: Use Windows Vista Double Buffer in WM_PAINT. (Usar Doble Buffer d Windows Vista)  (Read 361 times)
lucindom
Member
*
Offline Offline

Posts: 12


« on: June 18, 2010, 06:51:34 PM »

1) From PEllesC,  Create a Windows Project (Desde Pelles, crear un Proyecto Windows).
2) after the last #include directive, add the next (Despues de la ultima directiva #include, agregar)
     #include <uxtheme.h>
     #pragma comment(lib, "uxtheme.lib")
3) Declare the bIsbufered Variable:  static BOOL IsBufered = FALSE;
4) To this Option dont crash in Windows Xp, follow this steps ().
     3.1.- Open the Menu:  Project -> Project Options (Abrir en el Menu estas opciones).
     3.2.- In the Tab <Linker>, add the uxtheme.dll in the "Dll Files with delayed loading".
5) Add the Next Prototypes:
       static LRESULT Main_OnCreate(HWND, LPCREATESTRUCT);
       void MiPaint( HDC , RECT,  BOOL );
6) Add the Next Message Cracker: HANDLE_MSG(hwnd, WM_CREATE, Main_OnCreate);
7) Change the Main_OnDestroy: static void Main_OnDestroy(HWND hwnd){
    if (IsBufered) BufferedPaintUnInit(); PostQuitMessage(0); }
Cool Put the Main_OnCreate: static LRESULT Main_OnCreate(HWND hwnd, LPCREATESTRUCT lpstr) {
    IsBufered = (S_OK == BufferedPaintInit() );
    return 1;}
9) Change the Main_OnPaint:  static void Main_OnPaint(HWND hwnd){
      PAINTSTRUCT ps; RECT rc;GetClientRect(hwnd, &rc);
      HDC hdc = BeginPaint(hwnd, &ps);
         if (IsBufered){
            HDC hNewDC;         
            HPAINTBUFFER hBufferedPaint =  BeginBufferedPaint(hdc, &rc, BPBF_COMPATIBLEBITMAP, NULL, &hNewDC);
            if (hBufferedPaint) {
               MiPaint(hNewDC, rc, TRUE);
               EndBufferedPaint(hBufferedPaint, TRUE);
            } else{
               MiPaint(hdc, rc, FALSE);
            }
         } else {
            MiPaint(hdc, rc, FALSE);
         }
      EndPaint(hwnd, &ps); }
9) Add your Paint Function:
     void MiPaint( HDC thdc, RECT trc,  BOOL bBuffered ) {
           int iMonX = GetDeviceCaps(thdc, HORZRES);
           int iMonY = GetDeviceCaps(thdc, VERTRES);
           PatBlt(memoriDC, 0, 0, iMonX ,iMonY , WHITENESS);
           TextOut.....................
            ..... some code to show in the window.................
     }
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.096 seconds with 18 queries.