cambalinho 142 Practically a Posting Shark

seems that i have 1 problem on my BitmapDC(line):

BitBlt(bitmapsource, 0, 0, intwidth, intheight, bitmapsource, 0, 0, SRCCOPY);

it's:

BitBlt(bitmapsource, 0, 0, intwidth, intheight, HBitmap, 0, 0, SRCCOPY);

besides the variable life. what you can tell me about returning HBITMAP?
seems that everytime that i need it, i must recreate it with HDC.

cambalinho 142 Practically a Posting Shark

see my MemoryDc and BitmapDC class's:

class MemoryDC
{
private:
    HDC memoryDC;

public:
    MemoryDC ()
    {
        HDC hdc=GetDC(GetDesktopWindow());
        memoryDC=CreateCompatibleDC(hdc);
        ReleaseDC(GetDesktopWindow(),hdc);
    }

    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();
    }
};

now see my image class:

class image
{
private:
    ULONG_PTR m_gdiplusToken;
    Gdiplus::GdiplusStartupInput gdiplusStartupInput;
    BitmapDC HBitmap;
    Image *img=NULL;
    bool isimgused=false;
    bool isGDIPLUSIniciated=false;
    int imageheight=0;
    int imageweight=0;
    int framecount=0;
    int intSelectFrame=0; …
cambalinho 142 Practically a Posting Shark

i'm converting the VB6 DIB code to C\C++ from: http://www.tannerhelland.com/42/vb-graphics-programming-3/
V – Using DIB Sections
but doing by steps...
how can i convert:

ReDim ImageData(0 To 2, 0 To bm.bmWidth - 1, 0 To bm.bmHeight - 1)

to C\C++?
for then use it on GetDIBits() function

cambalinho 142 Practically a Posting Shark

the problem was that i was drawing 2 times on HDC control(background color and image). so i did another double buffering and no more flickers ;)
thanks for all

cambalinho 142 Practically a Posting Shark

i'm sorry, but i don't know how :(
you just mean copy the WM_PAINT to here?

cambalinho 142 Practically a Posting Shark

i'm getting flickers on windows. the windows have CW_USEDEFAULT size and i use the WS_CLIPCHILDREN.
on WM_PAINT i use my image class with client rect size.
it's big. but not more big than screen.
the WM_PAINT:

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

                case WM_PAINT:
                {
                    PAINTSTRUCT  ps;
                    BeginPaint(inst->hwnd, &ps);
                    RECT a;
                    GetClientRect(inst->hwnd, &a);

                    image imgpaint(a.right,a.bottom);//creates an image with form\window size
                    imgpaint.Brush(inst->clrBackColor);
                    pen test;
                    imgpaint.Pen(test);
                    imgpaint.DrawRectangle(0,0,imgpaint.width()+1, imgpaint.height()+1);
                    if (inst->Paint!=NULL)
                        inst->Paint(imgpaint);
                    //draws the image on HDC form\window
                    BitBlt(ps.hdc, inst->pntScrollDC.x,inst->pntScrollDC.y , imgpaint.width(), imgpaint.height(), imgpaint,0 ,0, SRCCOPY);
                    //inst->pntScrollDC it's the scroll position, but on start it's 0(zero)
                    EndPaint(inst->hwnd, &ps);
                    return 0;
                }
                break;

and see the Refresh() function:

void Refresh()
        {
            RECT a;
            GetClientRect(hwnd,&a);
            InvalidateRect(hwnd,&a,FALSE);
        }

creating the window:

hwnd = CreateWindowEx(WS_EX_LAYERED,classname, strCaption.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN,
                                  CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, parent, NULL, mod, this);

showing these: how can i avoid the flickers on form?
(i use a timer animation in these situation)
i can Refresh() the window with a RECT, but the brush color must be changed to backcolor;

cambalinho 142 Practically a Posting Shark

the nPage is the parent client bottom and the nMax is the entire scroll area(vertical\horizontal).

cambalinho 142 Practically a Posting Shark

i did a class for tell me what child controls the form have. and another class for tell me the last child control position(more big top and left) inclued the bottom\right.
ok. i have the most big X(the last control plus it's width) and:

RECT rtcParent;
        GetClientRect(ActivatedForm,&rtcParent);

heres how i'm trying calculate the nMax for the horizontal scrollbar:

if(ws.x>rtcParent.right)
                SCinfo.nMax =ws.y-rtcParent.bottom + GetSystemMetrics(SM_CXVSCROLL) + 7;
            else
                SCinfo.nMax =ws.y-rtcParent.bottom +7 ;

but i can't see the most right button :(
so the nMax calculation is incorrect. the X seems correct, because i debug it.
can anyone explain to me how can i calculate it?

cambalinho 142 Practically a Posting Shark

please see these image: http://www.sevenforums.com/attachments/tutorials/17261d1247158804-windows-media-player-taskbar-toolbar-wmp_toolbar_in_win_7.png
like you see, we have 1 minitoolbar on taskbar. how can i add something similar to it on taskbar?

cambalinho 142 Practically a Posting Shark

i mean add a button on taskbar for do some action

cambalinho 142 Practically a Posting Shark

using that code, i can add a child control,too, on task bar but will be above the icon\button where is the program :(
can i add 1 button after the others?

cambalinho 142 Practically a Posting Shark

i must include the Shobjidl.h but i need include anotherthing for the linker too:
"undefined reference to `_imp__CoCreateInstance@20'"
i have several errors like these. but i can't find the right lib, can you help me?

cambalinho 142 Practically a Posting Shark

i'm sorry, but what is the library for use the ITaskbarList and others?

cambalinho 142 Practically a Posting Shark

i'm changind the standard messagebox for add more options.
using the hook procedure, i can center to it's parent and the text too. and i added a checkbox(without a window procedure).
my question: how can i get the checkbox state?
i use SetWindowsHookEx() with WH_CBT flag. can i use with mouse too?

cambalinho 142 Practically a Posting Shark

i was geting wrong parent. now see these code:

enum ControlPositions
{
    CenterCenter=0,
    LeftCenter=1,
    LeftTop=2,
    LeftBottom=3,
    CenterTop=4,
    CenterBottom=5,
    RightTop=6,
    RightCenter=7,
    RightBottom=8,
    LeftRightTop=9,
    LeftRightBottom=10,
    LeftTopBottom=11
};

void ControlPosition(HWND hWnd, ControlPositions ControlPosition=CenterCenter)
{
    //getting the parent
    HWND parent=GetDesktopWindow();
    if (!(GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD) && parent==GetDesktopWindow())
    {
        if(GetProp(hWnd, "parent")!=NULL) //i added these property when the form is created and when the parent it's changed
            parent=(HWND)GetProp(hWnd, "parent");
    }
    else
        parent=GetParent(hWnd);

    //getting the controls positions\size
    //depending if is a child or not
    RECT frm,frmparent;

    if ((GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD))
    {
        GetClientRect(parent, &frmparent);
        GetWindowRect(hWnd, &frm);
        ScreenToClient(parent,&frm);
    }
    else
    {
        GetWindowRect(parent, &frmparent);
        GetWindowRect(hWnd, &frm);
    }

    //calculate the position choosed
    LONG x;
    LONG y;
    if (parent!=GetDesktopWindow())
    {
        if(ControlPosition==0)
        {
            x=(frmparent.left+((frmparent.right-frmparent.left)/2)) - ((frm.right-frm.left)/2);
            y=(frmparent.top+((frmparent.bottom-frmparent.top)/2)) - ((frm.bottom-frm.top)/2);
        }
        else if (ControlPosition==1)
        {
            x=frmparent.left;
            y=(frmparent.top+((frmparent.bottom-frmparent.top)/2)) - ((frm.bottom-frm.top)/2);
        }

    }
    else //center of screen
    {
        if(ControlPosition==0)
        {
            x=(((frmparent.right-frmparent.left)/2)) - ((frm.right-frm.left)/2);
            y=(((frmparent.bottom-frmparent.top)/2)) - ((frm.bottom-frm.top)/2);
        }
        else if (ControlPosition==1)
        {
            x=0;
            y=(((frmparent.bottom-frmparent.top)/2)) - ((frm.bottom-frm.top)/2)+3;
        }
    }

    //position the control
    SetWindowPos(hWnd,0,x ,y,0,0, SWP_NOSIZE |  SWP_NOZORDER);
}

these function works greate for WS_CHILD controls. but when it's not WS_CHILD and ControlPosition is 1, i see the control, on x, more pixels(maybe 4) on left. how can i correct these?

cambalinho 142 Practically a Posting Shark

i know get the windows taskbar HWND:

HWND GetDesktopToolBar()
{
    return FindWindow("Shell_Traywnd", "");
}

now i can do:
1 - add controls on left side(close to Start Button)... but the click messages isn't working. maybe because use the form messages procedure. can anyone correct me?;
2 - enable\visible it.

but, for exemple, the windows media player minitoolbar is added to Tray Notifiction left side. how can i add it?
i know the minitoolbar it's an DLL. but how can i add it to taskbar?

cambalinho 142 Practically a Posting Shark

heres my function for convert to client using RECT:

void ScreenToClient(HWND WindowDestination, RECT *WindowRectangle)
{
    POINT a={WindowRectangle->right, WindowRectangle->bottom};
    WindowRectangle->left=0;
    WindowRectangle->top=0;
    ::ScreenToClient(WindowDestination,&a);
    WindowRectangle->right=a.x;
    WindowRectangle->bottom=a.y;
}

maybe have some errors too :(

void Center()
        {
            RECT frm,frmparent;
            GetWindowRect(GetParent(hwnd), &frmparent);
            ScreenToClient(GetParent(hwnd),&frmparent);

            GetWindowRect(hwnd, &frm);
            ScreenToClient(hwnd,&frm);


            LONG x=frmparent.right/2 - (frm.right-frm.left)/2;
            LONG y=100;


            SetWindowPos(hwnd,0,x,y,0,0, SWP_NOSIZE |  SWP_NOZORDER);
        }

i'm trying calculate the x and y positions for the control. but i'm getting a big values even with 7 digits :(
can anyone correct me please?

cambalinho 142 Practically a Posting Shark

how can i draw a string, transparent, clear?
what i mean is, depending on font name, i can see a white color arround the letters :(
how can avoid that effect?
SetBKMode() is transparent(or i can use a HBRUSH transparent(it's the same))

cambalinho 142 Practically a Posting Shark

ddanbe: i belive that i don't have your experience, but we must, for exemple, use the const on class constructors and overloading operations for not lose data. and some errors are dificulty to find them, because the compiler don't detect them.
on these simple function we don't need use the const... so why he used? maybe because the negative\positive can change the variables results, i don't know... and maybe the '()' can avoid that problem. but for he use the 'const' it's because his variables are changed on some place

cambalinho 142 Practically a Posting Shark

i agree with Suzie999. the 'const' key word is for avoid that the variable value is changed. good for function parameters(1 time i was getting problems, until i change the parameter(on header function) to const.
maybe, when you change the positive\negative values, you realy need the const.
but for test try these:

Mat3D R_z(double RotAngle)
{
   double S = sin (RotAngle);
   double C = cos (RotAngle);

  Mat3D U;

  U.m_Mat[0][0] =  +(C);  U.m_Mat[0][1] =  +(S);  U.m_Mat[0][2] = 0.0;
  U.m_Mat[1][0] =  -(S);  U.m_Mat[1][1] =  +(C);  U.m_Mat[1][2] = 0.0;
  U.m_Mat[2][0] = 0.0;  U.m_Mat[2][1] = 0.0;  U.m_Mat[2][2] = 1.0;

  return U;
}

is just a thot: maybe the Suzie999 can correct us the diference(i didn't tested the code)
like you see they aren't const and their values are inside of parentheses('()'). maybe in these way, their values aren't changed and only show them with the negative\positive signal

cambalinho 142 Practically a Posting Shark

maybe you have right, but i can't delete a new pointer, after return it. i belive.

cambalinho 142 Practically a Posting Shark

that's why i gived you the update function:

CHOOSEFONT ShowSelectFont(HWND hwnd=GetForegroundWindow())
{
    CHOOSEFONT cf = {sizeof(CHOOSEFONT)};
    LOGFONT* lf = new LOGFONT;
    cf.Flags = CF_EFFECTS | CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
    cf.hwndOwner = hwnd;
    cf.lpLogFont = lf;
    cf.rgbColors = RGB(0,0,0);
    cf.lpLogFont->lfStrikeOut=FALSE;
    cf.lpLogFont->lfUnderline=FALSE;
    cf.lpLogFont->lfHeight=-MulDiv(12, GetDeviceCaps(GetDC(hwnd), LOGPIXELSY), 72);//change font size
    _tcscpy(cf.lpLogFont->lfFaceName, "Arial" ); //we must include tchar.h
    ChooseFont(&cf);
        HFONT hf = CreateFontIndirect(lf);
        //lf->lfQuality=PROOF_QUALITY;
        cf.lpLogFont = lf;
    //delete lf; //i can't delete what i'm using it
            return cf;
}
cambalinho 142 Practically a Posting Shark

see the image:
1 - the blue and the image on left couner is the form;
2 - the button is behind the label.
3 - the image and text it's a transparent label(usin regions functions. the big size, can slow). if by some reason, you can't see the text perfectly, use another backcolor or brush.

cambalinho 142 Practically a Posting Shark

just a tip: if you choose the font on control, and the control isn't resize. just use\select the same font to txthdc and then calculate the size ;)
thanks to all

cambalinho 142 Practically a Posting Shark

now works fine:

CHOOSEFONT ShowSelectFont(HWND hwnd=GetForegroundWindow())
{
    CHOOSEFONT cf = {sizeof(CHOOSEFONT)};
    LOGFONT* lf = new LOGFONT;
    cf.Flags = CF_EFFECTS | CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
    cf.hwndOwner = hwnd;
    cf.lpLogFont = lf;
    cf.rgbColors = RGB(0,0,0);
    cf.lpLogFont->lfStrikeOut=FALSE;
    cf.lpLogFont->lfUnderline=FALSE;
    cf.lpLogFont->lfHeight=-MulDiv(12, GetDeviceCaps(GetDC(hwnd), LOGPIXELSY), 72);//change font size
    _tcscpy(cf.lpLogFont->lfFaceName, "Arial" ); //we must include tchar.h
    ChooseFont(&cf);

        HFONT hf = CreateFontIndirect(lf);
        //lf->lfQuality=PROOF_QUALITY;
        cf.lpLogFont = lf;
    //delete lf; //i can't delete what i'm using it
            return cf;


}

//heres my image DrawText()
void DrawText(string strText,int PosX=0, int PosY=0)
    {
        // geting the text rectangle
        RECT r = { 0, 0, 0, 0 };
        char *text=(char*)strText.c_str();
        //change the position of the text

        //draw the text

        HBRUSH hBackBrush=imgBrush;
        HBRUSH oldBrush=(HBRUSH)SelectObject(HBitmap,hBackBrush);
        HPEN hBackPen=(HPEN)imgPen;
        HPEN oldPen=(HPEN)SelectObject((HDC)HBitmap,hBackPen);

        HFONT hFont=CreateFontIndirect(chFont.lpLogFont);
        HFONT holdfont=(HFONT)SelectObject((HDC)HBitmap,hFont);
        SetTextColor(HBitmap,chFont.rgbColors);

        ::DrawText(HBitmap, text, -1,&r,DT_LEFT | DT_EXPANDTABS | DT_CALCRECT);
        r.left+=PosX;
        r.top+=PosY;
        r.bottom+= PosX;
        r.right+= PosY;
        SetBkMode(HBitmap,TRANSPARENT);

        ::DrawText(HBitmap, text, -1,&r,DT_LEFT | DT_EXPANDTABS);

        SelectObject(HBitmap,holdfont);
        DeleteBrush(hFont);

        SelectObject(HBitmap,oldBrush);
        DeleteBrush(hBackBrush);

        SelectObject(HBitmap,oldPen);
        DeleteBrush(hBackPen);
    }

//heres how i draw it:
case WM_PAINT:
            {
                PAINTSTRUCT  ps;
                BeginPaint(inst->hwnd, &ps);
                image imgLabel(inst->intWidth+1,inst->intHeight+1);

                //back color
                /*pen penTransparent;
                imgLabel.Pen(penTransparent);
                imgLabel.Brush(inst->clrBackColor);
                imgLabel.DrawRectangle(0,0,imgLabel.width()+2,imgLabel.height()+2);*/
                SetDCBrushColor(imgLabel,inst->clrBackColor);
                SetDCBrushColor(ps.hdc,inst->clrBackColor);

                //draw image
                DrawHICONtoHDC( imgLabel, inst->imgtest);

                //draw text
                brush transparentbrush;
                imgLabel.Brush(transparentbrush);

                SetBkMode(imgLabel,TRANSPARENT);//text background transparent
                imgLabel.Font(inst->chFont);
                imgLabel.DrawText(inst->strCaption.c_str());

                //NULL the window region
                SetWindowRgn(inst->hwnd,NULL,FALSE);


                if(inst->blnTransparent==true)
                {
                    region lblRegion(imgLabel,GetPixel(imgLabel,0,0));
                    SetWindowRgn(inst->hwnd,lblRegion,FALSE);
                    TransparentBlt(ps.hdc,0,0,imgLabel.width(), imgLabel.height(), imgLabel,0,0,imgLabel.width(), imgLabel.height(),GetPixel(imgLabel,0,0));

                }
                else
                {
                    BitBlt(ps.hdc,0,0,imgLabel.width(), imgLabel.height(), imgLabel,0,0,SRCCOPY);
                }


                EndPaint(inst->hwnd, &ps);
                return 0;
            }
            break;
//i create the memory DC with control size+1. for don't lose any pixel;
//if your draw it's strange, like not perfect design, please change the back color or brush

thanks for all

cambalinho 142 Practically a Posting Shark
CHOOSEFONT ShowSelectFont(HWND hwnd=GetForegroundWindow())
{
    CHOOSEFONT cf = {sizeof(CHOOSEFONT)};
    LOGFONT lf;
    cf.Flags = CF_EFFECTS | CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
    cf.hwndOwner = hwnd;
    cf.lpLogFont = &lf;
    cf.rgbColors = RGB(0,0,0);
    cf.lpLogFont->lfStrikeOut=FALSE;
    cf.lpLogFont->lfUnderline=FALSE;
    cf.lpLogFont->lfHeight=-MulDiv(12, GetDeviceCaps(GetDC(hwnd), LOGPIXELSY), 72);//change font size
    _tcscpy(cf.lpLogFont->lfFaceName, "Arial" ); //we must include tchar.h
    if(ChooseFont(&cf))
    {
        HFONT hf = CreateFontIndirect(&lf);
        if(hf)
        {
            return cf;
        }
        else
        {
            MessageBox(hwnd, "Font creation failed!", "Error", MB_OK | MB_ICONEXCLAMATION);
            //return  (CHOOSEFONT)(HFONT)GetStockObject(DEFAULT_GUI_FONT);
        }
    }
}


///
void Font(CHOOSEFONT chft)
    {
        chFont=chft;
    }

    void DrawText(string strText,int PosX=0, int PosY=0)
    {
        SetLastError(0);
        // geting the text rectangle
        RECT r = { 0, 0, 0, 0 };
        char *text=(char*)strText.c_str();
        //change the position of the text
        r.left=PosX;
        r.top=PosY;
        r.bottom=HBitmap.Width() + PosY;
        r.right=HBitmap.Height() + PosX;
        SetBkMode(HBitmap,TRANSPARENT);
        //draw the text

        HBRUSH hBackBrush=imgBrush;
        HBRUSH oldBrush=(HBRUSH)SelectObject(HBitmap,hBackBrush);
        HPEN hBackPen=(HPEN)imgPen;
        HPEN oldPen=(HPEN)SelectObject((HDC)HBitmap,hBackPen);

        HFONT hFont=CreateFontIndirect(chFont.lpLogFont);
        HFONT holdfont=(HFONT)SelectObject((HDC)HBitmap,hFont);


        SetTextColor(HBitmap,chFont.rgbColors);

        ::DrawText(HBitmap, text, -1,&r,DT_LEFT);

        SelectObject(HBitmap,holdfont);
        DeleteBrush(hFont);

        SelectObject(HBitmap,oldBrush);
        DeleteBrush(hBackBrush);
        SelectObject(HBitmap,oldPen);
        DeleteBrush(hBackPen);
    }

seems that i can lose the cf.lpLogFont, because it's a pointer :(
but i have the size(cf.lpLogFont->lfHeight), i only - tested - lose the font name :(
i see the the color(with white on back and it's transparent) and the size. the font name isn't used. if i'm not losing the pointer, so the problem must be with DrawText(). please tell me something

cambalinho 142 Practically a Posting Shark

heres my function for select the font:

CHOOSEFONT ShowSelectFont(HWND hwnd=GetForegroundWindow())
{

    CHOOSEFONT cf = {sizeof(CHOOSEFONT)};
    LOGFONT lf;

    cf.Flags = CF_EFFECTS | CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
    cf.hwndOwner = hwnd;
    cf.lpLogFont = &lf;
    cf.rgbColors = RGB(0,0,0);
    cf.lpLogFont->lfStrikeOut=FALSE;
    cf.lpLogFont->lfUnderline=FALSE;
    cf.lpLogFont->lfHeight=-MulDiv(12, GetDeviceCaps(GetDC(hwnd), LOGPIXELSY), 72);//change font size
    _tcscpy(cf.lpLogFont->lfFaceName, "Arial" ); //we must include tchar.h

    if(ChooseFont(&cf))
    {
        HFONT hf = CreateFontIndirect(&lf);
        if(hf)
        {
            return cf;
        }
        else
        {
            MessageBox(hwnd, "Font creation failed!", "Error", MB_OK | MB_ICONEXCLAMATION);
            //return  (CHOOSEFONT)(HFONT)GetStockObject(DEFAULT_GUI_FONT);
        }
    }
}

heres how i use it:

CHOOSEFONT testfont=ShowSelectFont();

lbltest.setFont(testfont);

//on label class:
private:
CHOOSEFONT chFont;

public:
void setFont(const CHOOSEFONT font)
{
    chFont=font;
}

//on WM_PAINT:
imglabel.TextColor(inst->chFont.rgbColors);
imglabel.Font(inst->chFont);

//inst is the label pointer, that gives me the chFont.
//imglabel is object image class


void Font(CHOOSEFONT chft)
    {
        chFont=chft;
    }

void DrawText(string strText,int PosX=0, int PosY=0)
    {
        // geting the text rectangle
        RECT r = { 0, 0, 0, 0 };
        char *text=(char*)strText.c_str();
        //change the position of the text
        r.left=PosX;
        r.top=PosY;
        r.bottom=HBitmap.Width() + PosY;
        r.right=HBitmap.Height() + PosX;
        SetBkMode(HBitmap,TRANSPARENT);
        //draw the text

        HBRUSH hBackBrush=imgBrush;
        HBRUSH oldBrush=(HBRUSH)SelectObject(HBitmap,hBackBrush);
        HPEN hBackPen=(HPEN)imgPen;
        HPEN oldPen=(HPEN)SelectObject((HDC)HBitmap,hBackPen);

        HFONT *hFont=(HFONT*)chFont.lpLogFont; //lpLogFont it's a pointer
        HFONT holdfont=(HFONT)SelectObject((HDC)HBitmap,*hFont);

        SetTextColor(HBitmap,chFont.rgbColors);

        ::DrawText(HBitmap, text, -1,&r,DT_LEFT);

        SelectObject(HBitmap,holdfont);
        DeleteBrush(*hFont);

        SelectObject(HBitmap,oldBrush);
        DeleteBrush(hBackBrush);
        SelectObject(HBitmap,oldPen);
        DeleteBrush(hBackPen);
    }

https://msdn.microsoft.com/en-us/library/windows/desktop/ms646832%28v=vs.85%29.aspx

by some reason, the font name and size isn't selected, but the color is.
what i'm doing wrong?

cambalinho 142 Practically a Posting Shark

i did a mistake with DrawThemeText():

SIZE GetStringSize(const string text, string ControlName="", int PartID=0, int StateID=0)
{

    RECT textrect={0};
    HDC txthdc=GetDC(GetForegroundWindow());

    DrawText (txthdc,text.c_str(),-1 ,&textrect,DT_CALCRECT| DT_EXPANDTABS);

    if(ControlName=="")
    {
        DrawText (txthdc,text.c_str(),-1 ,&textrect,DT_CALCRECT| DT_EXPANDTABS);

    }
    else
    {
        HTHEME hTheme = OpenThemeData(GetForegroundWindow(), towstring(ControlName).c_str());

        GetThemeTextExtent(hTheme,txthdc, PartID , StateID,towstring(text).c_str(),text.size(),DT_CALCRECT | DT_EXPANDTABS,NULL, &textrect);

        //DrawThemeText(hTheme, txthdc, PartID , StateID, towstring(text).c_str(),text.size(),DT_CALCRECT | DT_EXPANDTABS | DT_LEFT,0,&textrect);
        CloseThemeData(hTheme);
    }
    ReleaseDC(GetDesktopWindow(),txthdc);
    SIZE a={textrect.right-textrect.left, textrect.bottom-textrect.top};
    return a;
}

if we do not use DT_CALCRECT flag, the text is drawed on focus window or parent window.

cambalinho 142 Practically a Posting Shark

finally i found it:

HWND GetDesktopToolBar()
{
    return FindWindow("Shell_Traywnd", "");
}

i have 1 question: how can i add a toolbar(like the old windows media player mini-toolbar) or buttons on it?

cambalinho 142 Practically a Posting Shark

the GetDesktopWindow() give me the desktop HWND, but how can i get the desktop toolbar HWND?
i belive that theres 1 function for get the toolbar on windows, but i don't know how :(

cambalinho 142 Practically a Posting Shark

doing an irregular control without using Regions.
please correct me: hide a backcolor(or other color) is called transparent?
or i'm using the wrong terms\words or i don't know. please correct me

cambalinho 142 Practically a Posting Shark

(i'm using win7)
i can use the Region functions for get the transparent control. but, in some cases, i can get bad resoltes(.
i have read that i can use brushes for get the transparent control. can anyone explain better?

cambalinho 142 Practically a Posting Shark

problem resolved, but i'm confused.
the firefox or other browser activated the Flash Player addon, but not on video. on video, i was, always with HTML 5, instead Flash Player(i have seen the video menu). for resolve that i installed another addon for activate the Flash Player. i'm confused, because, on past, these never happen :(

cambalinho 142 Practically a Posting Shark

the internet explorer can show me the online video without so many problems. but the browser is very slow :(
any advice please?

cambalinho 142 Practically a Posting Shark

my Region code affects the ToolTip control. so i did my own ToolTip control and now works fine. thanks for all

cambalinho 142 Practically a Posting Shark

the HWND_TOP with SetWindowPos() works fine. but(very important) the WS_CLIPSIBLINGS child style is used when i create the child control for avoid several drawed problems when we use the WS_CLIPCHILDREN style on parent control

cambalinho 142 Practically a Posting Shark

yes.. it's dual core. but how can resolve the problem? :(

cambalinho 142 Practically a Posting Shark

for correct it i nust take off the '*' pointer operator and i create precompiled routines:

#define GetProperty(x) std::bind(&x, this)
#define SetProperty(x) std::bind(&x, this, std::placeholders::_1)

//how use it:
property <string> caption{GetProperty(tooltip::GetCaption),SetProperty(tooltip::SetCaption)};

thanks for all

cambalinho 142 Practically a Posting Shark

memory shared 1151MB; video system memory 0MB; and have 3GB's of ram. i use the firefox, but the chrome have the same problem

cambalinho 142 Practically a Posting Shark

i did several mistakes. and i resolve the problem. see my new function:

SIZE GetStringSize(const string text, string ControlName="", int PartID=0, int StateID=0)
{

    RECT textrect={0};
    HDC txthdc=GetDC(GetForegroundWindow());

    if(ControlName=="")
    {
        DrawText (txthdc,text.c_str(),-1 ,&textrect,DT_CALCRECT| DT_EXPANDTABS);

    }
    else
    {
        HTHEME hTheme = OpenThemeData(GetForegroundWindow(), towstring(ControlName).c_str());

        GetThemeTextExtent(hTheme,txthdc, PartID , StateID,towstring(text).c_str(),text.size(),DT_CALCRECT | DT_EXPANDTABS,NULL, &textrect);

        DrawThemeText(hTheme, txthdc, PartID , StateID, towstring(text).c_str(),text.size(),DT_LEFT,0,&textrect);
        CloseThemeData(hTheme);
    }
    ReleaseDC(GetDesktopWindow(),txthdc);
    SIZE a={textrect.right-textrect.left, textrect.bottom-textrect.top};
    return a;
}

these function is prepared for GDI and THEME. my problem was with my Region function(again) :(

cambalinho 142 Practically a Posting Shark

maybe is 2.00GHz of CPU and 256MB of graphic and i must use less quallity on youtube.

cambalinho 142 Practically a Posting Shark

my CPU can be 50% or even 100% with online videos(i'm using firefox, but i notice on chrome too).
maybe i have the Hadware\Video Acellerator Activated or something. can anyone advice me?
- audio seems playing normaly;
- video can freezes some frames :(

cambalinho 142 Practically a Posting Shark

see my property constructor:

template <typename T>
class property
{
private:
    T PropertyValue;
    std::function<T(void)> getf;
    std::function<void(T)> setf;
public:

    property(const T &value)
    {
        getf=nullptr;
        setf=nullptr;
        PropertyValue=value;
    }

    property(const property &value)  :  PropertyValue(value.PropertyValue) , getf(value.getf)
    {
    }

    property(std::function<T(void)> GetFunction=nullptr,std::function<void(T)> SetFunction=nullptr)
    {
        setf=SetFunction;
        getf=GetFunction;
    }

inside a class i have 2 functions:

void SetCaption(string strtext)
    {
        strCaption=strtext;
        RECT textrect={0};
        HDC txthdc=GetDC(hwnd);
        DrawText (txthdc,strCaption.c_str(),strCaption.size(),&textrect,DT_CALCRECT | DT_LEFT);
        SetWindowPos(hwnd, HWND_TOP, 0, 0, textrect.right-textrect.left, textrect.bottom-textrect.top, SWP_NOMOVE);
    }

    string GetCaption()
    {
        return strCaption;
    }

heres how i create the property:
(to complex yes :( )

property <string> caption{std::bind(&tooltip::GetCaption, *this),std::bind(&tooltip::SetCaption, *this, std::placeholders::_1)};

no error message. but my application gives me an error(no message.. just tells me that the programs stops) and the OS closes the program.
what i'm doing wrong?

cambalinho 142 Practically a Posting Shark

i have these function for get the string size:

SIZE GetStringSize(string text, HWND hdccontrol=GetForegroundWindow())
{
    RECT textrect={0};
    HDC txthdc=GetDC(hdccontrol);
    DrawText (txthdc,text.c_str(),-1,&textrect,DT_CALCRECT);
    ReleaseDC(hdccontrol,txthdc);
    SIZE a={textrect.right-textrect.left, textrect.bottom-textrect.top};
    return a;
}

the 1st string size isn't correct. then i get the correct one. so why i get, sometimes, the wrong size?
something to do with my HDC's font's or something. so i can't control it correctly :( can anyone advice me?

cambalinho 142 Practically a Posting Shark

is there any message for test when the Z-Order is changed?

cambalinho 142 Practically a Posting Shark

i did several ways and nothing work correctly.
i have 2 controls:
1 - label: with an animation;
2 - the tooltip is showed on top until the label is re-painted.
so is there another way for put the control, always, on top?

cambalinho 142 Practically a Posting Shark

i have these function for create the tooltip:

HWND CreateToolTip(HWND hwndTool, string text)
{

    /*INITCOMMONCONTROLSEX icc;

    icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
    icc.dwICC = ICC_BAR_CLASSES | ICC_TAB_CLASSES | ICC_WIN95_CLASSES;

    InitCommonControlsEx(&icc);*/
    if (text=="")
    {
        return FALSE;
    }
    // Get the window of the tool.
    //HWND hwndTool = GetDlgItem(hDlg, toolID);

    // Create the tooltip. g_hInst is the global instance handle.
    HWND hwndTip = CreateWindowEx(0, TOOLTIPS_CLASS, NULL,
        TTS_ALWAYSTIP|WS_POPUP, //| TTS_BALLOON,
        CW_USEDEFAULT, CW_USEDEFAULT,
        CW_USEDEFAULT, CW_USEDEFAULT,
        GetParent(hwndTool), NULL,
        hinstance, NULL);

    if (!hwndTool || !hwndTip)
    {
        MessageBox(NULL, "Couldn't create the ToolTip control.", "Error", MB_OK);
        return (HWND)NULL;
    }



    // Associate the tooltip with the tool.
    TOOLINFO toolInfo = { 0 };
    toolInfo.cbSize =sizeof (TOOLINFO);// TTTOOLINFOA_V1_SIZE;
    toolInfo.hwnd = GetParent(hwndTool);
    toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
    toolInfo.uId = (UINT_PTR)hwndTool;
    toolInfo.lpszText =(LPSTR) text.c_str();



    if (!SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &toolInfo)) //Will add the Tool Tip on Control
    {
        MessageBox(NULL,to_string(GetLastError()).c_str(), "Error", MB_OK);
    }

    if (SendMessage(hwndTip, TTM_ACTIVATE, TRUE,0)) //Will add the Tool Tip on Control
    {
        MessageBox(NULL,to_string(GetLastError()).c_str(), "Error", MB_OK);

    }

    return hwndTip;
}

my question is: how can i show the ToolTip manually?
i was trying using the ShowWindow() function, but my region function is affecting if the tooltip is showing or not(i'm testing)

cambalinho 142 Practically a Posting Shark

thanks for all

cambalinho 142 Practically a Posting Shark

yes. i have 100% sure. the pen it's protected, because it's for network
please see the image.
'software e jogos' -> 'software and games'
like you see have the selection ok. but the windows don't give me the ask window, just open the program

cambalinho 142 Practically a Posting Shark

the letter is f.
i did:

echo > autorun.inf

'access denied'
the pen is blocked. i belive that i did before, but i don't know where :(
that i choosed the program and never executed again when i connected the pen to pc