Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
U

User 11511469

@User 11511469
About
Posts
5
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • win32 - how avoid flickers?
    U User 11511469

    for avoid flickers i must do: 1 - use the WS_CLIPCHILDREN on parent window; 2 -

    case WM_ERASEBKGND:
    {
    return (LRESULT) 1;
    }
    break;

    seems be used only on parent window too. the child controls are transparent: (i use the button class for create a label. why?!? because be correctly transparent using the BS_OWNERDRAW style.)

    case WM_ERASEBKGND:
    {
    return (LRESULT)1;
    }
    break;

            case WM\_CTLCOLORSTATIC:
            {
                return (LRESULT)GetStockObject(NULL\_BRUSH);
            }
            break;
            case WM\_PAINT:
            {
                PAINTSTRUCT test;
                BeginPaint(hwnd, &test);
                image imglabel(test.rcPaint.right-test.rcPaint.left,test.rcPaint.bottom - test.rcPaint.top);
                brush brshbackcolor(inst->clrBackColor);
                brshbackcolor.ToDC(imglabel);
                brush brshTransparent;
    
                FillRect(imglabel,&test.rcPaint,brshbackcolor);
                if(inst->imgtest.haveimage())
                    DrawHICONtoHDC(imglabel, inst->imgtest,1,1);
                SetBkMode(imglabel,TRANSPARENT);
                char \*text=(char\*)inst->strCaption.c\_str();
                SetTextColor(imglabel,inst->clrTextColor );
                DrawTextEx(imglabel,text,-1,&test.rcPaint,DT\_LEFT,NULL);
                if(inst->blnBorder==true)
                    DrawEdge(imglabel, &test.rcPaint,BDR\_SUNKENINNER | BDR\_RAISEDOUTER,BF\_RECT);
                TransparentBlt(test.hdc,0,0,test.rcPaint.right,test.rcPaint.bottom,imglabel,0,0,test.rcPaint.right,test.rcPaint.bottom, inst->clrBackColor);
                //BitBlt(test.hdc,0,0,test.rcPaint.right,test.rcPaint.bottom,imglabel,0,0, SRCCOPY);
                EndPaint(hwnd, &test);
                return 0;
            }
            break;
    

    and the how i readraw the window:

    RECT d;
    GetClientRect(hwnd,&d);
    RedrawWindow(hwnd,&d,nullptr,RDW_UPDATENOW | RDW_INVALIDATE | RDW_ERASENOW);

    but when, with animation\timer, the next image is drawed above the older one, instead clean all control and then redraw it. (i need avoid the flicker and draw the control correctly and not 1 image above other) can anyone advice me?

    C / C++ / MFC question

  • C/C++ - Win32 : how can i find memory leaks?
    U User 11511469

    sorry i use GNU compiler

    Windows API graphics question c++ testing beta-testing

  • C/C++ - Win32 : how can i find memory leaks?
    U User 11511469

    why???? i never used GDI+ ;)

    Windows API graphics question c++ testing beta-testing

  • C/C++ - Win32 : how can i find memory leaks?
    U User 11511469

    how can check the rest of your program for non-GDI memory leaks, if i don't know how? :( what i can do, like i did with joystick, is comment some code, until i see where is it ;)

    Windows API graphics question c++ testing beta-testing

  • C/C++ - Win32 : how can i find memory leaks?
    U User 11511469

    i did a big program. now i have several memory leaks and they are hard to find. i did find several GDI memory leaks and i did MemoryDC and BitmapDC class's for avoid several memory leaks ;)

    class MemoryDC
    {
    private:
    HDC memoryDC;

    public:
    MemoryDC ()
    {
    memoryDC=CreateCompatibleDC(NULL);
    }

    operator HDC() const
    {
        return memoryDC;
    }
    
    ~MemoryDC ()
    {
       DeleteDC(memoryDC);
    }
    

    };

    class BitmapDC
    {
    private:
    MemoryDC hdcbitmap;
    HGDIOBJ bitmapold;
    HBITMAP bitmapcurrent;
    int intwidth;
    int intheight;

    void init(int width, int height)
    {
        bitmapcurrent = CreateBitmap(width, height, 1, 32, NULL);
        bitmapold = SelectObject(hdcbitmap, bitmapcurrent);
        intwidth=width;
        intheight=height;
    }
    
    void destroy()
    {
        SelectObject(hdcbitmap, bitmapold);
        DeleteObject(bitmapcurrent);
    }
    

    public:

    BitmapDC(int width, int height)
    {
        init(width, height);
    }
    
    BitmapDC()
    {
        init(1, 1);
    }
    
    void size(int width, int height)
    {
        destroy();
        init(width, height);
    }
    
    int Width()
    {
        return intwidth;
    }
    
    int Height()
    {
        return intheight;
    }
    
    BitmapDC& operator= (const BitmapDC &bitmapsource)
    {
        if (this == &bitmapsource)      // Same object?
            return \*this;
        destroy();
        init(bitmapsource.intwidth, bitmapsource.intheight);
        BitBlt(bitmapsource, 0, 0, intwidth, intheight, bitmapsource, 0, 0, SRCCOPY);
        return \*this;
    }
    
    BitmapDC& operator= (const HBITMAP &bitmapsource)
    {
        destroy();
        BITMAP bm;
        GetObject(bitmapsource,sizeof(bm),&bm);
        init(bm.bmWidth, bm.bmHeight);
        DrawHBITMAPtoHDC(bitmapsource,hdcbitmap);
        return \*this;
    }
    
    //testing the bitmao value if is nullptr
    bool operator != ( nullptr\_t ) const
    {
        return bitmapcurrent != nullptr;
    }
    
    bool operator==(const BitmapDC &other) const
    {
        return (other.bitmapcurrent == this->bitmapcurrent);
    }
    
    bool operator!=(const BitmapDC &other) const
    {
        return !(\*this == other);
    }
    
    operator HBITMAP() const
    {
        return bitmapcurrent;
    }
    
    operator HDC() const
    {
        return hdcbitmap;
    }
    
    ~BitmapDC()
    {
       destroy();
    }
    

    };

    like you

    Windows API graphics question c++ testing beta-testing
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups